user: 请从给定的汇编指令推导出C源代码：

```asm
<find_optimal_freq>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x390,%rsp
  mov    %edi,-0x374(%rbp)
  mov    %esi,-0x378(%rbp)
  mov    %edx,-0x37c(%rbp)
  mov    %rcx,-0x388(%rbp)
  mov    %r8d,-0x380(%rbp)
  mov    %r9,-0x390(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x35c(%rbp)
  movss  D42(%rip),%xmm0
  movss  %xmm0,-0x358(%rbp)
  movl   $0x0,-0x354(%rbp)
  cmpl   $0x0,-0x378(%rbp)
  jne    L172
  movl   $0x186a0,-0x350(%rbp)
  movl   $0x0,-0x364(%rbp)
  jmp    L35
L96:
  mov    -0x364(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x388(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x374(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,%edi
  call   <fabs@plt>
  cmp    %eax,-0x350(%rbp)
  jle    L129
  mov    -0x364(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x388(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x374(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,%edi
  call   <fabs@plt>
  mov    %eax,-0x350(%rbp)
  mov    -0x364(%rbp),%eax
  mov    %eax,-0x35c(%rbp)
L129:
  addl   $0x1,-0x364(%rbp)
L35:
  mov    -0x364(%rbp),%eax
  cmp    -0x380(%rbp),%eax
  jl     L96
L172:
  movl   $0x0,-0x364(%rbp)
  jmp    L121
L49:
  movl   $0x0,-0x360(%rbp)
  jmp    L97
L120:
  mov    -0x360(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x364(%rbp),%eax
  cltq
  shl    $0x4,%rax
  add    %rdx,%rax
  pxor   %xmm0,%xmm0
  movss  %xmm0,-0x310(%rbp,%rax,4)
  addl   $0x1,-0x360(%rbp)
L97:
  cmpl   $0xf,-0x360(%rbp)
  jle    L120
  addl   $0x1,-0x364(%rbp)
L121:
  cmpl   $0xb,-0x364(%rbp)
  jle    L49
  lea    -0x310(%rbp),%rsi
  mov    -0x380(%rbp),%ecx
  mov    -0x388(%rbp),%rdx
  mov    -0x390(%rbp),%rax
  mov    %rsi,%r8
  mov    0x10(%rbp),%esi
  mov    %rax,%rdi
  call   <compute_scatter_percentage@plt>
  mov    -0x37c(%rbp),%ecx
  lea    -0x340(%rbp),%rdx
  mov    -0x380(%rbp),%esi
  lea    -0x310(%rbp),%rax
  mov    %rax,%rdi
  call   <average_scatter_percentages@plt>
  movss  D42(%rip),%xmm0
  movss  %xmm0,-0x358(%rbp)
  movl   $0x0,-0x364(%rbp)
  jmp    L164
L59:
  mov    -0x364(%rbp),%eax
  cltq
  movss  -0x340(%rbp,%rax,4),%xmm0
  comiss -0x358(%rbp),%xmm0
  jb     L55
  mov    -0x364(%rbp),%eax
  cltq
  movss  -0x340(%rbp,%rax,4),%xmm0
  movss  %xmm0,-0x358(%rbp)
  mov    -0x364(%rbp),%eax
  mov    %eax,-0x354(%rbp)
L55:
  addl   $0x1,-0x364(%rbp)
L164:
  mov    -0x364(%rbp),%eax
  cmp    -0x380(%rbp),%eax
  jl     L59
  pxor   %xmm1,%xmm1
  cvtss2sd -0x358(%rbp),%xmm1
  mov    -0x35c(%rbp),%eax
  cltq
  movss  -0x340(%rbp,%rax,4),%xmm0
  pxor   %xmm2,%xmm2
  cvtss2sd %xmm0,%xmm2
  movsd  D26(%rip),%xmm0
  mulsd  %xmm2,%xmm0
  comisd %xmm1,%xmm0
  ja     L63
  mov    -0x35c(%rbp),%eax
  cltq
  movss  -0x340(%rbp,%rax,4),%xmm2
  movss  -0x358(%rbp),%xmm0
  movaps %xmm0,%xmm1
  subss  %xmm2,%xmm1
  movss  D14(%rip),%xmm0
  comiss %xmm1,%xmm0
  jbe    L156
L63:
  mov    -0x35c(%rbp),%eax
  mov    %eax,-0x354(%rbp)
L156:
  mov    -0x354(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x388(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x34c(%rbp)
  lea    D6(%rip),%rax
  mov    %rax,%rsi
  lea    D35(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x348(%rbp)
  cmpq   $0x0,-0x348(%rbp)
  je     L79
  movl   $0x0,-0x364(%rbp)
  jmp    L176
L84:
  cmpl   $0x0,-0x37c(%rbp)
  jne    L101
  mov    -0x364(%rbp),%eax
  cltq
  movss  -0x340(%rbp,%rax,4),%xmm0
  pxor   %xmm3,%xmm3
  cvtss2sd %xmm0,%xmm3
  movq   %xmm3,%rsi
  mov    -0x364(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x388(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x364(%rbp),%edx
  mov    -0x348(%rbp),%rax
  movq   %rsi,%xmm0
  lea    D109(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <fprintf@plt>
  jmp    L31
L101:
  mov    -0x364(%rbp),%eax
  cltq
  movss  -0x340(%rbp,%rax,4),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x364(%rbp),%xmm1
  divss  %xmm1,%xmm0
  pxor   %xmm4,%xmm4
  cvtss2sd %xmm0,%xmm4
  movq   %xmm4,%rsi
  mov    -0x364(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x388(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x364(%rbp),%edx
  mov    -0x348(%rbp),%rax
  movq   %rsi,%xmm0
  lea    D109(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <fprintf@plt>
L31:
  addl   $0x1,-0x364(%rbp)
L176:
  mov    -0x364(%rbp),%eax
  cmp    -0x380(%rbp),%eax
  jl     L84
  mov    -0x378(%rbp),%edx
  mov    -0x348(%rbp),%rax
  lea    D44(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    -0x37c(%rbp),%edx
  mov    -0x348(%rbp),%rax
  lea    D17(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    -0x34c(%rbp),%edx
  mov    -0x348(%rbp),%rax
  lea    D103(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    -0x348(%rbp),%rax
  mov    %rax,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  mov    -0x348(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L79:
  mov    -0x34c(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L61
  call   <__stack_chk_fail@plt>
L61:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D42
data_type: byte[4]
name: extract_symbolic_data
arguments: label: D26
data_type: f64
name: extract_symbolic_data
arguments: label: D14
data_type: f32
name: extract_symbolic_data
arguments: label: D6
data_type: string
name: extract_symbolic_data
arguments: label: D35
data_type: string
name: extract_symbolic_data
arguments: label: D109
data_type: string
name: extract_symbolic_data
arguments: label: D44
data_type: string
name: extract_symbolic_data
arguments: label: D17
data_type: string
name: extract_symbolic_data
arguments: label: D103
data_type: string

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

tool: D26: 1.15

tool: D14: 0.75

tool: D6: w

tool: D35: /tmp/freq_search.out

tool: D109: 
%2d %d %10.7lf

tool: D44: 
Cutlass: %d

tool: D17: 
Freq Weighting: %d

tool: D103: 
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);
}
```