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

```asm
<psg_kernel_adi>:
  endbr64
  push   %r15
  pxor   %xmm0,%xmm0
  pxor   %xmm2,%xmm2
  push   %r14
  cvtsi2sd %esi,%xmm0
  push   %r13
  cvtsi2sd %edi,%xmm2
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  sub    $0x128,%rsp
  movsd  D26(%rip),%xmm1
  movsd  D103(%rip),%xmm4
  mov    %edi,0x88(%rsp)
  divsd  %xmm0,%xmm1
  movsd  D26(%rip),%xmm0
  mov    %esi,0x34(%rsp)
  mov    %rdx,0x38(%rsp)
  mov    %rcx,0x68(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x118(%rsp)
  xor    %eax,%eax
  divsd  %xmm2,%xmm0
  mulsd  %xmm1,%xmm1
  movapd %xmm0,%xmm3
  addsd  %xmm0,%xmm3
  divsd  %xmm1,%xmm0
  divsd  %xmm1,%xmm3
  movapd %xmm0,%xmm1
  addsd  D26(%rip),%xmm0
  xorpd  D149(%rip),%xmm1
  mulsd  %xmm4,%xmm1
  movsd  %xmm0,0x8(%rsp)
  movapd %xmm3,%xmm2
  addsd  D26(%rip),%xmm3
  xorpd  D149(%rip),%xmm2
  mulsd  %xmm4,%xmm2
  movsd  %xmm3,(%rsp)
  test   %edi,%edi
  jle    L26
  mov    %esi,%edi
  sar    %ebx
  mov    %rdx,%r11
  lea    -0x1(%rsi),%esi
  mov    %ebx,0x8c(%rsp)
  mov    %edi,%ebx
  shr    $0x1f,%edi
  movapd %xmm2,%xmm7
  mov    %edi,%eax
  movslq %ebx,%rdx
  mov    %esi,0x4c(%rsp)
  lea    0xf0(%rsp),%rdi
  add    %ebx,%eax
  lea    0x0(,%rdx,8),%rbx
  xorpd  D149(%rip),%xmm7
  movl   $0x1,0x48(%rsp)
  sar    %eax
  mov    %rdi,0x80(%rsp)
  mov    %rbx,%r14
  mov    %eax,0x1c(%rsp)
  lea    (%r8,%rbx,1),%rax
  mov    %rax,0x58(%rsp)
  lea    (%r9,%rbx,1),%rax
  mov    %rax,0xc0(%rsp)
  mov    %edx,%eax
  imul   %esi,%eax
  mov    %rcx,%rsi
  mov    %r8,0xe8(%rsp)
  mov    %r9,0x50(%rsp)
  movsd  %xmm7,0x70(%rsp)
  cltq
  movsd  %xmm2,0x78(%rsp)
  lea    0x8(%rcx,%rax,8),%rcx
  lea    (%rsi,%rax,8),%rsi
  mov    %rcx,0xc8(%rsp)
  lea    (%r11,%rbx,1),%rcx
  lea    -0x3(%rdx),%r11d
  mov    %rcx,0x60(%rsp)
  lea    (%rdx,%r11,1),%rcx
  lea    0x8(%r8,%rcx,8),%rcx
  mov    %rsi,0xe0(%rsp)
  mov    %rcx,0xd0(%rsp)
  mov    %edx,%ecx
  neg    %ecx
  mov    %r11,0xd8(%rsp)
  movslq %ecx,%rcx
  lea    0x0(,%rcx,8),%rsi
  mov    %edx,%ecx
  mov    %rsi,0x98(%rsp)
  lea    -0x2(%rdx),%esi
  imul   %esi,%ecx
  mov    %esi,0x30(%rsp)
  movslq %ecx,%rcx
  sub    %rax,%rcx
  lea    0x8(%rbx),%rax
  mov    %rax,0xb0(%rsp)
  mov    %rbx,%rax
  neg    %rax
  mov    %rcx,0x90(%rsp)
  mov    %rax,0xb8(%rsp)
  lea    (%rdx,%rdx,1),%eax
  cltq
  shl    $0x3,%rax
  mov    %rax,0xa8(%rsp)
  lea    0x2(%rdx,%r11,1),%rax
  shl    $0x3,%rax
  mov    %rax,0xa0(%rsp)
  movslq %esi,%rax
  lea    -0x8(%r9,%rax,8),%rax
  mov    %rax,0x40(%rsp)
  nopl   (%rax)
L42:
  cmpl   $0x1,0x4c(%rsp)
  jle    L125
  mov    0xd8(%rsp),%rax
  movapd %xmm1,%xmm6
  movapd %xmm1,%xmm3
  mov    0xd0(%rsp),%r10
  addsd  %xmm1,%xmm6
  addsd  D26(%rip),%xmm6
  xorpd  D149(%rip),%xmm3
  mov    $0x1,%r11d
  add    $0x2,%rax
  mov    0x60(%rsp),%rbx
  mov    0xc8(%rsp),%r12
  mov    0x58(%rsp),%rsi
  mov    %rax,0x28(%rsp)
  mov    0xc0(%rsp),%rdi
  mov    0x90(%rsp),%r8
  movsd  0x78(%rsp),%xmm2
  mov    0x98(%rsp),%r9
  mov    0xe0(%rsp),%r15
  mov    0x68(%rsp),%rbp
  mov    0x30(%rsp),%r13d
  movsd  0x70(%rsp),%xmm7
  xchg   %ax,%ax
L13:
  mov    D26(%rip),%rax
  mov    %rdi,%rcx
  mov    %rbx,%rdx
  mov    %rax,0x0(%rbp,%r11,8)
  mov    %rsi,%rax
  movq   $0x0,(%rsi)
  movsd  0x0(%rbp,%r11,8),%xmm0
  movsd  %xmm0,(%rdi)
  nopw   0x0(%rax,%rax,1)
L144:
  movsd  (%rax),%xmm4
  movapd %xmm7,%xmm0
  add    $0x8,%rax
  add    $0x8,%rcx
  mulsd  %xmm2,%xmm4
  addsd  (%rsp),%xmm4
  divsd  %xmm4,%xmm0
  movsd  %xmm0,(%rax)
  movsd  (%rdx),%xmm0
  movsd  0x8(%rdx),%xmm5
  mulsd  %xmm3,%xmm0
  mulsd  %xmm6,%xmm5
  addsd  %xmm5,%xmm0
  movsd  0x10(%rdx),%xmm5
  add    %r14,%rdx
  mulsd  %xmm1,%xmm5
  subsd  %xmm5,%xmm0
  movsd  -0x8(%rcx),%xmm5
  mulsd  %xmm2,%xmm5
  subsd  %xmm5,%xmm0
  divsd  %xmm4,%xmm0
  movsd  %xmm0,(%rcx)
  cmp    %r10,%rax
  jne    L144
  mov    D26(%rip),%rax
  mov    %rax,(%r15,%r11,8)
  test   %r13d,%r13d
  je     L24
  movslq %r13d,%rax
  mov    %r12,%rdx
  cs nopw 0x0(%rax,%rax,1)
L102:
  movsd  (%rsi,%rax,8),%xmm0
  mulsd  (%rdx),%xmm0
  addsd  (%rdi,%rax,8),%xmm0
  sub    $0x1,%rax
  movsd  %xmm0,(%rdx,%r8,8)
  add    %r9,%rdx
  test   %eax,%eax
  jne    L102
  add    $0x1,%r11
  add    %r14,%rsi
  add    %r14,%rdi
  add    $0x8,%r12
  add    $0x8,%rbx
  add    %r14,%r10
  cmp    0x28(%rsp),%r11
  jne    L13
  nop
L24:
  movsd  0x78(%rsp),%xmm2
  xor    %r9d,%r9d
  mov    $0x1,%r8d
  mov    0xa0(%rsp),%rdi
  mov    %r9,0x20(%rsp)
  mov    0xa8(%rsp),%rbx
  movapd %xmm2,%xmm6
  mov    %r8,0x10(%rsp)
  mov    0xb8(%rsp),%r11
  addsd  %xmm2,%xmm6
  mov    0x58(%rsp),%rsi
  mov    0x60(%rsp),%rcx
  addsd  D26(%rip),%xmm6
  mov    0xb0(%rsp),%r10
  mov    0x48(%rsp),%r12d
  mov    0x8c(%rsp),%r9d
  mov    0x68(%rsp),%r8
  mov    0xe8(%rsp),%rbp
  mov    0x50(%rsp),%r15
  movsd  0x70(%rsp),%xmm7
  nopl   0x0(%rax,%rax,1)
L163:
  mov    D26(%rip),%rax
  mov    0x20(%rsp),%rdx
  mov    %rax,(%rcx)
  lea    (%r11,%rdx,1),%r13
  lea    (%rbx,%r11,1),%rdx
  mov    %r10,%rax
  movq   $0x0,(%rsi)
  movsd  (%rcx),%xmm0
  add    %r8,%r13
  add    %r8,%rdx
  movsd  %xmm0,-0x8(%r15,%r10,1)
  nopw   0x0(%rax,%rax,1)
L44:
  movsd  -0x8(%rbp,%rax,1),%xmm4
  movapd %xmm3,%xmm0
  mulsd  %xmm1,%xmm4
  addsd  0x8(%rsp),%xmm4
  divsd  %xmm4,%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,1)
  movsd  0x0(%r13,%rax,1),%xmm0
  movsd  (%r8,%rax,1),%xmm5
  mulsd  %xmm7,%xmm0
  mulsd  %xmm6,%xmm5
  addsd  %xmm5,%xmm0
  movsd  (%rdx,%rax,1),%xmm5
  mulsd  %xmm2,%xmm5
  subsd  %xmm5,%xmm0
  movsd  -0x8(%r15,%rax,1),%xmm5
  mulsd  %xmm1,%xmm5
  subsd  %xmm5,%xmm0
  divsd  %xmm4,%xmm0
  movsd  %xmm0,(%r15,%rax,1)
  add    $0x8,%rax
  cmp    %rax,%rdi
  jne    L44
  mov    D26(%rip),%rdx
  mov    0x38(%rsp),%rax
  mov    %rdx,-0x8(%rax,%rbx,1)
  mov    0x30(%rsp),%edx
  test   %edx,%edx
  jle    L19
  mov    0x10(%rsp),%edx
  cmp    %edx,0x1c(%rsp)
  mov    0x40(%rsp),%rdx
  sete   %r13b
  movslq 0x30(%rsp),%rax
  add    %r10,%rdx
  jmp    L189
  nopw   0x0(%rax,%rax,1)
L111:
  movsd  (%rdx),%xmm4
L2:
  movsd  (%rsi,%rax,8),%xmm0
  mulsd  0x8(%rcx,%rax,8),%xmm0
  sub    $0x8,%rdx
  addsd  %xmm4,%xmm0
  movsd  %xmm0,(%rcx,%rax,8)
  sub    $0x1,%rax
  test   %eax,%eax
  jle    L19
L189:
  cmp    %r12d,%r9d
  jne    L111
  cmp    %eax,0x1c(%rsp)
  jne    L111
  test   %r13b,%r13b
  je     L111
  movsd  0x80(%rdx),%xmm4
  movsd  %xmm4,(%rdx)
  jmp    L2
  nopw   0x0(%rax,%rax,1)
L19:
  addq   $0x1,0x10(%rsp)
  add    %r14,%rcx
  add    %r14,%rsi
  add    %r14,%r10
  add    %r14,0x20(%rsp)
  mov    0x10(%rsp),%rax
  sub    %r14,%r11
  add    %r14,%rbx
  add    %r14,%rdi
  cmp    0x28(%rsp),%rax
  jne    L163
L125:
  mov    0x80(%rsp),%rbx
  mov    0x48(%rsp),%edx
  lea    D81(%rip),%rsi
  movsd  %xmm1,0x10(%rsp)
  mov    %rbx,%rdi
  call   <sprintf@plt>
  mov    %rbx,%rdi
  lea    D140(%rip),%rsi
  call   <strcat@plt>
  mov    %rbx,%rdi
  lea    D72(%rip),%rsi
  xor    %ebx,%ebx
  call   <fopen@plt>
  mov    0x50(%rsp),%r13
  movsd  0x10(%rsp),%xmm1
  mov    %rax,%r12
  mov    0x4c(%rsp),%eax
  mov    %rax,%rdi
  mov    0x34(%rsp),%eax
  test   %eax,%eax
  jle    L62
  mov    %r13,%rbp
  movsd  %xmm1,0x10(%rsp)
  mov    %rdi,%r13
  nopw   0x0(%rax,%rax,1)
L136:
  xor    %r15d,%r15d
  nopl   0x0(%rax,%rax,1)
L121:
  movsd  0x0(%rbp,%r15,8),%xmm0
  mov    %r15d,%ecx
  mov    %ebx,%edx
  mov    %r12,%rdi
  lea    D137(%rip),%rsi
  call   <fprintf@plt>
  mov    %r15,%rax
  add    $0x1,%r15
  cmp    %r13,%rax
  jne    L121
  add    $0x1,%ebx
  add    %r14,%rbp
  cmp    %ebx,0x34(%rsp)
  jne    L136
  movsd  0x10(%rsp),%xmm1
L62:
  mov    %r12,%rdi
  movsd  %xmm1,0x10(%rsp)
  call   <fclose@plt>
  addl   $0x1,0x48(%rsp)
  mov    0x48(%rsp),%eax
  cmp    %eax,0x88(%rsp)
  movsd  0x10(%rsp),%xmm1
  jge    L42
L26:
  mov    0x118(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L7
  add    $0x128,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L7:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D26
type: f64
name: extract_symbolic_data
arguments: tag: D103
type: f32[2]
name: extract_symbolic_data
arguments: tag: D149
type: f32[4]
name: extract_symbolic_data
arguments: tag: D81
type: string
name: extract_symbolic_data
arguments: tag: D140
type: string
name: extract_symbolic_data
arguments: tag: D72
type: string
name: extract_symbolic_data
arguments: tag: D137
type: string

tool: D26: 1

tool: {"D103": [0.0,1.75]}

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

tool: D81: %d

tool: D140: _simData_q.dat

tool: D72: wb

tool: D137: %d %d %lf


assistant: ```c
void psg_kernel_adi(int tsteps, int n, double *u, double *v, double *p, double *q) {
  double *q1;
  FILE *fp_u;
  FILE *fp_v;
  FILE *fp_p;
  FILE *fp_q;
  int t, i, j;
  double DX, DY, DT;
  double B1, B2;
  double mul1, mul2;
  double a, b, c, d, e, f;
#pragma scop
  DX = 1.0 / (double)n;
  DY = 1.0 / (double)n;
  DT = 1.0 / (double)tsteps;
  B1 = 2.0;
  B2 = 1.0;
  mul1 = B1 * DT / (DX * DX);
  mul2 = B2 * DT / (DY * DY);
  a = -mul1 / 2.0;
  b = 1.0 + mul1;
  c = a;
  d = -mul2 / 2.0;
  e = 1.0 + mul2;
  f = d;
  for (t = 1; t <= tsteps; t++) {
    for (i = 1; i < n - 1; i++) {
      v[i] = 1.0;
      p[i * n] = 0.0;
      q[i * n] = v[i];
      for (j = 1; j < n - 1; j++) {
        p[i * n + j] = -c / (a * p[i * n + (j - 1)] + b);
        q[i * n + j] = (-d * u[j * n + (i - 1)] + (1.0 + 2.0 * d) * u[j * n + i] - f * u[j * n + (i + 1)] - a * q[i * n + (j - 1)]) / (a * p[i * n + (j - 1)] + b);
      }
      v[n * (n - 1) + i] = 1.0;
      for (j = n - 2; j >= 1; j--) {
        v[j * n + i] = p[i * n + j] * v[(j + 1) * n + i] + q[i * n + j];
      }
    }
    for (i = 1; i < n - 1; i++) {
      u[i * n] = 1.0;
      p[i * n] = 0.0;
      q[i * n] = u[i * n];
      for (j = 1; j < n - 1; j++) {
        p[i * n + j] = -f / (d * p[i * n + (j - 1)] + e);
        q[i * n + j] = (-a * v[(i - 1) * n + j] + (1.0 + 2.0 * a) * v[i * n + j] - c * v[(i + 1) * n + j] - d * q[i * n + (j - 1)]) / (d * p[i * n + (j - 1)] + e);
      }
      u[i * n + (n - 1)] = 1.0;
      for (j = n - 2; j >= 1; j--) {
        if (t == tsteps / 2 && i == n / 2 && j == n / 2) {
          q1 = q + 16;
          q[i * n + j] = q1[i * n + j];
        }
        u[i * n + j] = p[i * n + j] * u[i * n + (j + 1)] + q[i * n + j];
      }
    }
    char buffer_q[40];
    sprintf(buffer_q, "%d", t);
    strcat(buffer_q, "_simData_q.dat");
    fp_q = fopen(buffer_q, "wb");
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        fprintf(fp_q, "%d %d %lf\n", i, j, q[i * n + j]);
      }
    }
    fclose(fp_q);
  }
#pragma endscop
}
```