user: Please show me the C implementation that matches the assembly code listed below:

```asm
<PPChi2>:
  endbr64
  push   %r12
  pxor   %xmm6,%xmm6
  push   %rbp
  push   %rbx
  sub    $0x60,%rsp
  movsd  %xmm0,0x8(%rsp)
  movsd  %xmm2,0x38(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  comisd %xmm0,%xmm6
  movl   $0x1,(%rdi)
  ja     L178
  comisd D584(%rip),%xmm0
  jae    L178
  comisd %xmm1,%xmm6
  mov    %rdi,%rbp
  jae    L119
  movsd  D310(%rip),%xmm6
  movl   $0x0,(%rdi)
  movsd  0x8(%rsp),%xmm0
  movsd  %xmm1,0x20(%rsp)
  mulsd  %xmm1,%xmm6
  movsd  %xmm6,0x10(%rsp)
  subsd  D584(%rip),%xmm6
  movsd  %xmm6,0x18(%rsp)
  call   <log@plt>
  mulsd  D557(%rip),%xmm0
  movsd  0x20(%rsp),%xmm1
  comisd %xmm1,%xmm0
  ja     L14
  comisd D606(%rip),%xmm1
  movsd  %xmm1,0x20(%rsp)
  jbe    L149
  movsd  0x8(%rsp),%xmm0
  lea    0x54(%rsp),%r12
  mov    $0x1,%eax
  mov    %r12,%rdi
  call   <PPND16@plt>
  movsd  0x20(%rsp),%xmm1
  pxor   %xmm5,%xmm5
  movsd  D678(%rip),%xmm2
  pxor   %xmm3,%xmm3
  divsd  %xmm1,%xmm2
  cvtsi2sd %eax,%xmm3
  ucomisd %xmm2,%xmm5
  ja     L47
  movapd %xmm2,%xmm0
  sqrtsd %xmm0,%xmm0
L91:
  mulsd  %xmm3,%xmm0
  movapd %xmm1,%xmm3
  addsd  D584(%rip),%xmm0
  mulsd  D76(%rip),%xmm1
  addsd  D657(%rip),%xmm1
  subsd  %xmm2,%xmm0
  mulsd  %xmm0,%xmm3
  mulsd  %xmm0,%xmm3
  mulsd  %xmm0,%xmm3
  comisd %xmm1,%xmm3
  ja     L80
L114:
  mov    $0x14,%ebx
  jmp    L196
  nopl   0x0(%rax,%rax,1)
L53:
  movapd %xmm0,%xmm3
L196:
  movsd  D310(%rip),%xmm5
  movsd  0x10(%rsp),%xmm1
  mov    %r12,%rdi
  mov    $0x2,%eax
  movsd  %xmm3,0x30(%rsp)
  mulsd  %xmm3,%xmm5
  movapd %xmm5,%xmm0
  movsd  %xmm5,0x20(%rsp)
  call   <GammaD@plt>
  pxor   %xmm0,%xmm0
  movsd  0x8(%rsp),%xmm6
  cvtsi2sd %eax,%xmm0
  mov    0x54(%rsp),%eax
  subsd  %xmm0,%xmm6
  movsd  %xmm6,0x28(%rsp)
  test   %eax,%eax
  jne    L106
  movsd  0x30(%rsp),%xmm3
  movapd %xmm3,%xmm0
  call   <log@plt>
  movsd  D567(%rip),%xmm3
  mulsd  0x10(%rsp),%xmm3
  movapd %xmm0,%xmm1
  movsd  0x38(%rsp),%xmm0
  mulsd  0x18(%rsp),%xmm1
  addsd  %xmm3,%xmm0
  addsd  0x20(%rsp),%xmm0
  subsd  %xmm1,%xmm0
  call   <exp@plt>
  movsd  0x28(%rsp),%xmm5
  movsd  0x30(%rsp),%xmm3
  movsd  0x18(%rsp),%xmm7
  movsd  D574(%rip),%xmm1
  mulsd  %xmm0,%xmm5
  movsd  D310(%rip),%xmm0
  movsd  D10(%rip),%xmm15
  movapd %xmm7,%xmm10
  movsd  D121(%rip),%xmm9
  movsd  D250(%rip),%xmm2
  movsd  D132(%rip),%xmm11
  movsd  D222(%rip),%xmm8
  movsd  D184(%rip),%xmm12
  movsd  D58(%rip),%xmm13
  movsd  D71(%rip),%xmm14
  mulsd  %xmm5,%xmm0
  movapd %xmm5,%xmm6
  divsd  %xmm3,%xmm6
  movapd %xmm0,%xmm4
  mulsd  %xmm6,%xmm10
  subsd  %xmm10,%xmm4
  mulsd  %xmm4,%xmm1
  addsd  D231(%rip),%xmm1
  mulsd  %xmm4,%xmm9
  addsd  D543(%rip),%xmm9
  mulsd  %xmm4,%xmm8
  addsd  D267(%rip),%xmm8
  mulsd  %xmm4,%xmm12
  addsd  D378(%rip),%xmm12
  mulsd  %xmm4,%xmm1
  mulsd  %xmm4,%xmm9
  addsd  D537(%rip),%xmm9
  mulsd  %xmm4,%xmm8
  addsd  D61(%rip),%xmm8
  mulsd  %xmm4,%xmm13
  addsd  D583(%rip),%xmm13
  mulsd  %xmm4,%xmm12
  addsd  %xmm15,%xmm1
  mulsd  %xmm4,%xmm9
  addsd  D257(%rip),%xmm12
  addsd  D373(%rip),%xmm9
  mulsd  %xmm4,%xmm8
  mulsd  %xmm7,%xmm13
  mulsd  %xmm4,%xmm1
  addsd  D349(%rip),%xmm1
  mulsd  %xmm4,%xmm9
  addsd  %xmm2,%xmm8
  mulsd  %xmm4,%xmm1
  addsd  D291(%rip),%xmm1
  addsd  %xmm11,%xmm9
  divsd  %xmm14,%xmm8
  mulsd  %xmm4,%xmm1
  addsd  %xmm2,%xmm1
  movapd %xmm7,%xmm2
  divsd  %xmm11,%xmm1
  movapd %xmm9,%xmm11
  movsd  D102(%rip),%xmm9
  mulsd  %xmm4,%xmm9
  addsd  D439(%rip),%xmm9
  mulsd  %xmm4,%xmm9
  mulsd  D312(%rip),%xmm4
  addsd  D459(%rip),%xmm9
  mulsd  %xmm7,%xmm9
  movapd %xmm13,%xmm7
  addsd  %xmm15,%xmm4
  addsd  %xmm4,%xmm7
  movapd %xmm2,%xmm4
  addsd  %xmm12,%xmm9
  movsd  D655(%rip),%xmm12
  mulsd  D379(%rip),%xmm2
  addsd  D497(%rip),%xmm2
  mulsd  %xmm4,%xmm2
  divsd  %xmm14,%xmm7
  mulsd  %xmm1,%xmm0
  addsd  D584(%rip),%xmm0
  addsd  D158(%rip),%xmm2
  divsd  %xmm12,%xmm2
  divsd  %xmm12,%xmm9
  mulsd  %xmm6,%xmm2
  subsd  %xmm2,%xmm7
  mulsd  %xmm6,%xmm7
  divsd  %xmm14,%xmm11
  movapd %xmm9,%xmm2
  subsd  %xmm7,%xmm2
  mulsd  %xmm6,%xmm2
  subsd  %xmm2,%xmm8
  mulsd  %xmm6,%xmm8
  subsd  %xmm8,%xmm11
  mulsd  %xmm6,%xmm11
  subsd  %xmm11,%xmm1
  mulsd  %xmm10,%xmm1
  subsd  %xmm1,%xmm0
  mulsd  %xmm5,%xmm0
  addsd  %xmm3,%xmm0
  divsd  %xmm0,%xmm3
  subsd  D584(%rip),%xmm3
  andpd  D672(%rip),%xmm3
  comisd D650(%rip),%xmm3
  ja     L73
  sub    $0x1,%ebx
  jne    L53
  movl   $0x4,0x0(%rbp)
  jmp    L73
  nopl   (%rax)
L119:
  movl   $0x2,(%rdi)
L178:
  movsd  D2(%rip),%xmm0
L73:
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L62
  add    $0x60,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L14:
  movsd  0x10(%rsp),%xmm0
  mulsd  D567(%rip),%xmm0
  addsd  0x38(%rsp),%xmm0
  call   <exp@plt>
  movsd  0x10(%rsp),%xmm5
  movsd  0x8(%rsp),%xmm6
  movapd %xmm0,%xmm1
  mulsd  %xmm5,%xmm6
  movapd %xmm6,%xmm0
  mulsd  %xmm1,%xmm0
  movsd  D584(%rip),%xmm1
  divsd  %xmm5,%xmm1
  call   <pow@plt>
  movsd  D650(%rip),%xmm1
  movapd %xmm0,%xmm3
  comisd %xmm0,%xmm1
  ja     L73
L140:
  lea    0x54(%rsp),%r12
  jmp    L114
  nopw   0x0(%rax,%rax,1)
L149:
  movsd  D584(%rip),%xmm0
  subsd  0x8(%rsp),%xmm0
  call   <log@plt>
  movsd  0x18(%rsp),%xmm6
  mulsd  D567(%rip),%xmm6
  addsd  0x38(%rsp),%xmm0
  movsd  D518(%rip),%xmm3
  movsd  %xmm0,0x48(%rsp)
  movsd  %xmm6,0x40(%rsp)
  nopl   0x0(%rax,%rax,1)
L198:
  movsd  D582(%rip),%xmm2
  movsd  D634(%rip),%xmm1
  movsd  %xmm3,0x20(%rsp)
  movsd  D310(%rip),%xmm0
  addsd  %xmm3,%xmm2
  addsd  %xmm3,%xmm1
  mulsd  %xmm3,%xmm0
  addsd  0x48(%rsp),%xmm0
  addsd  0x40(%rsp),%xmm0
  mulsd  %xmm3,%xmm2
  addsd  D203(%rip),%xmm2
  mulsd  %xmm3,%xmm1
  addsd  D584(%rip),%xmm1
  mulsd  %xmm3,%xmm2
  movsd  %xmm1,0x30(%rsp)
  movsd  %xmm2,0x28(%rsp)
  call   <exp@plt>
  movsd  0x28(%rsp),%xmm2
  movsd  0x30(%rsp),%xmm1
  movsd  0x20(%rsp),%xmm3
  movsd  D584(%rip),%xmm4
  mulsd  %xmm2,%xmm0
  divsd  %xmm1,%xmm0
  subsd  %xmm0,%xmm4
  movapd %xmm3,%xmm0
  addsd  %xmm3,%xmm0
  addsd  D634(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  D414(%rip),%xmm1
  mulsd  %xmm3,%xmm1
  addsd  D603(%rip),%xmm1
  mulsd  %xmm3,%xmm1
  addsd  D203(%rip),%xmm1
  divsd  %xmm2,%xmm1
  subsd  D310(%rip),%xmm0
  subsd  %xmm1,%xmm0
  divsd  %xmm0,%xmm4
  movapd %xmm3,%xmm0
  subsd  %xmm4,%xmm3
  divsd  %xmm3,%xmm0
  subsd  D584(%rip),%xmm0
  andpd  D672(%rip),%xmm0
  comisd D315(%rip),%xmm0
  ja     L198
  jmp    L140
  nopl   0x0(%rax,%rax,1)
L106:
  movl   $0x3,0x0(%rbp)
  jmp    L178
  nopl   0x0(%rax)
L80:
  movsd  D584(%rip),%xmm0
  subsd  0x8(%rsp),%xmm0
  movsd  %xmm3,0x20(%rsp)
  call   <log@plt>
  movsd  0x20(%rsp),%xmm3
  movq   %xmm0,%rbx
  movsd  D310(%rip),%xmm0
  mulsd  %xmm3,%xmm0
  call   <log@plt>
  movsd  0x18(%rsp),%xmm1
  movsd  D129(%rip),%xmm3
  mulsd  %xmm0,%xmm1
  movq   %rbx,%xmm0
  subsd  %xmm1,%xmm0
  addsd  0x38(%rsp),%xmm0
  mulsd  %xmm0,%xmm3
  jmp    L114
L62:
  call   <__stack_chk_fail@plt>
L47:
  movapd %xmm2,%xmm0
  movsd  %xmm1,0x30(%rsp)
  movsd  %xmm3,0x28(%rsp)
  movsd  %xmm2,0x20(%rsp)
  call   <sqrt@plt>
  movsd  0x30(%rsp),%xmm1
  movsd  0x28(%rsp),%xmm3
  movsd  0x20(%rsp),%xmm2
  jmp    L91
```

