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

```asm
<sphx2s>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  movslq %ecx,%r13
  push   %r12
  mov    %r9,%r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %esi,%edi
  push   %rbx
  movslq %r8d,%rbx
  sub    $0xc8,%rsp
  mov    0x108(%rsp),%rax
  mov    %edx,0x6c(%rsp)
  mov    0x100(%rsp),%r15
  mov    %rax,0x58(%rsp)
  mov    0x110(%rsp),%rax
  mov    %rax,0x60(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xb8(%rsp)
  xor    %eax,%eax
  mov    %esi,0x24(%rsp)
  mov    %edx,%esi
  test   %edx,%edx
  jg     L171
  mov    %edi,0x6c(%rsp)
  mov    $0x1,%esi
  movl   $0x1,0x24(%rsp)
L171:
  pxor   %xmm5,%xmm5
  ucomisd 0x20(%rbp),%xmm5
  jp     L161
  je     L54
L161:
  mov    %edi,%eax
  imul   %ebx,%eax
  test   %edi,%edi
  jle    L609
  cltq
  movslq %r13d,%r11
  movslq %ebx,%r10
  mov    0x58(%rsp),%r9
  lea    0x0(,%rax,8),%rcx
  shl    $0x3,%r11
  shl    $0x3,%r10
  xor    %r8d,%r8d
  nopl   0x0(%rax)
L365:
  movsd  (%r12),%xmm0
  subsd  0x10(%rbp),%xmm0
  mov    %r9,%rdx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L364:
  add    $0x1,%eax
  movsd  %xmm0,(%rdx)
  add    %rcx,%rdx
  cmp    %eax,%esi
  jne    L364
  add    $0x1,%r8d
  add    %r11,%r12
  add    %r10,%r9
  cmp    %r8d,%edi
  jne    L365
L609:
  mov    0x6c(%rsp),%edx
  test   %edx,%edx
  jle    L136
  lea    0x0(,%r13,8),%rax
  lea    0x0(,%rbx,8),%r14
  mov    %r15,0x38(%rsp)
  mov    %rax,0x70(%rsp)
  mov    0x24(%rsp),%eax
  movl   $0x0,0x68(%rsp)
  sub    $0x1,%eax
  add    $0x1,%rax
  imul   %r14,%rax
  mov    %rax,0x88(%rsp)
  lea    0xa0(%rsp),%rax
  mov    %rax,0x78(%rsp)
  lea    0xb0(%rsp),%rax
  mov    %rax,0x80(%rsp)
  nop
L304:
  mov    0x38(%rsp),%rax
  mov    0x78(%rsp),%rsi
  mov    0x80(%rsp),%rdi
  movsd  (%rax),%xmm0
  mov    $0x1,%eax
  call   <sincosd@plt>
  movsd  0x18(%rbp),%xmm2
  mov    0x24(%rsp),%eax
  movsd  0xa0(%rsp),%xmm0
  movapd %xmm2,%xmm1
  mulsd  %xmm0,%xmm1
  movsd  %xmm1,0x18(%rsp)
  movsd  0x20(%rbp),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,0x48(%rsp)
  movsd  0xb0(%rsp),%xmm0
  mulsd  %xmm0,%xmm2
  mulsd  %xmm0,%xmm1
  movsd  %xmm2,0x50(%rsp)
  movsd  %xmm1,0x28(%rsp)
  test   %eax,%eax
  jle    L443
  movsd  D63(%rip),%xmm5
  lea    0xa8(%rsp),%rax
  mov    0x58(%rsp),%rbx
  xor    %r13d,%r13d
  mov    %rax,0x30(%rsp)
  mov    0x60(%rsp),%r12
  lea    0x98(%rsp),%r15
  movsd  %xmm5,0x10(%rsp)
  jmp    L503
  nopl   0x0(%rax)
L22:
  subsd  %xmm6,%xmm2
  movsd  %xmm2,(%rbx)
L116:
  mov    D93(%rip),%rax
  movapd %xmm5,%xmm0
  movsd  %xmm3,0x8(%rsp)
  movsd  %xmm4,(%rsp)
  movq   %rax,%xmm1
  call   <fmod@plt>
  pxor   %xmm6,%xmm6
  movsd  (%rsp),%xmm4
  movsd  0x8(%rsp),%xmm3
  movapd %xmm0,%xmm1
  movsd  0x98(%rsp),%xmm0
  ucomisd %xmm6,%xmm1
  jp     L206
  jne    L206
  mov    0x38(%rsp),%rax
  mulsd  0x8(%rbp),%xmm0
  addsd  (%rax),%xmm0
  comisd D9(%rip),%xmm0
  jbe    L389
  movsd  D93(%rip),%xmm5
  subsd  %xmm0,%xmm5
  movapd %xmm5,%xmm0
L389:
  movsd  D113(%rip),%xmm1
  movsd  %xmm0,(%r12)
  comisd %xmm0,%xmm1
  jbe    L328
  movsd  D223(%rip),%xmm1
  subsd  %xmm0,%xmm1
  movsd  %xmm1,(%r12)
L328:
  add    $0x1,%r13d
  add    %r14,%rbx
  add    %r14,%r12
  cmp    %r13d,0x24(%rsp)
  je     L480
L503:
  movsd  (%rbx),%xmm5
  mov    0x30(%rsp),%rdi
  mov    %r15,%rsi
  mov    $0x1,%eax
  movapd %xmm5,%xmm0
  movsd  %xmm5,(%rsp)
  call   <sincosd@plt>
  movsd  0x18(%rsp),%xmm0
  movsd  0x28(%rsp),%xmm4
  mulsd  0x98(%rsp),%xmm0
  movsd  D169(%rip),%xmm7
  movsd  (%rsp),%xmm5
  subsd  %xmm0,%xmm4
  movapd %xmm4,%xmm0
  andpd  D141(%rip),%xmm0
  comisd %xmm0,%xmm7
  ja     L27
L267:
  pxor   %xmm7,%xmm7
  mov    $0x1,%edx
  movsd  0xa0(%rsp),%xmm3
  xorpd  D233(%rip),%xmm3
  mulsd  0xa8(%rsp),%xmm3
  ucomisd %xmm7,%xmm4
  setp   %al
  cmovne %edx,%eax
  test   %al,%al
  jne    L581
  ucomisd %xmm7,%xmm3
  setp   %al
  cmovne %edx,%eax
  test   %al,%al
  jne    L581
  movsd  D9(%rip),%xmm6
  comisd 0x8(%rbp),%xmm6
  jbe    L237
  movsd  D93(%rip),%xmm2
  addsd  %xmm5,%xmm2
L134:
  addsd  0x0(%rbp),%xmm2
  pxor   %xmm7,%xmm7
  movsd  %xmm2,(%rbx)
  movsd  0x0(%rbp),%xmm0
  comisd %xmm7,%xmm0
  jb     L441
  comisd %xmm2,%xmm7
  jbe    L352
  addsd  0x10(%rsp),%xmm2
  movsd  %xmm2,(%rbx)
L352:
  movsd  0x10(%rsp),%xmm6
  comisd %xmm6,%xmm2
  ja     L22
  movsd  D237(%rip),%xmm6
  comisd %xmm2,%xmm6
  jbe    L116
  addsd  0x10(%rsp),%xmm2
  movsd  %xmm2,(%rbx)
  jmp    L116
  nopl   (%rax)
L206:
  mulsd  0x48(%rsp),%xmm0
  addsd  0x50(%rsp),%xmm0
  movapd %xmm0,%xmm1
  andpd  D141(%rip),%xmm1
  comisd D27(%rip),%xmm1
  jbe    L35
  mulsd  %xmm3,%xmm3
  pxor   %xmm1,%xmm1
  mulsd  %xmm4,%xmm4
  comisd %xmm0,%xmm1
  addsd  %xmm4,%xmm3
  ja     L73
  pxor   %xmm5,%xmm5
  ucomisd %xmm3,%xmm5
  ja     L350
  sqrtsd %xmm3,%xmm3
  movapd %xmm3,%xmm0
L497:
  mov    $0x1,%eax
  call   <acosd@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  andpd  D141(%rip),%xmm0
L110:
  movsd  %xmm0,(%r12)
  jmp    L328
  nopl   0x0(%rax,%rax,1)
L441:
  pxor   %xmm7,%xmm7
  comisd %xmm7,%xmm2
  jbe    L352
  subsd  0x10(%rsp),%xmm2
  movsd  %xmm2,(%rbx)
  jmp    L352
  nopl   (%rax)
L237:
  movapd %xmm5,%xmm2
  xorpd  D233(%rip),%xmm2
  jmp    L134
  nopl   0x0(%rax)
L581:
  movapd %xmm4,%xmm1
  movapd %xmm3,%xmm0
  mov    $0x2,%eax
  movsd  %xmm5,0x40(%rsp)
  movsd  %xmm4,0x8(%rsp)
  movsd  %xmm3,(%rsp)
  call   <atan2d@plt>
  pxor   %xmm2,%xmm2
  movsd  (%rsp),%xmm3
  movsd  0x8(%rsp),%xmm4
  cvtsi2sd %eax,%xmm2
  movsd  0x40(%rsp),%xmm5
  jmp    L134
  nopl   0x0(%rax)
L27:
  mov    0x38(%rsp),%rax
  movsd  (%rax),%xmm0
  addsd  0x8(%rbp),%xmm0
  mov    $0x1,%eax
  call   <cosd@plt>
  pxor   %xmm0,%xmm0
  movsd  (%rsp),%xmm5
  movsd  D147(%rip),%xmm4
  subsd  0x98(%rsp),%xmm4
  neg    %eax
  mulsd  0x18(%rsp),%xmm4
  cvtsi2sd %eax,%xmm0
  addsd  %xmm0,%xmm4
  jmp    L267
  nop
L35:
  mov    $0x1,%eax
  call   <asind@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  jmp    L110
  nopw   0x0(%rax,%rax,1)
L73:
  ucomisd %xmm3,%xmm1
  ja     L109
  sqrtsd %xmm3,%xmm3
  movapd %xmm3,%xmm0
L226:
  mov    $0x1,%eax
  call   <acosd@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  andpd  D141(%rip),%xmm0
  xorpd  D233(%rip),%xmm0
  jmp    L110
  nopl   0x0(%rax)
L480:
  mov    0x88(%rsp),%rcx
  add    %rcx,0x58(%rsp)
  add    %rcx,0x60(%rsp)
L443:
  addl   $0x1,0x68(%rsp)
  mov    0x70(%rsp),%rdi
  mov    0x68(%rsp),%eax
  add    %rdi,0x38(%rsp)
  cmp    %eax,0x6c(%rsp)
  jne    L304
L136:
  mov    0xb8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L639
  add    $0xc8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L54:
  ucomisd 0x8(%rbp),%xmm5
  movsd  0x0(%rbp),%xmm0
  movsd  0x10(%rbp),%xmm2
  movsd  D63(%rip),%xmm1
  jp     L541
  jne    L541
  addsd  D93(%rip),%xmm0
  movsd  %xmm1,(%rsp)
  subsd  %xmm2,%xmm0
  call   <fmod@plt>
  mov    0x6c(%rsp),%esi
  movsd  (%rsp),%xmm1
  test   %esi,%esi
  jle    L136
  movslq %ebx,%rdi
  mov    0x24(%rsp),%ebx
  movslq %r13d,%r8
  mov    0x60(%rsp),%r14
  shl    $0x3,%rdi
  shl    $0x3,%r8
  mov    0x58(%rsp),%r13
  xor    %r9d,%r9d
  lea    -0x1(%rbx),%r10d
  mov    %rdi,%r11
  movsd  D237(%rip),%xmm3
  add    $0x1,%r10
  imul   %r10,%r11
  imul   %r8,%r10
  nopw   0x0(%rax,%rax,1)
L301:
  test   %ebx,%ebx
  jle    L636
  mov    %r13,%rax
  mov    %r14,%rsi
  xor    %edx,%edx
  xor    %ecx,%ecx
  jmp    L444
  nopl   0x0(%rax)
L504:
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
L332:
  add    $0x1,%ecx
  add    %rdi,%rax
  add    %rdi,%rsi
  add    %r8,%rdx
  cmp    %ecx,%ebx
  je     L653
L444:
  movsd  (%r12,%rdx,1),%xmm2
  pxor   %xmm5,%xmm5
  addsd  %xmm0,%xmm2
  movsd  %xmm2,(%rax)
  movsd  (%r15,%rdx,1),%xmm2
  movsd  %xmm2,(%rsi)
  movsd  0x0(%rbp),%xmm2
  comisd %xmm5,%xmm2
  movsd  (%rax),%xmm2
  jb     L641
  comisd %xmm2,%xmm5
  jbe    L502
  addsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
L502:
  comisd %xmm1,%xmm2
  ja     L504
  comisd %xmm2,%xmm3
  jbe    L332
  addsd  %xmm1,%xmm2
  add    $0x1,%ecx
  add    %rdi,%rsi
  add    %r8,%rdx
  movsd  %xmm2,(%rax)
  add    %rdi,%rax
  cmp    %ecx,%ebx
  jne    L444
L653:
  add    %r11,%r13
  add    %r11,%r14
  add    %r10,%r12
  add    %r10,%r15
L636:
  add    $0x1,%r9d
  cmp    %r9d,0x6c(%rsp)
  jne    L301
  jmp    L136
L541:
  addsd  %xmm2,%xmm0
  movsd  %xmm1,(%rsp)
  call   <fmod@plt>
  mov    0x6c(%rsp),%ecx
  test   %ecx,%ecx
  jle    L136
  movslq %ebx,%rdi
  mov    0x24(%rsp),%ebx
  movslq %r13d,%r8
  mov    0x60(%rsp),%r14
  shl    $0x3,%rdi
  shl    $0x3,%r8
  mov    0x58(%rsp),%r13
  xor    %r9d,%r9d
  lea    -0x1(%rbx),%r10d
  mov    %rdi,%r11
  movq   D233(%rip),%xmm3
  movsd  D237(%rip),%xmm4
  add    $0x1,%r10
  movsd  (%rsp),%xmm1
  imul   %r10,%r11
  imul   %r8,%r10
  nopw   0x0(%rax,%rax,1)
L374:
  test   %ebx,%ebx
  jle    L433
  mov    %r13,%rax
  mov    %r14,%rsi
  xor    %edx,%edx
  xor    %ecx,%ecx
  jmp    L260
  nopl   0x0(%rax)
L156:
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
L659:
  add    $0x1,%ecx
  add    %rdi,%rax
  add    %rdi,%rsi
  add    %r8,%rdx
  cmp    %ecx,%ebx
  je     L254
L260:
  movapd %xmm0,%xmm2
  subsd  (%r12,%rdx,1),%xmm2
  pxor   %xmm6,%xmm6
  movsd  %xmm2,(%rax)
  movsd  (%r15,%rdx,1),%xmm2
  xorpd  %xmm3,%xmm2
  movsd  %xmm2,(%rsi)
  movsd  0x0(%rbp),%xmm2
  comisd %xmm6,%xmm2
  movsd  (%rax),%xmm2
  jb     L81
  comisd %xmm2,%xmm6
  jbe    L319
  addsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
L319:
  comisd %xmm1,%xmm2
  ja     L156
  comisd %xmm2,%xmm4
  jbe    L659
  addsd  %xmm1,%xmm2
  add    $0x1,%ecx
  add    %rdi,%rsi
  add    %r8,%rdx
  movsd  %xmm2,(%rax)
  add    %rdi,%rax
  cmp    %ecx,%ebx
  jne    L260
L254:
  add    %r11,%r13
  add    %r11,%r14
  add    %r10,%r12
  add    %r10,%r15
L433:
  add    $0x1,%r9d
  cmp    %r9d,0x6c(%rsp)
  jne    L374
  jmp    L136
  nopl   0x0(%rax)
L641:
  pxor   %xmm6,%xmm6
  comisd %xmm6,%xmm2
  jbe    L502
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
  jmp    L502
  nopl   0x0(%rax,%rax,1)
L81:
  pxor   %xmm7,%xmm7
  comisd %xmm7,%xmm2
  jbe    L319
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
  jmp    L319
L109:
  movapd %xmm3,%xmm0
  call   <sqrt@plt>
  jmp    L226
L350:
  movapd %xmm3,%xmm0
  call   <sqrt@plt>
  jmp    L497
L639:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_label: D63
type_guessed: f64
name: parse_data
arguments: data_label: D93
type_guessed: f64
name: parse_data
arguments: data_label: D9
type_guessed: f64[2]
name: parse_data
arguments: data_label: D113
type_guessed: f32[2]
name: parse_data
arguments: data_label: D223
type_guessed: f32[2]
name: parse_data
arguments: data_label: D169
type_guessed: byte[8]
name: parse_data
arguments: data_label: D141
type_guessed: qword[2]
name: parse_data
arguments: data_label: D233
type_guessed: f32[4]
name: parse_data
arguments: data_label: D237
type_guessed: f32[2]
name: parse_data
arguments: data_label: D27
type_guessed: f64[2]
name: parse_data
arguments: data_label: D147
type_guessed: f64

tool: D63: 360

tool: D93: 180

tool: {"D9": [90.0,-90.0]}

tool: {"D113": [0.0,-3.3515625]}

tool: {"D223": [0.0,-3.6015625]}

tool: {"D169": [0xf1,0x68,0xe3,0x88,0xb5,0xf8,0xe4,0x3e]}

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

tool: {"D233": [0.0,-0.0,0.0,0.0]}

tool: {"D237": [0.0,-3.8515625]}

tool: {"D27": [0.99,0.0]}

tool: D147: 1

assistant: ```c
int sphx2s(const double eul[5], int nphi, int ntheta, int spt, int sll, const double phi[], const double theta[], double lng[], double lat[]) {
  int mphi, mtheta, rowlen, rowoff;
  double cosphi, costhe, costhe3, costhe4, dlng, dphi, sinphi, sinthe, sinthe3, sinthe4, x, y, z;
  register int iphi, itheta;
  register const double *phip, *thetap;
  register double *latp, *lngp;
  if (ntheta > 0) {
    mphi = nphi;
    mtheta = ntheta;
  } else {
    mphi = 1;
    mtheta = 1;
    ntheta = nphi;
  }
  if (eul[4] == 0.0) {
    if (eul[1] == 0.0) {
      dlng = fmod(eul[0] + 180.0 - eul[2], 360.0);
      lngp = lng;
      latp = lat;
      phip = phi;
      thetap = theta;
      for (itheta = 0; itheta < ntheta; itheta++) {
        for (iphi = 0; iphi < mphi; iphi++) {
          *lngp = *phip + dlng;
          *latp = *thetap;
          if (eul[0] >= 0.0) {
            if (*lngp < 0.0)
              *lngp += 360.0;
          } else {
            if (*lngp > 0.0)
              *lngp -= 360.0;
          }
          if (*lngp > 360.0) {
            *lngp -= 360.0;
          } else if (*lngp < -360.0) {
            *lngp += 360.0;
          }
          lngp += sll;
          latp += sll;
          phip += spt;
          thetap += spt;
        }
      }
    } else {
      dlng = fmod(eul[0] + eul[2], 360.0);
      lngp = lng;
      latp = lat;
      phip = phi;
      thetap = theta;
      for (itheta = 0; itheta < ntheta; itheta++) {
        for (iphi = 0; iphi < mphi; iphi++) {
          *lngp = dlng - *phip;
          *latp = -(*thetap);
          if (eul[0] >= 0.0) {
            if (*lngp < 0.0)
              *lngp += 360.0;
          } else {
            if (*lngp > 0.0)
              *lngp -= 360.0;
          }
          if (*lngp > 360.0) {
            *lngp -= 360.0;
          } else if (*lngp < -360.0) {
            *lngp += 360.0;
          }
          lngp += sll;
          latp += sll;
          phip += spt;
          thetap += spt;
        }
      }
    }
    return 0;
  }
  phip = phi;
  rowoff = 0;
  rowlen = nphi * sll;
  for (iphi = 0; iphi < nphi; iphi++, rowoff += sll, phip += spt) {
    dphi = *phip - eul[2];
    lngp = lng + rowoff;
    for (itheta = 0; itheta < mtheta; itheta++) {
      *lngp = dphi;
      lngp += rowlen;
    }
  }
  thetap = theta;
  lngp = lng;
  latp = lat;
  for (itheta = 0; itheta < ntheta; itheta++, thetap += spt) {
    sincosd(*thetap, &sinthe, &costhe);
    costhe3 = costhe * eul[3];
    costhe4 = costhe * eul[4];
    sinthe3 = sinthe * eul[3];
    sinthe4 = sinthe * eul[4];
    for (iphi = 0; iphi < mphi; iphi++, lngp += sll, latp += sll) {
      dphi = *lngp;
      sincosd(dphi, &sinphi, &cosphi);
      x = sinthe4 - costhe3 * cosphi;
      if (fabs(x) < 1.0e-5) {
        x = -cosd(*thetap + eul[1]) + costhe3 * (1.0 - cosphi);
      }
      y = -costhe * sinphi;
      if (x != 0.0 || y != 0.0) {
        dlng = atan2d(y, x);
      } else {
        if (eul[1] < 90.0) {
          dlng = dphi + 180.0;
        } else {
          dlng = -dphi;
        }
      }
      *lngp = eul[0] + dlng;
      if (eul[0] >= 0.0) {
        if (*lngp < 0.0)
          *lngp += 360.0;
      } else {
        if (*lngp > 0.0)
          *lngp -= 360.0;
      }
      if (*lngp > 360.0) {
        *lngp -= 360.0;
      } else if (*lngp < -360.0) {
        *lngp += 360.0;
      }
      if (fmod(dphi, 180.0) == 0.0) {
        *latp = *thetap + cosphi * eul[1];
        if (*latp > 90.0)
          *latp = 180.0 - *latp;
        if (*latp < -90.0)
          *latp = -180.0 - *latp;
      } else {
        z = sinthe3 + costhe4 * cosphi;
        if (fabs(z) > 0.99) {
          *latp = ((z) < 0.0 ? -fabs(acosd(sqrt(x * x + y * y))) : fabs(acosd(sqrt(x * x + y * y))));
        } else {
          *latp = asind(z);
        }
      }
    }
  }
  return 0;
}
```