user: Please show me the C implementation that matches the assembly code listed below:

```asm
<construct_array_with_main_lobe>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x20,%rsp
  mov    %rdi,%r14
  mov    %rsi,%r12
  mov    %rdx,%r13
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  mov    (%rsi),%esi
  movslq %esi,%rax
  lea    0xf(,%rax,8),%rax
  mov    %rax,%rcx
  and    $0xfffffffffffffff0,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rdx
  sub    %rax,%rdx
L5:
  cmp    %rdx,%rsp
  je     L155
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L5
L155:
  mov    %rcx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L70
  orq    $0x0,-0x8(%rsp,%rax,1)
L70:
  mov    %rsp,%rbx
  lea    -0x30(%rbp),%rcx
  lea    -0x34(%rbp),%rdx
  mov    $0x1,%r8d
  mov    %r14,%rdi
  call   <amplitudeloc@plt>
  mov    -0x34(%rbp),%ecx
  movsd  -0x30(%rbp),%xmm2
  mov    (%r12),%edi
  test   %edi,%edi
  jle    L114
  mov    %edi,%edx
  mov    $0x0,%eax
L30:
  movsd  (%r14,%rax,8),%xmm0
  divsd  %xmm2,%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L30
L114:
  test   %ecx,%ecx
  je     L96
  lea    -0x1(%rdi),%esi
  lea    -0x1(%rcx),%eax
  test   %eax,%eax
  jle    L113
  movslq %eax,%rdx
  movq   D33(%rip),%xmm3
  movsd  D24(%rip),%xmm1
L29:
  mov    %edx,%ecx
  movsd  (%rbx,%rdx,8),%xmm0
  andpd  %xmm3,%xmm0
  comisd %xmm0,%xmm1
  ja     L183
  sub    $0x1,%rdx
  test   %edx,%edx
  jg     L29
  mov    $0x0,%ecx
L183:
  cmp    %eax,%esi
  jle    L191
  cltq
  movq   D33(%rip),%xmm3
  movsd  D24(%rip),%xmm1
L174:
  movsd  (%rbx,%rax,8),%xmm0
  andpd  %xmm3,%xmm0
  comisd %xmm0,%xmm1
  ja     L39
  add    $0x1,%rax
  cmp    %eax,%esi
  jg     L174
  jmp    L191
L113:
  mov    $0x0,%ecx
  jmp    L183
L39:
  mov    %eax,%esi
L191:
  test   %edi,%edi
  jle    L44
  mov    $0x0,%eax
  movapd %xmm2,%xmm5
  andpd  D33(%rip),%xmm5
  movsd  D24(%rip),%xmm4
  movsd  D48(%rip),%xmm3
  jmp    L56
L45:
  movq   $0x0,0x0(%r13,%rax,8)
L134:
  add    $0x1,%rax
  cmp    %eax,(%r12)
  jle    L44
L56:
  cmp    %eax,%ecx
  jge    L45
  cmp    %eax,%esi
  jle    L45
  movsd  (%rbx,%rax,8),%xmm1
  subsd  %xmm4,%xmm1
  movapd %xmm2,%xmm0
  divsd  %xmm5,%xmm0
  mulsd  %xmm1,%xmm0
  divsd  %xmm3,%xmm0
  movsd  %xmm0,0x0(%r13,%rax,8)
  jmp    L134
L44:
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L16
  mov    $0x0,%eax
  lea    -0x20(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %rbp
  ret
L96:
  lea    -0x1(%rdi),%esi
  mov    %ecx,%eax
  jmp    L183
L16:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D33
type_guessed: qword[2]
name: parse_data
arguments: data_tag: D24
type_guessed: f64
name: parse_data
arguments: data_tag: D48
type_guessed: byte[8]

tool: {"D33": [0x7fffffffffffffff,0x0000000000000000]}

tool: D24: 0.1

tool: {"D48": [0xcd,0xcc,0xcc,0xcc,0xcc,0xcc,0xec,0x3f]}

assistant: ```c
int construct_array_with_main_lobe(double *array_in, int *npts_in, double *array_out) {
  int amplitudeloc(double *array, int len, int *max_amp_loc, double *amplitude, int flag);
  int npts_peak_min, npts_peak_max, npts_peak;
  double peak_max, peak_min, value_peak;
  int count, flag;
  double cut_min = 0.1;
  double cut_max = 1.0;
  double array_tmp[*npts_in];
  amplitudeloc(array_in, *npts_in, &npts_peak_max, &peak_max, 1);
  if (value_peak == 0)
    value_peak = 1;
  npts_peak = npts_peak_max;
  value_peak = peak_max;
  for (count = 0; count < *npts_in; count++) {
    array_tmp[count] = array_in[count] / value_peak;
  }
  if (npts_peak == 0)
    npts_peak = 1;
  int ONSET = 0;
  int ENDSET = *npts_in - 1;
  for (count = npts_peak - 1; count > 0; count--) {
    if (fabs(array_tmp[count]) < cut_min) {
      ONSET = count;
      break;
    }
  }
  for (count = npts_peak - 1; count < *npts_in - 1; count++) {
    if (fabs(array_tmp[count]) < cut_min) {
      ENDSET = count;
      break;
    }
  }
  for (count = 0; count < *npts_in; count++) {
    if (count <= ONSET || count >= ENDSET)
      array_out[count] = 0;
    else {
      array_out[count] = value_peak / fabs(value_peak) * (array_tmp[count] - cut_min) / (1 - cut_min);
    }
  }
  return 0;
}
```