tool_calls: name: disassemble_data
arguments: data_tag: D584
type_guessed: f64[2]
name: disassemble_data
arguments: data_tag: D310
type_guessed: f64
name: disassemble_data
arguments: data_tag: D557
type_guessed: byte[8]
name: disassemble_data
arguments: data_tag: D606
type_guessed: f64[2]
name: disassemble_data
arguments: data_tag: D678
type_guessed: f64
name: disassemble_data
arguments: data_tag: D76
type_guessed: f64
name: disassemble_data
arguments: data_tag: D657
type_guessed: f64
name: disassemble_data
arguments: data_tag: D567
type_guessed: f64
name: disassemble_data
arguments: data_tag: D574
type_guessed: f64
name: disassemble_data
arguments: data_tag: D10
type_guessed: f64
name: disassemble_data
arguments: data_tag: D121
type_guessed: f64
name: disassemble_data
arguments: data_tag: D250
type_guessed: f64
name: disassemble_data
arguments: data_tag: D132
type_guessed: f64
name: disassemble_data
arguments: data_tag: D222
type_guessed: f64
name: disassemble_data
arguments: data_tag: D184
type_guessed: f64
name: disassemble_data
arguments: data_tag: D58
type_guessed: f64
name: disassemble_data
arguments: data_tag: D71
type_guessed: f64
name: disassemble_data
arguments: data_tag: D231
type_guessed: f64
name: disassemble_data
arguments: data_tag: D543
type_guessed: f64
name: disassemble_data
arguments: data_tag: D267
type_guessed: f64
name: disassemble_data
arguments: data_tag: D378
type_guessed: f64
name: disassemble_data
arguments: data_tag: D537
type_guessed: f64
name: disassemble_data
arguments: data_tag: D61
type_guessed: f64
name: disassemble_data
arguments: data_tag: D583
type_guessed: f64
name: disassemble_data
arguments: data_tag: D257
type_guessed: f64
name: disassemble_data
arguments: data_tag: D373
type_guessed: f64
name: disassemble_data
arguments: data_tag: D349
type_guessed: f64
name: disassemble_data
arguments: data_tag: D291
type_guessed: f64
name: disassemble_data
arguments: data_tag: D102
type_guessed: f64
name: disassemble_data
arguments: data_tag: D439
type_guessed: f64
name: disassemble_data
arguments: data_tag: D312
type_guessed: f64
name: disassemble_data
arguments: data_tag: D459
type_guessed: f64
name: disassemble_data
arguments: data_tag: D655
type_guessed: f64
name: disassemble_data
arguments: data_tag: D379
type_guessed: f64
name: disassemble_data
arguments: data_tag: D497
type_guessed: f64
name: disassemble_data
arguments: data_tag: D158
type_guessed: f64
name: disassemble_data
arguments: data_tag: D672
type_guessed: qword[2]
name: disassemble_data
arguments: data_tag: D650
type_guessed: byte[16]
name: disassemble_data
arguments: data_tag: D2
type_guessed: f32[2]
name: disassemble_data
arguments: data_tag: D518
type_guessed: f64
name: disassemble_data
arguments: data_tag: D582
type_guessed: f64
name: disassemble_data
arguments: data_tag: D634
type_guessed: f64
name: disassemble_data
arguments: data_tag: D203
type_guessed: f64
name: disassemble_data
arguments: data_tag: D414
type_guessed: f64
name: disassemble_data
arguments: data_tag: D603
type_guessed: f64
name: disassemble_data
arguments: data_tag: D315
type_guessed: f64[2]
name: disassemble_data
arguments: data_tag: D129
type_guessed: f32[2]

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

