user: 请将以下的汇编代码转换成C语言代码：

```asm
<sphx2s>:
  endbr64
  push   %r15
  mov    %esi,%r10d
  push   %r14
  push   %r13
  movslq %r8d,%r13
  push   %r12
  movslq %ecx,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %r9,%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,0x2c(%rsp)
  mov    %edx,%esi
  test   %edx,%edx
  jg     L431
  mov    %r10d,0x6c(%rsp)
  mov    $0x1,%esi
  movl   $0x1,0x2c(%rsp)
L431:
  pxor   %xmm3,%xmm3
  ucomisd 0x20(%rbp),%xmm3
  jp     L185
  je     L687
L185:
  mov    %r10d,%eax
  imul   %r13d,%eax
  test   %r10d,%r10d
  jle    L535
  cltq
  movslq %r12d,%r8
  movslq %r13d,%r11
  mov    0x58(%rsp),%r9
  lea    0x0(,%rax,8),%rcx
  shl    $0x3,%r8
  shl    $0x3,%r11
  xor    %edi,%edi
  nopl   (%rax)
L812:
  movsd  (%rbx),%xmm0
  subsd  0x10(%rbp),%xmm0
  mov    %r9,%rdx
  xor    %eax,%eax
  cs nopw 0x0(%rax,%rax,1)
L867:
  add    $0x1,%eax
  movsd  %xmm0,(%rdx)
  add    %rcx,%rdx
  cmp    %eax,%esi
  jne    L867
  add    $0x1,%edi
  add    %r8,%rbx
  add    %r11,%r9
  cmp    %edi,%r10d
  jne    L812
L535:
  mov    0x6c(%rsp),%edx
  test   %edx,%edx
  jle    L482
  lea    0x0(,%r12,8),%rax
  lea    0x0(,%r13,8),%r14
  mov    %r15,0x40(%rsp)
  mov    %rax,0x70(%rsp)
  mov    0x2c(%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)
  xchg   %ax,%ax
L10:
  mov    0x40(%rsp),%rax
  mov    0x78(%rsp),%rsi
  mov    0x80(%rsp),%rdi
  movsd  (%rax),%xmm0
  mov    $0x1,%eax
  call   <sincosd@plt>
  movsd  0x18(%rbp),%xmm2
  movsd  0x20(%rbp),%xmm1
  movsd  0xa0(%rsp),%xmm0
  mov    0x2c(%rsp),%eax
  movapd %xmm2,%xmm5
  mulsd  %xmm0,%xmm5
  mulsd  %xmm1,%xmm0
  movsd  %xmm5,0x20(%rsp)
  movsd  %xmm0,0x48(%rsp)
  movsd  0xb0(%rsp),%xmm0
  mulsd  %xmm0,%xmm2
  mulsd  %xmm0,%xmm1
  movsd  %xmm2,0x50(%rsp)
  movsd  %xmm1,0x30(%rsp)
  test   %eax,%eax
  jle    L405
  movsd  D24(%rip),%xmm3
  lea    0xa8(%rsp),%rax
  mov    0x58(%rsp),%rbx
  xor    %r13d,%r13d
  mov    %rax,0x38(%rsp)
  mov    0x60(%rsp),%r12
  lea    0x98(%rsp),%r15
  movsd  %xmm3,0x18(%rsp)
  jmp    L440
  nopl   0x0(%rax)
L740:
  subsd  %xmm7,%xmm3
  movsd  %xmm3,(%rbx)
L677:
  mov    D219(%rip),%rax
  movapd %xmm6,%xmm0
  movsd  %xmm2,(%rsp)
  movsd  %xmm4,0x10(%rsp)
  movq   %rax,%xmm1
  movsd  %xmm5,0x8(%rsp)
  call   <fmod@plt>
  pxor   %xmm6,%xmm6
  movsd  (%rsp),%xmm2
  movsd  0x8(%rsp),%xmm5
  ucomisd %xmm6,%xmm0
  movsd  0x10(%rsp),%xmm4
  jp     L183
  jne    L183
  mov    0x40(%rsp),%rax
  mulsd  0x8(%rbp),%xmm2
  addsd  (%rax),%xmm2
  comisd D127(%rip),%xmm2
  jbe    L883
  movsd  D219(%rip),%xmm4
  subsd  %xmm2,%xmm4
  movapd %xmm4,%xmm2
L883:
  movsd  D95(%rip),%xmm0
  movsd  %xmm2,(%r12)
  comisd %xmm2,%xmm0
  jbe    L904
  movsd  D192(%rip),%xmm0
  subsd  %xmm2,%xmm0
  movsd  %xmm0,(%r12)
L904:
  add    $0x1,%r13d
  add    %r14,%rbx
  add    %r14,%r12
  cmp    %r13d,0x2c(%rsp)
  je     L339
L440:
  movsd  (%rbx),%xmm6
  mov    0x38(%rsp),%rdi
  mov    %r15,%rsi
  mov    $0x1,%eax
  movapd %xmm6,%xmm0
  movsd  %xmm6,(%rsp)
  call   <sincosd@plt>
  movsd  0x20(%rsp),%xmm0
  movsd  0x30(%rsp),%xmm5
  movsd  0x98(%rsp),%xmm2
  movsd  D162(%rip),%xmm1
  movsd  (%rsp),%xmm6
  mulsd  %xmm2,%xmm0
  subsd  %xmm0,%xmm5
  movapd %xmm5,%xmm0
  andpd  D33(%rip),%xmm0
  comisd %xmm0,%xmm1
  ja     L120
L744:
  pxor   %xmm7,%xmm7
  mov    $0x1,%edx
  movsd  0xa0(%rsp),%xmm4
  xorpd  D120(%rip),%xmm4
  mulsd  0xa8(%rsp),%xmm4
  ucomisd %xmm7,%xmm5
  setp   %al
  cmovne %edx,%eax
  test   %al,%al
  jne    L121
  ucomisd %xmm7,%xmm4
  setp   %al
  cmovne %edx,%eax
  test   %al,%al
  jne    L121
  movsd  D127(%rip),%xmm1
  comisd 0x8(%rbp),%xmm1
  jbe    L424
  movsd  D219(%rip),%xmm3
  addsd  %xmm6,%xmm3
L193:
  addsd  0x0(%rbp),%xmm3
  pxor   %xmm1,%xmm1
  movsd  %xmm3,(%rbx)
  movsd  0x0(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jb     L296
  comisd %xmm3,%xmm1
  jbe    L780
  addsd  0x18(%rsp),%xmm3
  movsd  %xmm3,(%rbx)
L780:
  movsd  0x18(%rsp),%xmm7
  comisd %xmm7,%xmm3
  ja     L740
  movsd  D176(%rip),%xmm7
  comisd %xmm3,%xmm7
  jbe    L677
  addsd  0x18(%rsp),%xmm3
  movsd  %xmm3,(%rbx)
  jmp    L677
  nopl   0x0(%rax,%rax,1)
L183:
  mulsd  0x48(%rsp),%xmm2
  addsd  0x50(%rsp),%xmm2
  movapd %xmm2,%xmm0
  andpd  D33(%rip),%xmm0
  comisd D88(%rip),%xmm0
  jbe    L164
  mulsd  %xmm4,%xmm4
  movapd %xmm5,%xmm1
  mulsd  %xmm5,%xmm1
  pxor   %xmm5,%xmm5
  comisd %xmm2,%xmm5
  addsd  %xmm1,%xmm4
  ja     L320
  ucomisd %xmm4,%xmm5
  ja     L58
  sqrtsd %xmm4,%xmm4
  movapd %xmm4,%xmm0
L728:
  mov    $0x1,%eax
  call   <acosd@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  andpd  D33(%rip),%xmm0
L897:
  movsd  %xmm0,(%r12)
  jmp    L904
  nopl   0x0(%rax,%rax,1)
L296:
  comisd %xmm1,%xmm3
  jbe    L780
  subsd  0x18(%rsp),%xmm3
  movsd  %xmm3,(%rbx)
  jmp    L780
  nopl   0x0(%rax)
L424:
  movapd %xmm6,%xmm3
  xorpd  D120(%rip),%xmm3
  jmp    L193
  nopl   0x0(%rax)
L121:
  movapd %xmm5,%xmm1
  movapd %xmm4,%xmm0
  mov    $0x2,%eax
  movsd  %xmm6,0x10(%rsp)
  movsd  %xmm5,0x8(%rsp)
  movsd  %xmm4,(%rsp)
  call   <atan2d@plt>
  pxor   %xmm3,%xmm3
  movsd  (%rsp),%xmm4
  movsd  0x98(%rsp),%xmm2
  cvtsi2sd %eax,%xmm3
  movsd  0x8(%rsp),%xmm5
  movsd  0x10(%rsp),%xmm6
  jmp    L193
  nopw   0x0(%rax,%rax,1)
L120:
  mov    0x40(%rsp),%rax
  movsd  (%rax),%xmm0
  addsd  0x8(%rbp),%xmm0
  mov    $0x1,%eax
  call   <cosd@plt>
  pxor   %xmm1,%xmm1
  movsd  (%rsp),%xmm6
  movsd  0x98(%rsp),%xmm2
  movsd  D139(%rip),%xmm0
  neg    %eax
  cvtsi2sd %eax,%xmm1
  subsd  %xmm2,%xmm0
  mulsd  0x20(%rsp),%xmm0
  movapd %xmm1,%xmm5
  addsd  %xmm0,%xmm5
  jmp    L744
  nopw   0x0(%rax,%rax,1)
L164:
  movapd %xmm2,%xmm0
  mov    $0x1,%eax
  call   <asind@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  jmp    L897
  nopl   0x0(%rax,%rax,1)
L320:
  ucomisd %xmm4,%xmm5
  ja     L584
  sqrtsd %xmm4,%xmm4
  movapd %xmm4,%xmm0
L664:
  mov    $0x1,%eax
  call   <acosd@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  andpd  D33(%rip),%xmm0
  xorpd  D120(%rip),%xmm0
  jmp    L897
  nopl   0x0(%rax)
L339:
  mov    0x88(%rsp),%rcx
  add    %rcx,0x58(%rsp)
  add    %rcx,0x60(%rsp)
L405:
  addl   $0x1,0x68(%rsp)
  mov    0x70(%rsp),%rdi
  mov    0x68(%rsp),%eax
  add    %rdi,0x40(%rsp)
  cmp    %eax,0x6c(%rsp)
  jne    L10
L482:
  mov    0xb8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L491
  add    $0xc8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L687:
  ucomisd 0x8(%rbp),%xmm3
  movsd  0x0(%rbp),%xmm0
  movsd  0x10(%rbp),%xmm2
  movsd  D24(%rip),%xmm1
  jp     L511
  jne    L511
  addsd  D219(%rip),%xmm0
  movsd  %xmm1,(%rsp)
  subsd  %xmm2,%xmm0
  call   <fmod@plt>
  mov    0x6c(%rsp),%r10d
  movsd  (%rsp),%xmm1
  test   %r10d,%r10d
  jle    L482
  mov    0x2c(%rsp),%r9d
  movslq %r13d,%rdi
  movslq %r12d,%r8
  shl    $0x3,%rdi
  shl    $0x3,%r8
  test   %r9d,%r9d
  jle    L482
  cmp    $0x1,%r12d
  jne    L122
  cmp    $0x1,%r13d
  jne    L122
  movslq 0x2c(%rsp),%r10
  mov    %rdi,%r11
  mov    0x58(%rsp),%r13
  xor    %r9d,%r9d
  movsd  D176(%rip),%xmm3
  mov    0x60(%rsp),%r14
  imul   %r10,%r11
  mov    %r10,%r12
  imul   %r8,%r10
  nopw   0x0(%rax,%rax,1)
L907:
  mov    %r13,%rax
  mov    %r14,%rsi
  xor    %edx,%edx
  xor    %ecx,%ecx
  jmp    L705
  nopl   0x0(%rax)
L760:
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
L522:
  add    $0x1,%ecx
  add    %rdi,%rax
  add    %rdi,%rsi
  add    %r8,%rdx
  cmp    %ecx,%r12d
  je     L325
L705:
  movsd  (%rbx,%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     L520
  comisd %xmm2,%xmm5
  jbe    L826
  addsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
L826:
  comisd %xmm1,%xmm2
  ja     L760
  comisd %xmm2,%xmm3
  jbe    L522
  addsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
  jmp    L522
L511:
  addsd  %xmm2,%xmm0
  movsd  %xmm1,(%rsp)
  call   <fmod@plt>
  mov    0x6c(%rsp),%esi
  movapd %xmm0,%xmm2
  test   %esi,%esi
  jle    L482
  mov    0x2c(%rsp),%ecx
  movslq %r13d,%rdi
  movslq %r12d,%r8
  shl    $0x3,%rdi
  shl    $0x3,%r8
  test   %ecx,%ecx
  jle    L482
  cmp    $0x1,%r13d
  movsd  (%rsp),%xmm1
  jne    L594
  cmp    $0x1,%r12d
  jne    L594
  movslq 0x2c(%rsp),%r10
  mov    %rdi,%r11
  mov    0x58(%rsp),%r13
  xor    %r9d,%r9d
  movq   D120(%rip),%xmm3
  movsd  D176(%rip),%xmm4
  imul   %r10,%r11
  mov    %r10,%r12
  mov    0x60(%rsp),%r14
  imul   %r8,%r10
L250:
  mov    %r13,%rax
  mov    %r14,%rsi
  xor    %edx,%edx
  xor    %ecx,%ecx
  jmp    L167
  nopl   0x0(%rax)
L802:
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
L310:
  add    $0x1,%ecx
  add    %rdi,%rax
  add    %rdi,%rsi
  add    %r8,%rdx
  cmp    %ecx,%r12d
  je     L854
L167:
  movapd %xmm2,%xmm0
  subsd  (%rbx,%rdx,1),%xmm0
  pxor   %xmm6,%xmm6
  movsd  %xmm0,(%rax)
  movsd  (%r15,%rdx,1),%xmm0
  xorpd  %xmm3,%xmm0
  movsd  %xmm0,(%rsi)
  movsd  0x0(%rbp),%xmm0
  comisd %xmm6,%xmm0
  movsd  (%rax),%xmm0
  jb     L227
  comisd %xmm0,%xmm6
  jbe    L811
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
L811:
  comisd %xmm1,%xmm0
  ja     L802
  comisd %xmm0,%xmm4
  jbe    L310
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  jmp    L310
  nop
L520:
  comisd %xmm5,%xmm2
  jbe    L826
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
  jmp    L826
  nopw   0x0(%rax,%rax,1)
L227:
  comisd %xmm6,%xmm0
  jbe    L811
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  jmp    L811
L854:
  add    %r11,%r13
  add    %r11,%r14
  add    %r10,%rbx
  add    %r10,%r15
  add    $0x1,%r9d
  cmp    %r9d,0x6c(%rsp)
  jne    L250
  jmp    L482
L325:
  add    %r11,%r13
  add    %r11,%r14
  add    %r10,%rbx
  add    %r10,%r15
  add    $0x1,%r9d
  cmp    %r9d,0x6c(%rsp)
  jne    L907
  jmp    L482
L594:
  movslq 0x2c(%rsp),%rax
  mov    %rdi,%r10
  mov    0x58(%rsp),%r13
  xor    %r9d,%r9d
  movq   D120(%rip),%xmm3
  movsd  D176(%rip),%xmm4
  imul   %rax,%r10
  mov    %rax,%r12
  mov    0x60(%rsp),%r14
  imul   %r8,%rax
  mov    %rax,%r11
L247:
  mov    %r13,%rax
  mov    %r14,%rsi
  xor    %edx,%edx
  xor    %ecx,%ecx
  jmp    L621
  nop
L171:
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
L419:
  add    $0x1,%ecx
  add    %rdi,%rax
  add    %rdi,%rsi
  add    %r8,%rdx
  cmp    %ecx,%r12d
  je     L546
L621:
  movapd %xmm2,%xmm0
  subsd  (%rbx,%rdx,1),%xmm0
  pxor   %xmm5,%xmm5
  movsd  %xmm0,(%rax)
  movsd  (%r15,%rdx,1),%xmm0
  xorpd  %xmm3,%xmm0
  movsd  %xmm0,(%rsi)
  movsd  0x0(%rbp),%xmm0
  comisd %xmm5,%xmm0
  jb     L929
  movsd  (%rax),%xmm0
  comisd %xmm0,%xmm5
  jbe    L370
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
L370:
  comisd %xmm1,%xmm0
  ja     L171
  comisd %xmm0,%xmm4
  jbe    L419
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  jmp    L419
  nopl   0x0(%rax,%rax,1)
L929:
  movsd  (%rax),%xmm0
  comisd %xmm5,%xmm0
  jbe    L370
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  jmp    L370
L546:
  add    %r10,%r13
  add    %r10,%r14
  add    %r11,%rbx
  add    %r11,%r15
  add    $0x1,%r9d
  cmp    %r9d,0x6c(%rsp)
  jne    L247
  jmp    L482
L122:
  movslq 0x2c(%rsp),%rax
  mov    %rdi,%r10
  mov    0x58(%rsp),%r13
  xor    %r9d,%r9d
  movsd  D176(%rip),%xmm3
  mov    0x60(%rsp),%r14
  imul   %rax,%r10
  mov    %rax,%r12
  imul   %r8,%rax
  mov    %rax,%r11
L449:
  mov    %r13,%rax
  mov    %r14,%rsi
  xor    %edx,%edx
  xor    %ecx,%ecx
  jmp    L74
  nopl   0x0(%rax,%rax,1)
L162:
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
L759:
  add    $0x1,%ecx
  add    %rdi,%rax
  add    %rdi,%rsi
  add    %r8,%rdx
  cmp    %ecx,%r12d
  je     L150
L74:
  movsd  (%rbx,%rdx,1),%xmm2
  pxor   %xmm7,%xmm7
  addsd  %xmm0,%xmm2
  movsd  %xmm2,(%rax)
  movsd  (%r15,%rdx,1),%xmm2
  movsd  %xmm2,(%rsi)
  movsd  0x0(%rbp),%xmm2
  comisd %xmm7,%xmm2
  jb     L709
  movsd  (%rax),%xmm2
  comisd %xmm2,%xmm7
  jbe    L494
  addsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
L494:
  comisd %xmm1,%xmm2
  ja     L162
  comisd %xmm2,%xmm3
  jbe    L759
  addsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
  jmp    L759
  nopw   0x0(%rax,%rax,1)
L709:
  movsd  (%rax),%xmm2
  comisd %xmm7,%xmm2
  jbe    L494
  subsd  %xmm1,%xmm2
  movsd  %xmm2,(%rax)
  jmp    L494
L150:
  add    %r10,%r13
  add    %r10,%r14
  add    %r11,%rbx
  add    %r11,%r15
  add    $0x1,%r9d
  cmp    %r9d,0x6c(%rsp)
  jne    L449
  jmp    L482
L584:
  movapd %xmm4,%xmm0
  call   <sqrt@plt>
  jmp    L664
L58:
  movapd %xmm4,%xmm0
  call   <sqrt@plt>
  jmp    L728
L491:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D24
datatype: f64
name: parse_data
arguments: label: D219
datatype: f64
name: parse_data
arguments: label: D127
datatype: f64[2]
name: parse_data
arguments: label: D95
datatype: f32[2]
name: parse_data
arguments: label: D192
datatype: f32[2]
name: parse_data
arguments: label: D162
datatype: byte[8]
name: parse_data
arguments: label: D33
datatype: qword[2]
name: parse_data
arguments: label: D120
datatype: f32[4]
name: parse_data
arguments: label: D176
datatype: f32[2]
name: parse_data
arguments: label: D88
datatype: f64[2]
name: parse_data
arguments: label: D139
datatype: f64

tool: D24: 360

tool: D219: 180

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

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

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

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

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

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

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

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

tool: D139: 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;
}
```