
<task>
You are a professional security engineer identifying the input requirements for the target function `{FUNCTION_SIGNATURE}` in the project {PROJECT_NAME}.
We will provide you with the implementation of the target function, implementations of functions that reference the target function, and a set of tools that you can use to get additional context information about the target function.
Your goal is to analyze the provided function, its children functions, and its usages, and identify the input or state requirements that the target function needs to execute correctly, achieve high coverage and avoid false positive crashes.
False positive crashes can occur if the function is called with an input condition or state that is not feasible from any of its callers.
</task>

<expectations>
 We are interested in only the following kinds of requirements.
 - Input requirements that are necessary to prevent crashes in the target function.
    * Program crashes can be caused by assertion failures, invalid array indexing, out-of-bound memory accesses, pointer dereferencing failures.
 - Setup functions to call before the target function can be called.
    * This is the function or set of functions that are necessary to initialize the state of the target fucntion.
    * For example, if a function depends on a global variable which is set by another function, we need to call that function before the target function.
 - Requirements for creating valid input arguments.
    * What existing function or functions should be used to create valid input arguments.
    * This should be informed by how these arguments are created in the target function's callers.
    * For example, if a function uses an integer argument as a file descriptor when reading a file (eg the read function), you should check what functions the callers use to create valid file descriptors (eg the open function).
 - Requirements for variable argument lists in variadic functions
    * What factors influence the number and type of arguments in these functions?
    * How do the callers determine and initialize the arguments for these functions?
 - Relationship between inputs
    * For example, this can be the relationship between a pointer and an integer argument representing its size.
 - Input variables that should be fuzzed
    * What input variables can contain user-controlled input or invalid values at caller sites?
    * What input arguments always contain fixed, valid or constrained arguments at the caller sites?

Keep each requirement concise. Each requirement should contain two sentences.
The first is the requirement.
The second is a brief reason why it is important.
</expectations>

<steps>
Step 1: Collect the information you need to analyze the input requirements of a function.
The project source code directory is `{PROJECT_DIR}/` and was cloned from the project repository.
This includes:
   - The implementation of the target function
   - The call sites of the target function
   - The implementations of the target function's callers

Step 2: Identify the list of input parameters for the target function

Step 3: Analyze how each input parameter is generated in the function's callers.
   - is the input parameter always created or initialized using a specific function?
   - can the input parameter be user-controlled or contain invalid values?
   - Are there clear relationships between the input arguments passed to the function?

Step 4: Identify the implicit requirements of the parameters in the target functions.
Examples include:
   - Implicit assumptions about pointer states (null pointer, function pointers, string null-terminated pointers, etc)?
   - Implicit assumptions about range of integer variables or struct members?
   - Implicit assumptions about the number or types of variable arguments?

Step 5: Based on your analysis, specify how each input parameter should be initialized in the requirements.
Options include the following:
   - Initialized using a specific function (eg fopen)
   - Initialized using values from an array in the program
   - Initialized and constrained to a valid set of values, based on possible values the callers can provide
   - Initialized and constrained based on the target function's implicit requirements
   - Initialized using fuzz inputs

Step 6: Specify any functions that should be called before the target function.
This involves
   - Functions that sets the correct state of the target function
   - Functions that allocates or frees necessary resources

Step 7: Compile your results into a list of requirements for the function.
   - Each requirement should be short and precise.
   - If a requirement contains a constant, you should check the codebase and include the value of the constant as well.
   - If an input parameter is a struct or struct pointer, mention if the struct should be created as a whole or how each member should be initialized.
   - Identify a concise reason for including each requirement.

</steps>

Here is the provided data.

<target-function>
{FUNCTION_SOURCE}
</target-function>

<function-references>
{FUNCTION_REFERENCES}
</function-references>

{RESPONSE_FORMAT}


You will be provided with the following tools.
1. get_function_implementation: This is a tool you can use to retrieve the implementation of a function using the project's name and function's name as arguments.
2. search_project_files: This is an interactive tool you can use to search the project's source file using bash commands and find definitions or usages of functions, classes, structs, and variables.
    The usage guide for the Bash Tool is provided below.
3. return_final_result: This is the tool you must use to return your final result.

<instructions>
1. If the target function takes in a callback or function pointer as argument, provide instructions for creating this callback correctly based on how similar callbacks are created in the project.
   This should include what the callback should do, and what memory resources it should create or free.
</instructions>
