user: What is the c source code of the assembly code below?

```asm
<run_sex>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x150,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x148(%rsp)
  xor    %eax,%eax
  lea    0x40(%rsp),%rbp
  call   <write_sex_cfg@plt>
  mov    %r12,%rdx
  lea    D34(%rip),%rsi
  mov    %rbp,%rdi
  call   <sprintf@plt>
  mov    %rbp,%rdi
  call   <system@plt>
  lea    0x30(%rsp),%rcx
  lea    0x28(%rsp),%rdx
  lea    0x20(%rsp),%rsi
  lea    0x1c(%rsp),%rdi
  lea    0x38(%rsp),%r8
  call   <get_result@plt>
  movslq 0x1c(%rsp),%rbx
  pxor   %xmm1,%xmm1
  movsd  D30(%rip),%xmm4
  movq   D17(%rip),%xmm5
  mov    %rbx,%rbp
  nopl   0x0(%rax,%rax,1)
L112:
  test   %ebp,%ebp
  jle    L64
  mov    0x30(%rsp),%rdx
  mov    0x38(%rsp),%rcx
  xor    %eax,%eax
  movapd %xmm1,%xmm6
  movapd %xmm1,%xmm3
  nopl   0x0(%rax)
L14:
  movsd  (%rdx,%rax,8),%xmm0
  comisd %xmm1,%xmm0
  jbe    L77
  addsd  (%rcx,%rax,8),%xmm3
  addsd  %xmm4,%xmm6
L77:
  add    $0x1,%rax
  cmp    %rax,%rbx
  jne    L14
  divsd  %xmm6,%xmm3
  xor    %eax,%eax
  movapd %xmm1,%xmm0
  nop
L155:
  movsd  (%rdx,%rax,8),%xmm2
  comisd %xmm1,%xmm2
  jbe    L104
  movapd %xmm3,%xmm2
  subsd  (%rcx,%rax,8),%xmm2
  mulsd  %xmm2,%xmm2
  addsd  %xmm2,%xmm0
L104:
  add    $0x1,%rax
  cmp    %rax,%rbx
  jne    L155
  subsd  %xmm4,%xmm6
  divsd  %xmm6,%xmm0
  ucomisd %xmm0,%xmm1
  ja     L23
L43:
  sqrtsd %xmm0,%xmm0
  test   %ebp,%ebp
  jle    L126
L127:
  mov    0x38(%rsp),%rsi
  mov    0x30(%rsp),%rdx
  xor    %eax,%eax
  xor    %ecx,%ecx
  nopl   0x0(%rax)
L156:
  movsd  (%rdx,%rax,8),%xmm2
  comisd %xmm1,%xmm2
  jbe    L165
  movapd %xmm0,%xmm2
  movapd %xmm3,%xmm6
  subsd  (%rsi,%rax,8),%xmm6
  addsd  %xmm0,%xmm2
  comisd %xmm2,%xmm6
  ja     L20
  xorpd  %xmm5,%xmm2
  comisd %xmm6,%xmm2
  jbe    L165
L20:
  movq   $0x0,(%rdx,%rax,8)
  add    $0x1,%ecx
L165:
  add    $0x1,%rax
  cmp    %rbx,%rax
  jne    L156
  test   %ecx,%ecx
  jne    L112
  cmp    $0xa,%ebp
  jle    L126
L88:
  mov    0x148(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L147
  add    $0x150,%rsp
  movapd %xmm3,%xmm0
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L126:
  movsd  D12(%rip),%xmm3
  jmp    L88
  nopw   0x0(%rax,%rax,1)
L64:
  mov    D17(%rip),%rax
  movapd %xmm1,%xmm3
  divsd  %xmm1,%xmm3
  movq   %rax,%xmm0
  jmp    L43
L23:
  movsd  %xmm3,0x8(%rsp)
  call   <sqrt@plt>
  mov    D30(%rip),%rax
  movsd  0x8(%rsp),%xmm3
  pxor   %xmm1,%xmm1
  movq   D17(%rip),%xmm5
  movq   %rax,%xmm4
  jmp    L127
L147:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D34
data_type: string
name: unpack_data
arguments: tag: D30
data_type: f64
name: unpack_data
arguments: tag: D17
data_type: byte[8]
name: unpack_data
arguments: tag: D12
data_type: byte[8]

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

tool: D30: 1

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

tool: {"D12": [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;
}
```