tool: D310: 0.5

tool: {"D557": [0xd7,0xa3,0x70,0x3d,0x0a,0xd7,0xf3,0xbf]}

tool: {"D606": [0.32,0.222222]}

tool: D678: 0.222222

tool: D76: 2.2

tool: D657: 6

tool: D567: 0.6931471806

tool: D574: 60

tool: D10: 84

tool: D121: 1278

tool: D250: 210

tool: D132: 420

tool: D222: 932

tool: D184: 1182

tool: D58: 606

tool: D71: 2520

tool: D231: 70

tool: D543: 1141

tool: D267: 707

tool: D378: 672

tool: D537: 966

tool: D61: 462

tool: D583: 1175

tool: D257: 252

tool: D373: 735

tool: D349: 105

tool: D291: 140

tool: D102: 1740

tool: D439: 889

tool: D312: 2264

tool: D459: 294

tool: D655: 5040

tool: D379: 127

tool: D497: 346

tool: D158: 120

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

tool: {"D650": [0x8d,0xed,0xb5,0xa0,0xf7,0xc6,0xa0,0x3e,0x7b,0x14,0xae,0x47,0xe1,0x7a,0xd4,0x3f]}

tool: {"D2": [0.0,-1.875]}

tool: D518: 0.4

tool: D582: 6.66

