user: Converte this assembly snippet into its equivalent C code:

```asm
<ti_macd>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  push   %r13
  mov    %edi,%r13d
  mov    %rsi,%rdi
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x28,%rsp
  cvttsd2si (%rdx),%esi
  cvttsd2si 0x8(%rdx),%ecx
  cvttsd2si 0x10(%rdx),%r8d
  test   %esi,%esi
  setle  %al
  cmp    $0x1,%ecx
  setle  %dl
  or     %edx,%eax
  cmp    %ecx,%esi
  setg   %dl
  or     %dl,%al
  jne    L164
  test   %r8d,%r8d
  jg     L74
L164:
  mov    $0x1,%eax
L110:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L74:
  mov    (%rdi),%rdx
  mov    %rbp,%rdi
  mov    (%r15),%r14
  mov    %r8d,0x1c(%rsp)
  mov    0x8(%r15),%r12
  mov    0x10(%r15),%rbx
  mov    %ecx,0x18(%rsp)
  mov    %esi,0x14(%rsp)
  mov    %rdx,0x8(%rsp)
  call   <ti_macd_start@plt>
  mov    %eax,%r9d
  xor    %eax,%eax
  cmp    %r13d,%r9d
  jge    L110
  mov    0x1c(%rsp),%r8d
  pxor   %xmm0,%xmm0
  mov    0x14(%rsp),%esi
  movsd  D20(%rip),%xmm1
  movsd  D33(%rip),%xmm4
  cvtsi2sd %r8d,%xmm0
  cmp    $0xc,%esi
  mov    0x8(%rsp),%rdx
  mov    0x18(%rsp),%ecx
  movapd %xmm4,%xmm6
  addsd  %xmm1,%xmm0
  divsd  %xmm0,%xmm6
  jne    L98
  cmp    $0x1a,%ecx
  jne    L98
  movsd  (%rdx),%xmm2
  cmp    $0x1,%r13d
  jle    L102
  movsd  D26(%rip),%xmm4
  movsd  D34(%rip),%xmm5
  mov    $0x19,%ecx
L73:
  cmp    %ecx,%r13d
  mov    %ecx,%edi
  lea    0x8(%rdx),%rsi
  mov    $0x1,%eax
  cmovle %r13d,%edi
  movapd %xmm2,%xmm3
  pxor   %xmm0,%xmm0
  nopl   0x0(%rax,%rax,1)
L63:
  movsd  (%rsi),%xmm1
  movapd %xmm1,%xmm7
  subsd  %xmm3,%xmm1
  subsd  %xmm2,%xmm7
  mulsd  %xmm4,%xmm1
  mulsd  %xmm5,%xmm7
  addsd  %xmm1,%xmm3
  addsd  %xmm7,%xmm2
  movapd %xmm2,%xmm1
  subsd  %xmm3,%xmm1
  cmp    %ecx,%eax
  je     L103
  add    $0x1,%eax
  add    $0x8,%rsi
  cmp    %eax,%edi
  jg     L63
L127:
  cmp    %eax,%r13d
  jle    L102
L9:
  cltq
  jmp    L100
  nopl   0x0(%rax,%rax,1)
L181:
  movapd %xmm1,%xmm7
  subsd  %xmm0,%xmm7
  mulsd  %xmm6,%xmm7
  addsd  %xmm7,%xmm0
L7:
  add    $0x8,%r12
  add    $0x8,%rbx
  add    $0x1,%rax
  add    $0x8,%r14
  movsd  %xmm1,-0x8(%r14)
  subsd  %xmm0,%xmm1
  movsd  %xmm0,-0x8(%r12)
  movsd  %xmm1,-0x8(%rbx)
  cmp    %eax,%r13d
  jle    L102
L100:
  movsd  (%rdx,%rax,8),%xmm1
  movapd %xmm1,%xmm7
  subsd  %xmm3,%xmm1
  subsd  %xmm2,%xmm7
  mulsd  %xmm4,%xmm1
  mulsd  %xmm5,%xmm7
  addsd  %xmm1,%xmm3
  addsd  %xmm7,%xmm2
  movapd %xmm2,%xmm1
  subsd  %xmm3,%xmm1
  cmp    %eax,%ecx
  jne    L181
  movapd %xmm1,%xmm0
  subsd  %xmm1,%xmm0
  mulsd  %xmm6,%xmm0
  addsd  %xmm1,%xmm0
  jmp    L7
  nopw   0x0(%rax,%rax,1)
L102:
  mov    %rbp,%rdi
  sub    (%r15),%r14
  call   <ti_macd_start@plt>
  sar    $0x3,%r14
  xor    %edi,%edi
  mov    %eax,%r8d
  mov    %r13d,%eax
  sub    %r8d,%eax
  cltq
  cmp    %r14,%rax
  sete   %dil
  call   <assert@plt>
  mov    %rbp,%rdi
  sub    0x8(%r15),%r12
  call   <ti_macd_start@plt>
  sar    $0x3,%r12
  xor    %edi,%edi
  mov    %eax,%r8d
  mov    %r13d,%eax
  sub    %r8d,%eax
  cltq
  cmp    %r12,%rax
  sete   %dil
  call   <assert@plt>
  mov    %rbp,%rdi
  sub    0x10(%r15),%rbx
  call   <ti_macd_start@plt>
  sar    $0x3,%rbx
  xor    %edi,%edi
  sub    %eax,%r13d
  movslq %r13d,%r13
  cmp    %rbx,%r13
  sete   %dil
  call   <assert@plt>
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L103:
  movapd %xmm1,%xmm0
  movsd  %xmm1,(%r14)
  lea    0x8(%r14),%r8
  add    $0x1,%eax
  subsd  %xmm1,%xmm0
  lea    0x8(%r12),%r9
  add    $0x8,%rsi
  mov    %r8,%r14
  lea    0x8(%rbx),%r10
  mulsd  %xmm6,%xmm0
  addsd  %xmm1,%xmm0
  subsd  %xmm0,%xmm1
  movsd  %xmm0,(%r12)
  mov    %r9,%r12
  movsd  %xmm1,(%rbx)
  mov    %r10,%rbx
  cmp    %eax,%edi
  jg     L63
  jmp    L127
  nopl   (%rax)
L98:
  pxor   %xmm0,%xmm0
  movapd %xmm4,%xmm5
  movsd  (%rdx),%xmm2
  cvtsi2sd %esi,%xmm0
  addsd  %xmm1,%xmm0
  divsd  %xmm0,%xmm5
  pxor   %xmm0,%xmm0
  cvtsi2sd %ecx,%xmm0
  addsd  %xmm1,%xmm0
  divsd  %xmm0,%xmm4
  cmp    $0x1,%r13d
  jle    L102
  lea    -0x1(%rcx),%eax
  cmp    $0x2,%ecx
  je     L94
  mov    %eax,%ecx
  jmp    L73
  nopl   0x0(%rax)
L94:
  mov    $0x1,%ecx
  movapd %xmm2,%xmm3
  pxor   %xmm0,%xmm0
  jmp    L9
```

