user: Translate the below assembly code into C programming language:

```asm
<autocorr>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %edx,%r15d
  test   %esi,%esi
  jle    L64
  mov    %rdi,%r14
  mov    %esi,%ebp
  mov    %rdi,%rdx
  lea    -0x1(%rsi),%eax
  lea    0x8(%rdi,%rax,8),%rcx
  mov    %rdi,%rax
  pxor   %xmm1,%xmm1
L78:
  addsd  (%rax),%xmm1
  add    $0x8,%rax
  cmp    %rcx,%rax
  jne    L78
  pxor   %xmm2,%xmm2
  cvtsi2sd %ebp,%xmm2
  divsd  %xmm2,%xmm1
  mov    %r14,%rax
L152:
  movsd  (%rax),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rcx,%rax
  jne    L152
  pxor   %xmm1,%xmm1
L154:
  movsd  (%rdx),%xmm0
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  add    $0x8,%rdx
  cmp    %rcx,%rdx
  jne    L154
  divsd  %xmm2,%xmm1
  movsd  %xmm1,0x18(%rsp)
  mov    %ebp,%eax
  shr    $0x1f,%eax
  add    %ebp,%eax
  sar    %eax
  mov    %eax,0x20(%rsp)
  cmp    $0x1,%ebp
  jle    L167
  mov    $0x0,%ebx
  movl   $0x0,0x24(%rsp)
  mov    $0x0,%r13d
  mov    $0x0,%r12d
  jmp    L55
L166:
  movsd  0x8(%rsp),%xmm0
  mov    0x14(%rsp),%esi
  lea    D44(%rip),%rdi
  call   <printf@plt>
  test   %r13d,%r13d
  jne    L127
  movsd  0x28(%rsp),%xmm7
  addsd  0x8(%rsp),%xmm7
  movsd  %xmm7,0x28(%rsp)
L127:
  add    $0x1,%rbx
  sub    $0x1,%ebp
  cmp    %ebx,0x20(%rsp)
  jle    L138
L55:
  mov    %ebx,0x14(%rsp)
  mov    %ebp,%ecx
  pxor   %xmm1,%xmm1
  test   %ebp,%ebp
  jle    L155
  mov    %r14,%rax
  lea    -0x1(%rbp),%edx
  lea    0x8(%r14,%rdx,8),%rdx
  pxor   %xmm1,%xmm1
L124:
  movsd  (%rax),%xmm0
  mulsd  (%rax,%rbx,8),%xmm0
  addsd  %xmm0,%xmm1
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L124
L155:
  pxor   %xmm0,%xmm0
  cvtsi2sd %ecx,%xmm0
  mulsd  0x18(%rsp),%xmm0
  divsd  %xmm0,%xmm1
  movsd  %xmm1,0x8(%rsp)
  movapd %xmm1,%xmm0
  andpd  D40(%rip),%xmm0
  movsd  D47(%rip),%xmm5
  comisd %xmm0,%xmm5
  sbb    $0xffffffff,%r12d
  cmp    $0x2,%r12d
  mov    $0x1,%eax
  cmovge %eax,%r13d
  test   %r15d,%r15d
  je     L166
  movapd %xmm1,%xmm0
  call   <exp@plt>
  mov    0x14(%rsp),%esi
  lea    D44(%rip),%rdi
  call   <printf@plt>
  test   %r13d,%r13d
  je     L127
  cmpl   $0x0,0x24(%rsp)
  jne    L127
  movsd  0x8(%rsp),%xmm0
  call   <exp@plt>
  movapd %xmm0,%xmm2
  pxor   %xmm0,%xmm0
  cvtsi2sdl 0x14(%rsp),%xmm0
  movsd  D41(%rip),%xmm1
  subsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm0
  call   <ceil@plt>
  mov    %eax,0x24(%rsp)
  jmp    L127
L64:
  movl   $0x0,0x24(%rsp)
L138:
  test   %r15d,%r15d
  je     L12
L62:
  mov    0x24(%rsp),%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L167:
  movl   $0x0,0x24(%rsp)
  jmp    L138
L12:
  movsd  0x28(%rsp),%xmm0
  call   <ceil@plt>
  mov    %eax,0x24(%rsp)
  jmp    L62
```

tool_calls: name: parse_data
arguments: tag: D44
type_guessed: string
name: parse_data
arguments: tag: D40
type_guessed: qword[2]
name: parse_data
arguments: tag: D47
type_guessed: f64
name: parse_data
arguments: tag: D41
type_guessed: byte[8]

tool: D44: %d %f


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

tool: D47: 0.01

tool: {"D41": [0x69,0x57,0x14,0x8b,0x0a,0xbf,0x05,0x40]}

assistant: ```c
int autocorr(double *dat, int num, int log_scale) {
  int i, j;
  double avg = 0;
  double norm = 0;
  double ac = 0;
  int hits = 0;
  int decayed = 0;
  double ac_integral;
  int corr_time = 0;
  int log_corr_time = 0;
  for (i = 0; i < num; i++)
    avg += *(dat + i);
  avg /= num;
  for (i = 0; i < num; i++)
    *(dat + i) -= avg;
  for (i = 0; i < num; i++) {
    norm += *(dat + i) * (*(dat + i));
  }
  norm /= num;
  for (i = 0; i < (num / 2); i++) {
    ac = 0;
    for (j = 0; j < (num - i); j++) {
      ac += *(dat + j) * (*(dat + i + j));
    }
    ac /= (num - i) * norm;
    if (fabs(ac) <= 0.01)
      ++hits;
    if (hits >= 2)
      decayed = 1;
    if (log_scale) {
      printf("%d %f\n", i, exp(ac));
      if (decayed && !log_corr_time) {
        log_corr_time = (int)(ceil(((double)i) / (exp(1.0) - exp(ac))));
      }
    } else {
      printf("%d %f\n", i, ac);
      if (!decayed)
        ac_integral += ac;
    }
  }
  if (log_scale)
    corr_time = log_corr_time;
  else
    corr_time = (int)ceil(ac_integral);
  return (corr_time);
}
```