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

```asm
<digitize_one>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  movsd  %xmm0,0x8(%rsp)
  movsd  %xmm1,0x10(%rsp)
  mov    %rdi,%r12
  imul   %rdi,%r12
  test   %rsi,%rsi
  je     L82
  mov    %rdi,%rbp
  mov    %rdx,%rbx
  lea    D55(%rip),%rsi
  mov    %rdx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L410
  movsd  0x10(%rsp),%xmm2
  movapd %xmm2,%xmm1
  mulsd  %xmm2,%xmm1
  movsd  0x8(%rsp),%xmm3
  movapd %xmm3,%xmm0
  mulsd  %xmm3,%xmm0
  addsd  %xmm1,%xmm0
  comisd D231(%rip),%xmm0
  jbe    L519
  movsd  D231(%rip),%xmm0
L233:
  sqrtsd %xmm0,%xmm0
L481:
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L435
  sqrtsd %xmm0,%xmm0
L298:
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L492
  sqrtsd %xmm0,%xmm0
L338:
  pxor   %xmm1,%xmm1
  cvtsi2sd %rbp,%xmm1
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%rax
  lea    -0x1(%rbp),%rdx
  test   %rax,%rax
  mov    $0x0,%ebx
  cmovns %rax,%rbx
  cmp    %rax,%rbp
  cmovle %rdx,%rbx
  lea    0x1(%rbx,%rbx,1),%rbp
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm0
  call   <atan2@plt>
  addsd  D1(%rip),%xmm0
  divsd  D174(%rip),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %rbp,%xmm1
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%rcx
  test   %rcx,%rcx
  mov    $0x0,%edx
  cmovns %rcx,%rdx
  lea    (%rbx,%rbx,1),%rax
  cmp    %rcx,%rbp
  cmovg  %rdx,%rax
  imul   %rbx,%rbx
  add    %rbx,%rax
L128:
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L82:
  mulsd  %xmm0,%xmm0
  mulsd  %xmm1,%xmm1
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L399
  sqrtsd %xmm0,%xmm0
L400:
  addsd  D231(%rip),%xmm0
  mulsd  D241(%rip),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %r12,%xmm1
  mulsd  %xmm1,%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rdx
  lea    -0x1(%r12),%rcx
  test   %rdx,%rdx
  mov    $0x0,%eax
  cmovns %rdx,%rax
  cmp    %rdx,%r12
  cmovle %rcx,%rax
  jmp    L128
L399:
  call   <sqrt@plt>
  jmp    L400
L519:
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  jbe    L233
  call   <sqrt@plt>
  jmp    L481
L435:
  call   <sqrt@plt>
  jmp    L298
L492:
  call   <sqrt@plt>
  jmp    L338
L410:
  lea    D160(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L332
  lea    D198(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L311
  lea    D111(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L326
  lea    D243(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L243
  lea    D8(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  mov    %eax,%edx
  mov    $0x0,%eax
  test   %edx,%edx
  jne    L128
  pxor   %xmm7,%xmm7
  cvtsi2sd %r12,%xmm7
  movsd  %xmm7,0x18(%rsp)
  pxor   %xmm0,%xmm0
  ucomisd %xmm7,%xmm0
  ja     L245
  sqrtsd %xmm7,%xmm7
  movapd %xmm7,%xmm0
  cvttsd2si %xmm7,%rbp
L348:
  cvttsd2si %xmm0,%rbx
  movsd  0x10(%rsp),%xmm4
  movapd %xmm4,%xmm1
  mulsd  %xmm4,%xmm1
  movsd  0x8(%rsp),%xmm7
  movapd %xmm7,%xmm0
  mulsd  %xmm7,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L44
L287:
  movsd  D176(%rip),%xmm0
  addsd  0x10(%rsp),%xmm0
  mulsd  D227(%rip),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %rbp,%xmm1
  mulsd  %xmm1,%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%r12
  movsd  D176(%rip),%xmm0
  addsd  0x8(%rsp),%xmm0
  mulsd  D227(%rip),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %rbx,%xmm1
  mulsd  %xmm1,%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rcx
  lea    -0x1(%rbp),%rdx
  test   %r12,%r12
  mov    $0x0,%eax
  cmovns %r12,%rax
  cmp    %rbp,%r12
  cmovge %rdx,%rax
  lea    -0x1(%rbx),%rsi
  test   %rcx,%rcx
  mov    $0x0,%edx
  cmovns %rcx,%rdx
  cmp    %rcx,%rbx
  cmovle %rsi,%rdx
  imul   %rbx,%rax
  add    %rdx,%rax
  jmp    L128
L332:
  pxor   %xmm0,%xmm0
  cvtsi2sd %r12,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L98
  sqrtsd %xmm0,%xmm0
L500:
  cvttsd2si %xmm0,%rbp
  movsd  0x10(%rsp),%xmm4
  movapd %xmm4,%xmm1
  mulsd  %xmm4,%xmm1
  movsd  0x8(%rsp),%xmm5
  movapd %xmm5,%xmm0
  mulsd  %xmm5,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L328
  sqrtsd %xmm0,%xmm0
L413:
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L370
  sqrtsd %xmm0,%xmm0
L121:
  pxor   %xmm1,%xmm1
  cvtsi2sd %rbp,%xmm1
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%rax
  lea    -0x1(%rbp),%rdx
  test   %rax,%rax
  mov    $0x0,%ebx
  cmovns %rax,%rbx
  cmp    %rax,%rbp
  cmovle %rdx,%rbx
  lea    (%rbx,%rbx,1),%rbp
  lea    0x1(%rbp),%r12
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm0
  call   <atan2@plt>
  pxor   %xmm1,%xmm1
  comisd %xmm0,%xmm1
  ja     L309
L60:
  pxor   %xmm1,%xmm1
  cvtsi2sd %r12,%xmm1
  divsd  D174(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%rdx
  test   %rdx,%rdx
  mov    $0x0,%eax
  cmovns %rdx,%rax
  cmp    %rdx,%r12
  cmovg  %rax,%rbp
  imul   %rbx,%rbx
  lea    (%rbx,%rbp,1),%rax
  jmp    L128
L98:
  call   <sqrt@plt>
  jmp    L500
L328:
  call   <sqrt@plt>
  jmp    L413
L370:
  call   <sqrt@plt>
  jmp    L121
L309:
  addsd  D174(%rip),%xmm0
  jmp    L60
L311:
  pxor   %xmm0,%xmm0
  cvtsi2sd %r12,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L513
  sqrtsd %xmm0,%xmm0
L38:
  cvttsd2si %xmm0,%rbp
  movsd  0x10(%rsp),%xmm6
  movapd %xmm6,%xmm1
  mulsd  %xmm6,%xmm1
  movsd  0x8(%rsp),%xmm7
  movapd %xmm7,%xmm0
  mulsd  %xmm7,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L55
  sqrtsd %xmm0,%xmm0
L244:
  pxor   %xmm6,%xmm6
  cvtsi2sd %rbp,%xmm6
  movsd  %xmm6,0x18(%rsp)
  mulsd  %xmm6,%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rax
  lea    -0x1(%rbp),%rdx
  test   %rax,%rax
  mov    $0x0,%ebx
  cmovns %rax,%rbx
  cmp    %rax,%rbp
  cmovle %rdx,%rbx
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm0
  call   <atan2@plt>
  pxor   %xmm1,%xmm1
  comisd %xmm0,%xmm1
  ja     L93
L64:
  divsd  D174(%rip),%xmm0
  mulsd  0x18(%rsp),%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rdx
  lea    -0x1(%rbp),%rcx
  test   %rdx,%rdx
  mov    $0x0,%eax
  cmovns %rdx,%rax
  cmp    %rdx,%rbp
  cmovle %rcx,%rax
  imul   %rbp,%rbx
  add    %rbx,%rax
  jmp    L128
L513:
  call   <sqrt@plt>
  jmp    L38
L55:
  call   <sqrt@plt>
  jmp    L244
L93:
  addsd  D174(%rip),%xmm0
  jmp    L64
L326:
  pxor   %xmm0,%xmm0
  cvtsi2sd %r12,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L480
  sqrtsd %xmm0,%xmm0
L305:
  cvttsd2si %xmm0,%rbx
  movsd  0x10(%rsp),%xmm7
  movapd %xmm7,%xmm1
  mulsd  %xmm7,%xmm1
  movsd  0x8(%rsp),%xmm4
  movapd %xmm4,%xmm0
  mulsd  %xmm4,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L132
  sqrtsd %xmm0,%xmm0
  movsd  %xmm0,0x18(%rsp)
L100:
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm0
  call   <atan2@plt>
  pxor   %xmm1,%xmm1
  comisd %xmm0,%xmm1
  ja     L341
L387:
  pxor   %xmm5,%xmm5
  cvtsi2sd %rbx,%xmm5
  divsd  D174(%rip),%xmm0
  movsd  %xmm5,0x8(%rsp)
  mulsd  %xmm5,%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rax
  lea    -0x1(%rbx),%rdx
  test   %rax,%rax
  mov    $0x0,%ebp
  cmovns %rax,%rbp
  cmp    %rax,%rbx
  cmovle %rdx,%rbp
  test   $0x1,%bpl
  je     L180
  movsd  0x8(%rsp),%xmm0
  mulsd  0x18(%rsp),%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rdx
L13:
  lea    -0x1(%rbx),%rcx
  test   %rdx,%rdx
  mov    $0x0,%eax
  cmovns %rdx,%rax
  cmp    %rbx,%rdx
  cmovge %rcx,%rax
  imul   %rbx,%rax
  add    %rbp,%rax
  jmp    L128
L480:
  call   <sqrt@plt>
  jmp    L305
L132:
  call   <sqrt@plt>
  movsd  %xmm0,0x18(%rsp)
  jmp    L100
L341:
  addsd  D174(%rip),%xmm0
  jmp    L387
L180:
  movsd  0x8(%rsp),%xmm0
  mulsd  0x18(%rsp),%xmm0
  addsd  D241(%rip),%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rdx
  jmp    L13
L243:
  pxor   %xmm0,%xmm0
  cvtsi2sd %r12,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L172
  sqrtsd %xmm0,%xmm0
L113:
  cvttsd2si %xmm0,%rbx
  movsd  0x10(%rsp),%xmm6
  movapd %xmm6,%xmm1
  mulsd  %xmm6,%xmm1
  movsd  0x8(%rsp),%xmm5
  movapd %xmm5,%xmm0
  mulsd  %xmm5,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L34
  sqrtsd %xmm0,%xmm0
  movsd  %xmm0,0x18(%rsp)
L505:
  movsd  0x8(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm0
  call   <atan2@plt>
  pxor   %xmm1,%xmm1
  comisd %xmm0,%xmm1
  ja     L175
L408:
  pxor   %xmm1,%xmm1
  cvtsi2sd %rbx,%xmm1
  divsd  D174(%rip),%xmm0
  movsd  %xmm1,0x8(%rsp)
  mulsd  %xmm1,%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rax
  lea    -0x1(%rbx),%rdx
  test   %rax,%rax
  mov    $0x0,%ebp
  cmovns %rax,%rbp
  cmp    %rax,%rbx
  cmovle %rdx,%rbp
  pxor   %xmm0,%xmm0
  cvtsi2sd %rbp,%xmm0
  movsd  0x8(%rsp),%xmm1
  divsd  %xmm1,%xmm0
  mulsd  0x18(%rsp),%xmm1
  addsd  %xmm1,%xmm0
  call   <floor@plt>
  cvttsd2si %xmm0,%rdx
  lea    -0x1(%rbx),%rcx
  test   %rdx,%rdx
  mov    $0x0,%eax
  cmovns %rdx,%rax
  cmp    %rdx,%rbx
  cmovle %rcx,%rax
  imul   %rbx,%rax
  add    %rbp,%rax
  jmp    L128
L172:
  call   <sqrt@plt>
  jmp    L113
L34:
  call   <sqrt@plt>
  movsd  %xmm0,0x18(%rsp)
  jmp    L505
L175:
  addsd  D174(%rip),%xmm0
  jmp    L408
L245:
  movsd  0x18(%rsp),%xmm0
  call   <sqrt@plt>
  cvttsd2si %xmm0,%rbp
  movsd  0x18(%rsp),%xmm0
  call   <sqrt@plt>
  jmp    L348
L44:
  call   <sqrt@plt>
  jmp    L287
```

