user: What would the C source look like for the assembly code provided here:

```asm
<find_optimal_freq>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x368,%rsp
  mov    %esi,0x14(%rsp)
  mov    %edx,%r12d
  mov    %rcx,%rbp
  mov    %r8d,0x10(%rsp)
  mov    %r9,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x358(%rsp)
  xor    %eax,%eax
  movl   $0x0,0xc(%rsp)
  test   %esi,%esi
  jne    L98
  mov    %edi,%r14d
  test   %r8d,%r8d
  jle    L136
  mov    %r8d,%r15d
  mov    %esi,0xc(%rsp)
  mov    $0x0,%ebx
  mov    $0x186a0,%r13d
  jmp    L163
L95:
  add    $0x1,%rbx
  cmp    %r15,%rbx
  je     L98
L163:
  mov    %r14d,%edi
  sub    0x0(%rbp,%rbx,4),%edi
  call   <fabs@plt>
  cmp    %r13d,%eax
  jge    L95
  mov    %r14d,%edi
  sub    0x0(%rbp,%rbx,4),%edi
  call   <fabs@plt>
  mov    %eax,%r13d
  mov    %ebx,0xc(%rsp)
  jmp    L95
L136:
  mov    0x14(%rsp),%eax
  mov    %eax,0xc(%rsp)
L98:
  lea    0x90(%rsp),%rdx
  lea    0x390(%rsp),%rcx
L145:
  lea    -0x40(%rdx),%rax
L49:
  movl   $0x0,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L49
  add    $0x40,%rdx
  cmp    %rcx,%rdx
  jne    L145
  lea    0x50(%rsp),%rbx
  mov    %rbx,%r8
  mov    0x10(%rsp),%r15d
  mov    %r15d,%ecx
  mov    %rbp,%rdx
  mov    0x3a0(%rsp),%esi
  mov    0x18(%rsp),%rdi
  call   <compute_scatter_percentage@plt>
  lea    0x20(%rsp),%rdx
  mov    %r12d,%ecx
  mov    %r15d,%esi
  mov    %rbx,%rdi
  call   <average_scatter_percentages@plt>
  test   %r15d,%r15d
  jle    L168
  mov    %r15d,%edx
  mov    $0x0,%eax
  mov    $0x0,%ecx
  movss  D92(%rip),%xmm1
  jmp    L176
L152:
  add    $0x1,%rax
  cmp    %rdx,%rax
  je     L42
L176:
  movss  0x20(%rsp,%rax,4),%xmm0
  comiss %xmm1,%xmm0
  jb     L152
  mov    %eax,%ecx
  movaps %xmm0,%xmm1
  jmp    L152
L168:
  mov    $0x0,%ecx
  movss  D92(%rip),%xmm1
L42:
  mov    0xc(%rsp),%esi
  movslq %esi,%rax
  movss  0x20(%rsp,%rax,4),%xmm3
  pxor   %xmm0,%xmm0
  cvtss2sd %xmm1,%xmm0
  pxor   %xmm2,%xmm2
  cvtss2sd %xmm3,%xmm2
  mulsd  D35(%rip),%xmm2
  comisd %xmm0,%xmm2
  ja     L194
  subss  %xmm3,%xmm1
  movss  D67(%rip),%xmm0
  comiss %xmm1,%xmm0
  cmova  %esi,%ecx
  mov    %ecx,0xc(%rsp)
L194:
  movslq 0xc(%rsp),%rax
  mov    0x0(%rbp,%rax,4),%eax
  mov    %eax,0xc(%rsp)
  lea    D59(%rip),%rsi
  lea    D49(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L30
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  jle    L191
  mov    %eax,%r13d
  mov    $0x0,%ebx
  lea    D18(%rip),%r15
  jmp    L117
L196:
  pxor   %xmm1,%xmm1
  cvtsi2ss %ebx,%xmm1
  movss  0x20(%rsp,%rbx,4),%xmm0
  divss  %xmm1,%xmm0
  cvtss2sd %xmm0,%xmm0
  mov    0x0(%rbp,%rbx,4),%ecx
  mov    %r15,%rsi
  mov    %r14,%rdi
  mov    $0x1,%eax
  call   <fprintf@plt>
L171:
  add    $0x1,%rbx
  cmp    %r13,%rbx
  je     L191
L117:
  mov    %ebx,%edx
  test   %r12d,%r12d
  jne    L196
  pxor   %xmm0,%xmm0
  cvtss2sd 0x20(%rsp,%rbx,4),%xmm0
  mov    0x0(%rbp,%rbx,4),%ecx
  mov    %r15,%rsi
  mov    %r14,%rdi
  mov    $0x1,%eax
  call   <fprintf@plt>
  jmp    L171
L191:
  mov    0x14(%rsp),%edx
  lea    D64(%rip),%rsi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %r12d,%edx
  lea    D48(%rip),%rsi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    0xc(%rsp),%edx
  lea    D87(%rip),%rsi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %r14,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  mov    %r14,%rdi
  call   <fclose@plt>
L30:
  mov    0x358(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L73
  mov    0xc(%rsp),%eax
  add    $0x368,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L73:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D92
type_infered: byte[4]
name: read_data
arguments: tag: D35
type_infered: f64
name: read_data
arguments: tag: D67
type_infered: f32
name: read_data
arguments: tag: D59
type_infered: string
name: read_data
arguments: tag: D49
type_infered: string
name: read_data
arguments: tag: D18
type_infered: string
name: read_data
arguments: tag: D64
type_infered: string
name: read_data
arguments: tag: D48
type_infered: string
name: read_data
arguments: tag: D87
type_infered: string

tool: {"D92": [0x00,0x00,0x20,0xc1]}

tool: D35: 1.15

tool: D67: 0.75

tool: D59: w

tool: D49: /tmp/freq_search.out

tool: D18: 
%2d %d %10.7lf

tool: D64: 
Cutlass: %d

tool: D48: 
Freq Weighting: %d

tool: D87: 
Returned Frequency: %d kHz

assistant: ```c
int find_optimal_freq(int start_freq, int cutlass, int fw, int sounder_freqs[], int sft, struct sounder_struct *sounder_data, int act_snd_rec) {
  int i, j;
  int def_freq, def_freq_bin = 0;
  float iscat_percent[12][16];
  float average_iscat_percent[12];
  float max_scatter = -10;
  int max_freq_bin = 0;
  int dlf;
  FILE *out;
  if (!cutlass) {
    dlf = 100000;
    for (i = 0; i < sft; i++) {
      if (fabs(start_freq - sounder_freqs[i]) < dlf) {
        dlf = fabs(start_freq - sounder_freqs[i]);
        def_freq_bin = i;
      }
    }
  }
  for (i = 0; i < 12; i++)
    for (j = 0; j < 16; j++) {
      iscat_percent[i][j] = 0;
    }
  compute_scatter_percentage(sounder_data, act_snd_rec, sounder_freqs, sft, iscat_percent);
  average_scatter_percentages(iscat_percent, sft, average_iscat_percent, fw);
  max_scatter = -10;
  for (i = 0; i < sft; i++)
    if (average_iscat_percent[i] >= max_scatter) {
      max_scatter = average_iscat_percent[i];
      max_freq_bin = i;
    }
  if (max_scatter < 1.15 * average_iscat_percent[def_freq_bin] || (max_scatter - average_iscat_percent[def_freq_bin]) < 0.75)
    max_freq_bin = def_freq_bin;
  def_freq = sounder_freqs[max_freq_bin];
  out = fopen("/tmp/freq_search.out", "w");
  if (out != NULL) {
    for (i = 0; i < sft; i++) {
      if (!fw)
        fprintf(out, "\n%2d %d %10.7lf", i, sounder_freqs[i], average_iscat_percent[i]);
      else
        fprintf(out, "\n%2d %d %10.7lf", i, sounder_freqs[i], average_iscat_percent[i] / i);
    }
    fprintf(out, "\nCutlass: %d", cutlass);
    fprintf(out, "\nFreq Weighting: %d", fw);
    fprintf(out, "\nReturned Frequency: %d kHz", def_freq);
    fprintf(out, "\n");
    fclose(out);
  }
  return (def_freq);
}
```