=== LANG ===
C
=== FENCE ===
c
=== FILE_NOUN ===
C source file
=== GENERATOR_INPUTS ===
the file's include preamble (inserted verbatim), the list of allowed headers, and the declarations of the repository headers the file includes plus the prototypes of the unit's other files
=== DOC_HEADER ===
# <file path>

**Unit**: `<directory name>` (C)
=== SECTION_KINDS ===
- `## VariableDef <Name>` for every file-scope variable (`static` ones included; `extern` declarations excluded) and every `#define` macro (object-like and function-like; include guards excluded).
- `## ClassDef <Name>` for every `struct`, `union` and `enum` definition with a body and every `typedef` (`typedef struct tag {...} T;` is one section named `T`).
- `## FunctionDef <Name>` for every function definition, `static` functions and `main` included. Function prototypes are not sections.
- The first line under every header is `**<Name>**: <one-sentence summary>.` This line is used as the symbol summary in a wiki, so make it a real summary.
=== TYPE_RULE ===
Types: give the exact definition in a fenced `c` block: the struct/union/enum tag, every member with its exact name, type, array size and bit-field width, every enumerator with its explicit value, and the typedef name. Comments may be dropped. Then explain member semantics, invariants and ownership of pointer members in prose.
=== VALUE_RULE ===
Variables and macros: give the exact definition in a fenced `c` block, including storage class (`static`, `const`), type, array size and initializer, and for macros the exact `#define` line with its parameters and replacement text. If an initializer is longer than about 20 lines (large tables), describe its content precisely in prose instead.
=== FUNC_RULE ===
   - the exact signature including storage class (`static`, `inline`), `const` qualifiers, pointer levels and parameter names;
   - error reporting: return codes, `errno`, out-parameters (when they are written and when they are left untouched), NULL returns;
   - memory ownership: who allocates and who frees each pointer argument and return value, buffer sizes and termination (`'\0'`), truncation rules;
   - side effects: file-scope and global variables read or mutated, output written with `printf`/`fprintf` (exact format strings), files, signals, `exit`/`abort` calls;
=== CONTEXT_RULE ===
Declarations listed in the context come from the repository headers this file includes or from OTHER source files of the same directory unit: do not document them as sections of this file, but name them when this file uses them; name the struct members and macros of such declarations that this file uses exactly, in backticks.
=== CODEGEN_RULES ===
- The include preamble of the original file is inserted verbatim before your code: do not write it again. Add other `#include` lines only for standard headers you need.
- Write EVERY documented definition, in the documented order, with exactly the documented names, signatures, storage classes and `const` qualifiers, matching the prototypes of the included headers exactly.
- Reproduce every documented macro, type definition, file-scope variable and initializer exactly.
- Do not redefine anything declared in the context headers or defined in the unit's other files.
- If you need an extra helper, make it `static` and prefix its name with `cdg_` (for example `cdg_trim`).
- Write complete, working implementations: no placeholders, no TODOs, no omitted bodies.
- Do not write tests, and no `main` function unless the documentation describes one.
- Allocate and free memory exactly as documented; reproduce documented behaviour literally: exact strings, format strings, return codes and boundary comparisons.
=== TEST_INTRO ===
ONE complete, self-contained C test suite (one translation unit, built on the embedded `codocs_test.h` assertion header) for the target C source file
=== TEST_RULES ===
- The file starts with exactly these two lines: `#include "codocs_test.h"` and `#include CODOCS_TARGET`. The second line includes the target source file itself, so its `static` functions and variables are reachable and may be called directly. Do not include the target file any other way.
- Test cases are `CODOCS_TEST(name) { ... }` (name: a C identifier, unique in the file) using only `CHECK(cond)`, `CHECK_EQ_INT(a, b)`, `CHECK_EQ_UINT(a, b)`, `CHECK_EQ_DBL(a, b, eps)`, `CHECK_EQ_STR(a, b)`, `CHECK_EQ_MEM(a, b, n)`, `CHECK_NULL(p)`, `CHECK_NOT_NULL(p)`, `REQUIRE(cond)` and `SKIP(msg)`. No other test framework.
- No `main` function (the runner provides it; a `main` of the target is renamed). The suite is linked with the unit's other source files; other existing test programs are not part of it.
- Include only standard headers and the repository headers the target or its unit already include.
- Prefix every helper function, type and file-scope variable you declare with `cdx_` and make it `static`; do not redeclare any name listed as taken.
- Deterministic: no network, no sleeps, no dependence on time, randomness or the environment; create files only under `getenv("TMPDIR")`.
- Free all memory you allocate. EVERY case must pass against the code as given: compute expected values by reading the source.
- Use strong, exact-value assertions on return values, out-parameters, struct members and buffers, spread across ALL functions of the target file, executing every branch.
=== TEST_SHAPE ===
CODOCS_TEST(clamp_bounds) { CHECK_EQ_INT(clamp(5, 0, 10), 5); }
=== MARK ===
//