tool: D634: 4.67

tool: D203: 6.73

tool: D414: 3

tool: D603: 13.32

tool: {"D315": [0.01,60.0]}

tool: {"D129": [0.0,-2.0]}

assistant: ```c
double PPChi2(p, v, g, ifault)
double p, v, g;
int *ifault;
{
  int i, if1;
  double a, b, c, q, t, x, p1, p2, s1, s2, s3, s4, s5, s6, ch, xx, tmp;
  *ifault = 1;
  if ((p < 0.0) || (p >= 1.0))
    return -1.0;
  *ifault = 2;
  if (v <= 0.0)
    return -1.0;
  *ifault = 0;
  xx = 0.5 * v;
  c = xx - 1.0;
  if (v < -1.24 * log(p)) {
    ch = pow(p * xx * (exp(g + xx * 0.6931471806)), 1.0 / xx);
    if (ch < 5e-7)
      return ch;
  } else {
    if (v > 0.32) {
      x = PPND16(p, &if1);
      p1 = 0.222222 / v;
      tmp = x * sqrt(p1) + 1.0 - p1;
      ch = v * tmp * tmp * tmp;
      if (ch > 2.2 * v + 6.0)
        ch = -2.0 * (log(1.0 - p) - c * log(0.5 * ch) + g);
    } else {
      ch = 0.4;
      a = log(1.0 - p);
      do {
        q = ch;
        p1 = 1.0 + ch * (4.67 + ch);
        p2 = ch * (6.73 + ch * (6.66 + ch));
        t = -0.5 + (4.67 + 2.0 * ch) / p1 - (6.73 + ch * (13.32 + 3.0 * ch)) / p2;
        ch -= (1.0 - (exp(a + g + 0.5 * ch + c * 0.6931471806)) * p2 / p1) / t;
      } while (fabs(q / ch - 1.0) > 0.01);
    }
  }
  for (i = 1; i <= 20; ++i) {
    q = ch;
    p1 = 0.5 * ch;
    p2 = p - GammaD(p1, xx, &if1);
    if (if1 == 0) {
      t = p2 * (exp(xx * 0.6931471806 + g + p1 - c * log(ch)));
      b = t / ch;
      a = 0.5 * t - b * c;
      s1 = (210.0 + a * (140.0 + a * (105.0 + a * (84.0 + a * (70.0 + 60.0 * a))))) / 420.0;
      s2 = (420.0 + a * (735.0 + a * (966.0 + a * (1141.0 + 1278.0 * a)))) / 2520.0;
      s3 = (210.0 + a * (462.0 + a * (707.0 + 932.0 * a))) / 2520.0;
      s4 = (252.0 + a * (672.0 + 1182.0 * a) + c * (294.0 + a * (889.0 + 1740.0 * a))) / 5040.0;
      s5 = (84.0 + 2264.0 * a + c * (1175.0 + 606.0 * a)) / 2520.0;
      s6 = (120.0 + c * (346.0 + 127.0 * c)) / 5040.0;
      ch += t * (1.0 + 0.5 * t * s1 - b * c * (s1 - b * (s2 - b * (s3 - b * (s4 - b * (s5 - b * s6))))));
      if (fabs(q / ch - 1.0) > 5e-7)
        return ch;
    } else {
      *ifault = 3;
      return -1.0;
    }
  }
  *ifault = 4;
  return ch;
}
```