tool_calls: name: read_data
arguments: data_tag: D55
type: string
name: read_data
arguments: data_tag: D231
type: f64[2]
name: read_data
arguments: data_tag: D1
type: f64
name: read_data
arguments: data_tag: D174
type: byte[8]
name: read_data
arguments: data_tag: D241
type: f64
name: read_data
arguments: data_tag: D160
type: string
name: read_data
arguments: data_tag: D198
type: string
name: read_data
arguments: data_tag: D111
type: string
name: read_data
arguments: data_tag: D243
type: string
name: read_data
arguments: data_tag: D8
type: string
name: read_data
arguments: data_tag: D176
type: f64
name: read_data
arguments: data_tag: D227
type: f64

tool: D55: old

tool: {"D231": [1.0,0.5]}

tool: D1: 3.141592653589793

tool: {"D174": [0x18,0x2d,0x44,0x54,0xfb,0x21,0x19,0x40]}

tool: D241: 0.5

tool: D160: maze

tool: D198: dart

tool: D111: stagger

tool: D243: spiral

tool: D8: chess

tool: D176: 0.125

tool: D227: 4

assistant: ```c
long digitize_one(double c, double s, long nbin1, long idx, char *partition) {
  long is, ic, ir, ncol, nrow, nannuli, nsec;
  long one, nbin, nbin2, ibin1, ibin2;
  double angle, modulus, scaled, fs, fc, offset;
  nbin = nbin1 * nbin1;
  one = 0;
  if (idx == 0) {
    modulus = (c * c + s * s);
    modulus = sqrt(modulus);
    scaled = ((modulus + 1.0) / 2.0) * nbin;
    one = floor(scaled);
    if (one >= nbin)
      one = nbin - 1;
    else if (one < 0)
      one = 0;
  } else {
    if (strcmp(partition, "old") == 0) {
      modulus = (c * c + s * s);
      if (modulus < 0.0)
        modulus = 0.0;
      else if (modulus > 1.0)
        modulus = 1.0;
      modulus = sqrt(modulus);
      modulus = sqrt(modulus);
      modulus = sqrt(modulus);
      ibin1 = modulus * nbin1;
      if (ibin1 >= nbin1)
        ibin1 = nbin1 - 1;
      else if (ibin1 < 0)
        ibin1 = 0;
      nbin2 = 2 * ibin1 + 1;
      angle = 3.14159265358979323846 + atan2(s, c);
      ibin2 = nbin2 * (angle / (2 * 3.14159265358979323846));
      if (ibin2 >= nbin2)
        ibin2 = nbin2 - 1;
      else if (ibin2 < 0)
        ibin2 = 0;
      one = ibin1 * ibin1 + ibin2;
    } else if (strcmp(partition, "maze") == 0) {
      nannuli = sqrt((double)nbin);
      modulus = (c * c + s * s);
      modulus = sqrt(modulus);
      modulus = sqrt(modulus);
      ir = (modulus * nannuli);
      if (ir >= nannuli)
        ir = nannuli - 1;
      else if (ir < 0)
        ir = 0;
      nsec = 2 * ir + 1;
      angle = atan2(s, c);
      if (angle < 0.0)
        angle += 2.0 * 3.14159265358979323846;
      is = nsec * (angle / (2.0 * 3.14159265358979323846));
      if (is >= nsec)
        is = nsec - 1;
      else if (is < 0)
        is = 0;
      one = ir * ir + is;
    } else if (strcmp(partition, "dart") == 0) {
      nannuli = (long)sqrt((double)nbin);
      nsec = nannuli;
      modulus = (c * c + s * s);
      modulus = sqrt(modulus);
      ir = (long)floor((modulus * nannuli));
      if (ir >= nannuli)
        ir = nannuli - 1;
      else if (ir < 0)
        ir = 0;
      angle = atan2(s, c);
      if (angle < 0.0)
        angle += 2.0 * 3.14159265358979323846;
      is = (long)floor((double)nsec * (angle / (2.0 * 3.14159265358979323846)));
      if (is >= nsec)
        is = nsec - 1;
      else if (is < 0)
        is = 0;
      one = ir * nsec + is;
    } else if (strcmp(partition, "stagger") == 0) {
      nannuli = (long)sqrt((double)nbin);
      nsec = nannuli;
      modulus = (c * c + s * s);
      modulus = sqrt(modulus);
      angle = atan2(s, c);
      if (angle < 0.0)
        angle += 2.0 * 3.14159265358979323846;
      is = (long)floor((double)nsec * (angle / (2.0 * 3.14159265358979323846)));
      if (is >= nsec)
        is = nsec - 1;
      else if (is < 0)
        is = 0;
      if (is % 2)
        ir = (long)floor(modulus * nannuli);
      else
        ir = (long)floor(modulus * nannuli + 0.5);
      if (ir >= nannuli)
        ir = nannuli - 1;
      else if (ir < 0)
        ir = 0;
      one = ir * nsec + is;
    } else if (strcmp(partition, "spiral") == 0) {
      nannuli = (long)sqrt((double)nbin);
      nsec = nannuli;
      modulus = (c * c + s * s);
      modulus = sqrt(modulus);
      angle = atan2(s, c);
      if (angle < 0.0)
        angle += 2.0 * 3.14159265358979323846;
      is = (long)floor((double)nsec * (angle / (2.0 * 3.14159265358979323846)));
      if (is >= nsec)
        is = nsec - 1;
      else if (is < 0)
        is = 0;
      offset = ((double)is) / ((double)nsec);
      ir = (long)floor(modulus * nannuli + offset);
      if (ir >= nannuli)
        ir = nannuli - 1;
      else if (ir < 0)
        ir = 0;
      one = ir * nsec + is;
    } else if (strcmp(partition, "chess") == 0) {
      nrow = (long)floor(sqrt((double)nbin));
      ncol = (long)floor(sqrt((double)nbin));
      modulus = (c * c + s * s);
      modulus = sqrt(modulus);
      fs = 4.0 * (s + 0.125) * nrow;
      is = (long)floor(fs);
      fc = 4.0 * (c + 0.125) * ncol;
      ic = (long)floor(fc);
      if (is >= nrow)
        is = nrow - 1;
      else if (is < 0)
        is = 0;
      if (ic >= ncol)
        ic = ncol - 1;
      else if (ic < 0)
        ic = 0;
      one = is * ncol + ic;
    } else
      return (0);
  }
  return (one);
}
```