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

```asm
<run_sex>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x148,%rsp
  mov    %rdi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x138(%rsp)
  xor    %eax,%eax
  call   <write_sex_cfg@plt>
  lea    0x30(%rsp),%rbp
  mov    %rbx,%rdx
  lea    D56(%rip),%rsi
  mov    %rbp,%rdi
  call   <sprintf@plt>
  mov    %rbp,%rdi
  call   <system@plt>
  lea    0x20(%rsp),%rcx
  lea    0x18(%rsp),%rdx
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  lea    0x28(%rsp),%r8
  call   <get_result@plt>
  jmp    L70
L168:
  addsd  (%rsi,%rax,8),%xmm1
  addsd  D49(%rip),%xmm2
L152:
  add    $0x1,%rax
  cmp    %rcx,%rax
  je     L187
L172:
  movsd  (%rdx,%rax,8),%xmm0
  comisd %xmm3,%xmm0
  ja     L168
  jmp    L152
L150:
  add    $0x1,%rax
  cmp    %rcx,%rax
  je     L110
L9:
  movsd  (%rdx,%rax,8),%xmm1
  comisd %xmm3,%xmm1
  jbe    L150
  movq   %rbx,%xmm1
  subsd  (%rsi,%rax,8),%xmm1
  mulsd  %xmm1,%xmm1
  addsd  %xmm1,%xmm0
  jmp    L150
L110:
  subsd  D49(%rip),%xmm2
  divsd  %xmm2,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L145
L50:
  sqrtsd %xmm0,%xmm0
L78:
  test   %ebp,%ebp
  jle    L4
  mov    $0x0,%eax
  mov    $0x0,%esi
  pxor   %xmm3,%xmm3
  jmp    L127
L145:
  call   <sqrt@plt>
  jmp    L78
L218:
  movq   $0x0,(%rdx)
  add    $0x1,%esi
L154:
  mov    0xc(%rsp),%ebp
  add    $0x1,%rax
  cmp    %eax,%ebp
  jle    L199
L127:
  mov    0x20(%rsp),%rdx
  lea    (%rdx,%rax,8),%rdx
  movsd  (%rdx),%xmm1
  comisd %xmm3,%xmm1
  jbe    L154
  mov    0x28(%rsp),%rcx
  movq   %rbx,%xmm2
  subsd  (%rcx,%rax,8),%xmm2
  movapd %xmm0,%xmm1
  addsd  %xmm0,%xmm1
  comisd %xmm1,%xmm2
  ja     L218
  xorpd  D7(%rip),%xmm1
  comisd %xmm2,%xmm1
  jbe    L154
  jmp    L218
L199:
  test   %esi,%esi
  je     L4
L70:
  mov    0xc(%rsp),%ebp
  test   %ebp,%ebp
  jle    L132
  mov    0x20(%rsp),%rdx
  mov    0x28(%rsp),%rsi
  mov    %ebp,%ecx
  mov    $0x0,%eax
  pxor   %xmm2,%xmm2
  movapd %xmm2,%xmm1
  movapd %xmm2,%xmm3
  jmp    L172
L4:
  cmp    $0xa,%ebp
  jg     L173
  mov    D45(%rip),%rbx
L173:
  mov    0x138(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L93
  movq   %rbx,%xmm0
  add    $0x148,%rsp
  pop    %rbx
  pop    %rbp
  ret
L187:
  divsd  %xmm2,%xmm1
  movq   %xmm1,%rbx
  mov    $0x0,%eax
  pxor   %xmm0,%xmm0
  movapd %xmm0,%xmm3
  jmp    L9
L132:
  pxor   %xmm4,%xmm4
  divsd  %xmm4,%xmm4
  movq   %xmm4,%rbx
  movsd  D7(%rip),%xmm0
  jmp    L50
L93:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D56
type: string
name: extract_symbolic_data
arguments: data_label: D49
type: f64
name: extract_symbolic_data
arguments: data_label: D7
type: byte[16]
name: extract_symbolic_data
arguments: data_label: D45
type: byte[8]

tool: D56: sex -c _sex.cfg %s

tool: D49: 1

tool: {"D7": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: {"D45": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xbf]}

assistant: ```c
double run_sex(char *fitsfile) {
  char command[256];
  int N, j, x;
  double *xx, *yy, *F, *Q;
  double S, NN, E, tt;
  write_sex_cfg();
  sprintf(command, "sex -c _sex.cfg %s", fitsfile);
  system(command);
  get_result(&N, &xx, &yy, &F, &Q);
  do {
    S = 0;
    NN = 0;
    for (x = 0; x < N; x++)
      if (F[x] > 0) {
        S += Q[x];
        NN++;
      }
    S /= NN;
    E = 0;
    for (x = 0; x < N; x++)
      if (F[x] > 0) {
        tt = S - Q[x];
        E += tt * tt;
      }
    E = sqrt(E / (NN - 1));
    j = 0;
    for (x = 0; x < N; x++) {
      tt = S - Q[x];
      if (F[x] > 0)
        if ((tt > 2 * E) || (tt < -2 * E)) {
          F[x] = 0;
          j++;
        }
    }
  } while (j);
  if (N > 10)
    return S;
  else
    return -1.0;
}
```