{prompt_preamble}

The context contains definitions of relevant symbols (e.g. functions, structs, unions, global constants, macros), regex search results from the {repoName} codebase, regex search results from the historical commit messages and patches, and relevant context from certain files. One or more functions or other symbols may need to be edited to fix the bug.{' You will also be given a detailed explanation of why each piece of context is relevant to the bug and how different parts of the context are connected. The explanation will reveal how the person who collected this context understood the bug and all the code snippets and commits that are available to you.' if llm !='o1' else ''}

Your goal is to reason about the bug, generate a hypothesis about the root cause of the bug, and propose a patch to fix the bug.

You should reason from first principles about all possible root causes of the crash. You should understand the dataflow of variable and control flow through conditional statements, loops, jump statements and function calls. You should analyze this flow in reference to the crash report and the context provided. You should use the code search snippets to understand relevant patterns in the codebase, and the past commits to understand how code has evolved and how the developers usually write code.

You should then generate a specific and detailed hypothesis about what the bug is.

After generating the hypothesis, you should generate a patch based on the hypothesis. In the patch, you should provide the complete new rewrite of each symbol/function definition snippet that you want to modify. You should ensure that the starting line of your rewrite is the same as in the code given to you, and your rewrite is a complete replacement of the code snippet.

{'You should reach your hypothesis and patch through sound inferences from the crash report, the ' + repoName + ' repository code snippets, and the past commits. Focus on building up to the solution step-by-step, through careful reasoning steps.' if llm != 'o1' else ''}

You must provide your response in the following format:

<thoughts>
Write your analysis of the crash report, potentially buggy functions, symbol definitions, code snippets and past commits. You should reason about all possible root causes of the crash, and different ways to address them.
</thoughts>

<hypothesis>
Write a specific and detailed hypothesis about the root cause of the crash. Your hypothesis should be based on your analysis of the crash report, the context provided, and your understanding of the Linux kernel codebase.
</hypothesis>

<patch>
Write the complete new rewrite of each symbol/function definition snippet that you want to modify. Each symbol definition should be wrapped in <symbol> tags with file, name and start attributes. The code should start from the same line as the symbol definition code given to you, and should be a complete replacement of the code snippet.
</patch>

Your patch should be in the following format:

<patch>
<symbol file="/path/to/file.c" name="function_name" start="start_line_number">
New function body with modifications and starting from the same line as the function code snippet given to you
</symbol>
<symbol file="/path/to/another_file.c" name="another_function_name" start="another_start_line_number">
New function body with modifications and starting from the same line as the function code snippet given to you
</symbol>
<symbol file="/path/to/another_file.c" name="struct_name" start="struct_start_line_number">
New struct definition with modifications and starting from the same line as the struct code snippet given to you
</symbol>
</patch>
</actions>

Here is an example response:

{prompt_patch_gen_examples}