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

```asm
<ti_di>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdx,0x8(%rsp)
  cvttsd2si (%rdx),%r15d
  mov    $0x1,%eax
  test   %r15d,%r15d
  jle    L55
  mov    %edi,%r12d
  mov    %rdx,%rdi
  mov    %rcx,%r14
  mov    (%rsi),%rbx
  mov    0x8(%rsi),%rbp
  mov    0x10(%rsi),%r13
  mov    (%rcx),%rax
  mov    %rax,0x10(%rsp)
  mov    0x8(%rcx),%rax
  mov    %rax,0x18(%rsp)
  call   <ti_di_start@plt>
  mov    %eax,%edx
  mov    $0x0,%eax
  cmp    %r12d,%edx
  jge    L55
  pxor   %xmm0,%xmm0
  cvtsi2sd %r15d,%xmm0
  movapd %xmm0,%xmm5
  subsd  D10(%rip),%xmm5
  divsd  %xmm0,%xmm5
  cmp    $0x1,%r15d
  jle    L53
  lea    -0x1(%r15),%edx
  mov    $0x0,%eax
  pxor   %xmm2,%xmm2
  movapd %xmm2,%xmm3
  movapd %xmm2,%xmm1
  movq   D41(%rip),%xmm8
  movapd %xmm2,%xmm9
  movapd %xmm2,%xmm11
  movapd %xmm2,%xmm10
  jmp    L6
L130:
  pxor   %xmm0,%xmm0
L44:
  comisd %xmm4,%xmm10
  jbe    L48
  pxor   %xmm4,%xmm4
  jmp    L32
L48:
  movapd %xmm0,%xmm6
  cmpnltsd %xmm4,%xmm6
  andpd  %xmm6,%xmm0
  andnpd %xmm11,%xmm6
  orpd   %xmm6,%xmm0
L32:
  addsd  %xmm0,%xmm3
  addsd  %xmm4,%xmm2
  add    $0x1,%rax
  cmp    %rdx,%rax
  je     L29
L6:
  movsd  0x8(%rbp,%rax,8),%xmm6
  movsd  0x8(%rbx,%rax,8),%xmm0
  movsd  0x0(%r13,%rax,8),%xmm4
  movapd %xmm0,%xmm12
  subsd  %xmm4,%xmm12
  andpd  %xmm8,%xmm12
  movapd %xmm6,%xmm7
  subsd  %xmm4,%xmm7
  andpd  %xmm8,%xmm7
  movapd %xmm0,%xmm4
  subsd  %xmm6,%xmm4
  maxsd  %xmm4,%xmm12
  maxsd  %xmm12,%xmm7
  addsd  %xmm7,%xmm1
  subsd  (%rbx,%rax,8),%xmm0
  movsd  0x0(%rbp,%rax,8),%xmm4
  subsd  %xmm6,%xmm4
  comisd %xmm0,%xmm9
  ja     L130
  comisd %xmm4,%xmm0
  jbe    L44
  pxor   %xmm4,%xmm4
  jmp    L48
L53:
  pxor   %xmm2,%xmm2
  movapd %xmm2,%xmm3
  movapd %xmm2,%xmm1
L29:
  mov    0x10(%rsp),%rcx
  lea    0x8(%rcx),%rsi
  movsd  D31(%rip),%xmm0
  movapd %xmm3,%xmm4
  mulsd  %xmm0,%xmm4
  divsd  %xmm1,%xmm4
  movsd  %xmm4,(%rcx)
  mov    0x18(%rsp),%rdi
  lea    0x8(%rdi),%rax
  mov    %rax,0x10(%rsp)
  mulsd  %xmm2,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdi)
  cmp    %r12d,%r15d
  jge    L133
  movslq %r15d,%rax
  mov    %rax,%rdx
  neg    %rdx
  shl    $0x3,%rdx
  add    %rdx,%rcx
  add    %rdi,%rdx
  movq   D41(%rip),%xmm7
  pxor   %xmm8,%xmm8
  movapd %xmm8,%xmm10
  movapd %xmm8,%xmm9
  movsd  D31(%rip),%xmm6
  jmp    L153
L7:
  pxor   %xmm0,%xmm0
L103:
  comisd %xmm4,%xmm9
  jbe    L169
  pxor   %xmm4,%xmm4
  jmp    L152
L169:
  movapd %xmm0,%xmm11
  cmpnltsd %xmm4,%xmm11
  andpd  %xmm11,%xmm0
  andnpd %xmm10,%xmm11
  orpd   %xmm11,%xmm0
L152:
  mulsd  %xmm5,%xmm3
  addsd  %xmm0,%xmm3
  mulsd  %xmm5,%xmm2
  addsd  %xmm4,%xmm2
  movapd %xmm3,%xmm0
  mulsd  %xmm6,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%rcx,%rax,8)
  movapd %xmm2,%xmm0
  mulsd  %xmm6,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%r12d
  jle    L149
L153:
  movsd  0x0(%rbp,%rax,8),%xmm11
  movsd  (%rbx,%rax,8),%xmm0
  movsd  -0x8(%r13,%rax,8),%xmm4
  movapd %xmm0,%xmm13
  subsd  %xmm4,%xmm13
  andpd  %xmm7,%xmm13
  movapd %xmm11,%xmm12
  subsd  %xmm4,%xmm12
  andpd  %xmm7,%xmm12
  movapd %xmm0,%xmm4
  subsd  %xmm11,%xmm4
  maxsd  %xmm4,%xmm13
  maxsd  %xmm13,%xmm12
  mulsd  %xmm5,%xmm1
  addsd  %xmm12,%xmm1
  subsd  -0x8(%rbx,%rax,8),%xmm0
  movsd  -0x8(%rbp,%rax,8),%xmm4
  subsd  %xmm11,%xmm4
  comisd %xmm0,%xmm8
  ja     L7
  comisd %xmm4,%xmm0
  jbe    L103
  pxor   %xmm4,%xmm4
  jmp    L169
L149:
  lea    -0x1(%r12),%eax
  sub    %r15d,%eax
  lea    0x8(,%rax,8),%rax
  add    %rax,%rsi
  add    %rax,0x10(%rsp)
L133:
  sub    (%r14),%rsi
  sar    $0x3,%rsi
  mov    %rsi,%rbx
  mov    0x8(%rsp),%r15
  mov    %r15,%rdi
  call   <ti_di_start@plt>
  mov    %eax,%edx
  mov    %r12d,%eax
  sub    %edx,%eax
  cltq
  cmp    %rbx,%rax
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x10(%rsp),%rbx
  sub    0x8(%r14),%rbx
  sar    $0x3,%rbx
  mov    %r15,%rdi
  call   <ti_di_start@plt>
  sub    %eax,%r12d
  movslq %r12d,%r12
  cmp    %rbx,%r12
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    $0x0,%eax
L55:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D10
type: f32[2]
name: retrieve_data
arguments: data_tag: D41
type: qword
name: retrieve_data
arguments: data_tag: D31
type: f64

tool: {"D10": [0.0,1.875]}

tool: D41: 9223372036854775807

tool: D31: 100

assistant: ```c
int ti_di(int size, double const *const *inputs, double const *options, double *const *outputs) {
  const double *high = inputs[0];
  const double *low = inputs[1];
  const double *close = inputs[2];
  const int period = (int)options[0];
  double *plus_di = outputs[0];
  double *minus_di = outputs[1];
  if (period < 1)
    return 1;
  if (size <= ti_di_start(options))
    return 0;
  const double per = ((double)period - 1) / ((double)period);
  double atr = 0;
  double dmup = 0;
  double dmdown = 0;
  int i;
  for (i = 1; i < period; ++i) {
    double truerange;
    do {
      const double l = low[i];
      const double h = high[i];
      const double c = close[i - 1];
      const double ych = fabs(h - c);
      const double ycl = fabs(l - c);
      double v = h - l;
      if (ych > v)
        v = ych;
      if (ycl > v)
        v = ycl;
      truerange = v;
    } while (0);
    atr += truerange;
    double dp, dm;
    do {
      dp = high[i] - high[i - 1];
      dm = low[i - 1] - low[i];
      if (dp < 0)
        dp = 0;
      else if (dp > dm)
        dm = 0;
      if (dm < 0)
        dm = 0;
      else if (dm > dp)
        dp = 0;
    } while (0);
    dmup += dp;
    dmdown += dm;
  }
  *plus_di++ = 100.0 * dmup / atr;
  *minus_di++ = 100.0 * dmdown / atr;
  for (i = period; i < size; ++i) {
    double truerange;
    do {
      const double l = low[i];
      const double h = high[i];
      const double c = close[i - 1];
      const double ych = fabs(h - c);
      const double ycl = fabs(l - c);
      double v = h - l;
      if (ych > v)
        v = ych;
      if (ycl > v)
        v = ycl;
      truerange = v;
    } while (0);
    atr = atr * per + truerange;
    double dp, dm;
    do {
      dp = high[i] - high[i - 1];
      dm = low[i - 1] - low[i];
      if (dp < 0)
        dp = 0;
      else if (dp > dm)
        dm = 0;
      if (dm < 0)
        dm = 0;
      else if (dm > dp)
        dp = 0;
    } while (0);
    dmup = dmup * per + dp;
    dmdown = dmdown * per + dm;
    *plus_di++ = 100.0 * dmup / atr;
    *minus_di++ = 100.0 * dmdown / atr;
  }
  assert(plus_di - outputs[0] == size - ti_di_start(options));
  assert(minus_di - outputs[1] == size - ti_di_start(options));
  return 0;
}
```