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

```asm
<main>:
  endbr64
  push   %r15
  mov    $0x11,%esi
  mov    $0x1,%edi
  push   %r14
  lea    D149(%rip),%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <vector@plt>
  mov    %rax,%r12
  lea    0x14(%rsp),%rax
  mov    %rax,0x8(%rsp)
L22:
  mov    $0x11,%esi
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x8(%rsp),%rsi
  lea    D155(%rip),%rdi
  call   <scanf@plt>
  movss  0x14(%rsp),%xmm1
  pxor   %xmm3,%xmm3
  comiss %xmm1,%xmm3
  jae    L5
  xor    %ebx,%ebx
  jmp    L9
  nopl   0x0(%rax)
L98:
  movss  0x14(%rsp),%xmm1
L9:
  pxor   %xmm0,%xmm0
  cvtss2sd %xmm1,%xmm1
  cvtsi2sd %ebx,%xmm0
  mulsd  D75(%rip),%xmm0
  divsd  %xmm1,%xmm0
  call   <cos@plt>
  movss  %xmm0,0x4(%r12,%rbx,4)
  add    $0x1,%rbx
  cmp    $0x11,%rbx
  jne    L98
  mov    $0x10,%esi
  mov    %r12,%rdi
  call   <cosft1@plt>
  movss  0x4(%r12),%xmm0
  comiss D64(%rip),%xmm0
  movaps %xmm0,%xmm6
  minss  D3(%rip),%xmm6
  movss  %xmm6,(%rsp)
  ja     L54
  movss  D64(%rip),%xmm0
L54:
  movss  0x8(%r12),%xmm1
  mov    $0x1,%ebp
  lea    D173(%rip),%r15
  movaps %xmm1,%xmm7
  maxss  %xmm0,%xmm1
  minss  (%rsp),%xmm7
  movss  0xc(%r12),%xmm0
  movaps %xmm0,%xmm6
  minss  %xmm7,%xmm6
  maxss  %xmm1,%xmm0
  movss  0x10(%r12),%xmm1
  movaps %xmm1,%xmm7
  minss  %xmm6,%xmm7
  maxss  %xmm0,%xmm1
  movss  0x14(%r12),%xmm0
  movaps %xmm0,%xmm6
  minss  %xmm7,%xmm6
  maxss  %xmm1,%xmm0
  movss  0x18(%r12),%xmm1
  movaps %xmm1,%xmm7
  minss  %xmm6,%xmm7
  maxss  %xmm0,%xmm1
  movss  0x1c(%r12),%xmm0
  movaps %xmm0,%xmm6
  minss  %xmm7,%xmm6
  maxss  %xmm1,%xmm0
  movss  0x20(%r12),%xmm1
  movaps %xmm1,%xmm7
  minss  %xmm6,%xmm7
  maxss  %xmm0,%xmm1
  movss  0x24(%r12),%xmm0
  movaps %xmm0,%xmm6
  minss  %xmm7,%xmm6
  maxss  %xmm1,%xmm0
  movss  0x28(%r12),%xmm1
  movaps %xmm1,%xmm7
  minss  %xmm6,%xmm7
  maxss  %xmm0,%xmm1
  movss  0x2c(%r12),%xmm0
  movaps %xmm0,%xmm2
  minss  %xmm7,%xmm2
  maxss  %xmm1,%xmm0
  movss  0x30(%r12),%xmm1
  movaps %xmm1,%xmm3
  minss  %xmm2,%xmm3
  maxss  %xmm0,%xmm1
  movss  0x34(%r12),%xmm0
  movss  D102(%rip),%xmm2
  movaps %xmm0,%xmm4
  minss  %xmm3,%xmm4
  maxss  %xmm1,%xmm0
  movss  0x38(%r12),%xmm1
  movaps %xmm1,%xmm5
  minss  %xmm4,%xmm5
  maxss  %xmm0,%xmm1
  movss  0x3c(%r12),%xmm0
  movaps %xmm0,%xmm6
  minss  %xmm5,%xmm6
  maxss  %xmm1,%xmm0
  movss  0x40(%r12),%xmm1
  movaps %xmm1,%xmm7
  minss  %xmm6,%xmm7
  maxss  %xmm0,%xmm1
  movss  0x44(%r12),%xmm0
  movaps %xmm0,%xmm6
  minss  %xmm7,%xmm6
  maxss  %xmm1,%xmm0
  subss  %xmm6,%xmm0
  movss  %xmm6,(%rsp)
  divss  %xmm0,%xmm2
  movss  %xmm2,0x4(%rsp)
  nopl   0x0(%rax)
L21:
  movss  (%r12,%rbp,4),%xmm0
  mov    %ebp,%esi
  mov    %r15,%rdi
  mov    $0x1,%eax
  xor    %r13d,%r13d
  movaps %xmm0,%xmm1
  subss  (%rsp),%xmm1
  cvtss2sd %xmm0,%xmm0
  mulss  0x4(%rsp),%xmm1
  cvtss2sd %xmm1,%xmm1
  addsd  D78(%rip),%xmm1
  addsd  D166(%rip),%xmm1
  cvttsd2si %xmm1,%ebx
  call   <printf@plt>
  test   %ebx,%ebx
  js     L102
  xchg   %ax,%ax
L128:
  mov    $0x2a,%edi
  add    $0x1,%r13d
  call   <putchar@plt>
  cmp    %r13d,%ebx
  jge    L128
L102:
  mov    $0xa,%edi
  add    $0x1,%rbp
  call   <putchar@plt>
  cmp    $0x12,%rbp
  jne    L21
  lea    D123(%rip),%rdi
  call   <puts@plt>
  xor    %eax,%eax
  call   <getchar@plt>
  mov    $0x10,%esi
  mov    %r12,%rdi
  call   <cosft1@plt>
  movss  0x4(%r12),%xmm0
  comiss D64(%rip),%xmm0
  movaps %xmm0,%xmm3
  minss  D3(%rip),%xmm3
  movss  %xmm3,(%rsp)
  ja     L8
  movss  D64(%rip),%xmm0
L8:
  movss  0x8(%r12),%xmm1
  mov    $0x1,%ebp
  lea    D177(%rip),%r15
  movaps %xmm1,%xmm4
  maxss  %xmm0,%xmm1
  minss  (%rsp),%xmm4
  movss  0xc(%r12),%xmm0
  movaps %xmm0,%xmm5
  minss  %xmm4,%xmm5
  maxss  %xmm1,%xmm0
  movss  0x10(%r12),%xmm1
  movaps %xmm1,%xmm6
  minss  %xmm5,%xmm6
  maxss  %xmm0,%xmm1
  movss  0x14(%r12),%xmm0
  movaps %xmm0,%xmm2
  minss  %xmm6,%xmm2
  maxss  %xmm1,%xmm0
  movss  0x18(%r12),%xmm1
  movaps %xmm1,%xmm3
  minss  %xmm2,%xmm3
  maxss  %xmm0,%xmm1
  movss  0x1c(%r12),%xmm0
  movaps %xmm0,%xmm7
  minss  %xmm3,%xmm7
  maxss  %xmm1,%xmm0
  movss  0x20(%r12),%xmm1
  movaps %xmm1,%xmm4
  minss  %xmm7,%xmm4
  maxss  %xmm0,%xmm1
  movss  0x24(%r12),%xmm0
  movaps %xmm0,%xmm5
  minss  %xmm4,%xmm5
  maxss  %xmm1,%xmm0
  movss  0x28(%r12),%xmm1
  movaps %xmm1,%xmm6
  minss  %xmm5,%xmm6
  maxss  %xmm0,%xmm1
  movss  0x2c(%r12),%xmm0
  movaps %xmm0,%xmm2
  minss  %xmm6,%xmm2
  maxss  %xmm1,%xmm0
  movss  0x30(%r12),%xmm1
  movaps %xmm1,%xmm3
  minss  %xmm2,%xmm3
  maxss  %xmm0,%xmm1
  movss  0x34(%r12),%xmm0
  movss  D102(%rip),%xmm2
  movaps %xmm0,%xmm7
  minss  %xmm3,%xmm7
  maxss  %xmm1,%xmm0
  movss  0x38(%r12),%xmm1
  movaps %xmm1,%xmm4
  minss  %xmm7,%xmm4
  maxss  %xmm0,%xmm1
  movss  0x3c(%r12),%xmm0
  movaps %xmm0,%xmm5
  minss  %xmm4,%xmm5
  maxss  %xmm1,%xmm0
  movss  0x40(%r12),%xmm1
  movaps %xmm1,%xmm6
  minss  %xmm5,%xmm6
  maxss  %xmm0,%xmm1
  movss  0x44(%r12),%xmm0
  movaps %xmm0,%xmm7
  minss  %xmm6,%xmm7
  maxss  %xmm1,%xmm0
  subss  %xmm7,%xmm0
  movss  %xmm7,(%rsp)
  divss  %xmm0,%xmm2
  movss  %xmm2,0x4(%rsp)
  nopw   0x0(%rax,%rax,1)
L77:
  movss  (%r12,%rbp,4),%xmm0
  subss  (%rsp),%xmm0
  mov    %ebp,%esi
  mov    %r15,%rdi
  mulss  0x4(%rsp),%xmm0
  xor    %eax,%eax
  xor    %r13d,%r13d
  cvtss2sd %xmm0,%xmm0
  addsd  D78(%rip),%xmm0
  addsd  D166(%rip),%xmm0
  cvttsd2si %xmm0,%ebx
  call   <printf@plt>
  test   %ebx,%ebx
  js     L0
  nopl   0x0(%rax)
L82:
  mov    $0x2a,%edi
  add    $0x1,%r13d
  call   <putchar@plt>
  cmp    %r13d,%ebx
  jge    L82
L0:
  mov    $0xa,%edi
  add    $0x1,%rbp
  call   <putchar@plt>
  cmp    $0x12,%rbp
  jne    L77
  jmp    L22
L5:
  mov    $0x11,%edx
  mov    $0x1,%esi
  mov    %r12,%rdi
  call   <free_vector@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L58
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L58:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D149
datatype: string
name: retrieve_data
arguments: data_label: D155
datatype: string
name: retrieve_data
arguments: data_label: D75
datatype: byte[8]
name: retrieve_data
arguments: data_label: D64
datatype: byte[4]
name: retrieve_data
arguments: data_label: D3
datatype: f32
name: retrieve_data
arguments: data_label: D173
datatype: string
name: retrieve_data
arguments: data_label: D102
datatype: f32
name: retrieve_data
arguments: data_label: D78
datatype: f64
name: retrieve_data
arguments: data_label: D166
datatype: byte[8]
name: retrieve_data
arguments: data_label: D123
datatype: string
name: retrieve_data
arguments: data_label: D177
datatype: string

tool: D149: Period of cosine in channels (2-%2d)


tool: D155: %f

tool: {"D75": [0x4a,0xd8,0x12,0x4d,0xfb,0x21,0x19,0x40]}

tool: {"D64": [0xf9,0x02,0x15,0xd0]}

tool: D3: 10000000000

tool: D173: %4d %6.2f 

tool: D102: 30

tool: D78: 0.5

tool: {"D166": [0xfc,0xa9,0xf1,0xd2,0x4d,0x62,0x50,0x3f]}

tool: D123: press RETURN to continue ...

tool: D177: %4d 

assistant: ```c
int main(void) {
  int i, j, nlim;
  float big, per, scal, small, *data;
  data = vector(1, 17);
  for (;;) {
    printf("Period of cosine in channels (2-%2d)\n", 17);
    scanf("%f", &per);
    if (per <= 0.0)
      break;
    for (i = 1; i <= 17; i++)
      data[i] = cos(2.0 * 3.1415926 * (i - 1) / per);
    cosft1(data, 17 - 1);
    big = -1.0e10;
    small = 1.0e10;
    for (i = 1; i <= 17; i++) {
      if (data[i] < small)
        small = data[i];
      if (data[i] > big)
        big = data[i];
    }
    scal = 30.0 / (big - small);
    for (i = 1; i <= 17; i++) {
      nlim = (int)(0.5 + scal * (data[i] - small) + 1.0e-3);
      printf("%4d %6.2f ", i, data[i]);
      for (j = 1; j <= nlim + 1; j++)
        printf("*");
      printf("\n");
    }
    printf("press RETURN to continue ...\n");
    (void)getchar();
    cosft1(data, 17 - 1);
    big = -1.0e10;
    small = 1.0e10;
    for (i = 1; i <= 17; i++) {
      if (data[i] < small)
        small = data[i];
      if (data[i] > big)
        big = data[i];
    }
    scal = 30.0 / (big - small);
    for (i = 1; i <= 17; i++) {
      nlim = (int)(0.5 + scal * (data[i] - small) + 1.0e-3);
      printf("%4d ", i);
      for (j = 1; j <= nlim + 1; j++)
        printf("*");
      printf("\n");
    }
  }
  free_vector(data, 1, 17);
  return 0;
}
```