tool_calls: name: retrieve_data
arguments: label: D20
datatype: f64
name: retrieve_data
arguments: label: D33
datatype: f64
name: retrieve_data
arguments: label: D26
datatype: f64
name: retrieve_data
arguments: label: D34
datatype: f64

tool: D20: 1

tool: D33: 2

tool: D26: 0.075

tool: D34: 0.15

assistant: ```c
int ti_macd(int size, double const *const *inputs, double const *options, double *const *outputs) {
  const double *input = inputs[0];
  double *macd = outputs[0];
  double *signal = outputs[1];
  double *hist = outputs[2];
  const int short_period = (int)options[0];
  const int long_period = (int)options[1];
  const int signal_period = (int)options[2];
  if (short_period < 1)
    return 1;
  if (long_period < 2)
    return 1;
  if (long_period < short_period)
    return 1;
  if (signal_period < 1)
    return 1;
  if (size <= ti_macd_start(options))
    return 0;
  double short_per = 2 / ((double)short_period + 1);
  double long_per = 2 / ((double)long_period + 1);
  double signal_per = 2 / ((double)signal_period + 1);
  if (short_period == 12 && long_period == 26) {
    short_per = 0.15;
    long_per = 0.075;
  }
  double short_ema = input[0];
  double long_ema = input[0];
  double signal_ema = 0;
  int i;
  for (i = 1; i < size; ++i) {
    short_ema = (input[i] - short_ema) * short_per + short_ema;
    long_ema = (input[i] - long_ema) * long_per + long_ema;
    const double out = short_ema - long_ema;
    if (i == long_period - 1) {
      signal_ema = out;
    }
    if (i >= long_period - 1) {
      signal_ema = (out - signal_ema) * signal_per + signal_ema;
      *macd++ = out;
      *signal++ = signal_ema;
      *hist++ = out - signal_ema;
    }
  }
  assert(macd - outputs[0] == size - ti_macd_start(options));
  assert(signal - outputs[1] == size - ti_macd_start(options));
  assert(hist - outputs[2] == size - ti_macd_start(options));
  return 0;
}
```