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

```asm
<paw_scattering_test>:
  endbr64
  push   %r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  sub    $0x308,%rsp
  movsd  %xmm2,0x28(%rsp)
  movsd  %xmm1,0x88(%rsp)
  movsd  %xmm0,0x20(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x2f8(%rsp)
  xor    %eax,%eax
  call   <paw_N_LogGrid@plt>
  xor    %eax,%eax
  call   <paw_r_LogGrid@plt>
  mov    %rax,%rbx
  xor    %eax,%eax
  call   <paw_log_amesh_LogGrid@plt>
  xor    %eax,%eax
  movsd  %xmm0,0x58(%rsp)
  call   <paw_alloc_LogGrid@plt>
  mov    %rax,0x60(%rsp)
  mov    %rax,%r13
  xor    %eax,%eax
  call   <paw_alloc_LogGrid@plt>
  mov    %rax,0x68(%rsp)
  mov    %rax,%r12
  xor    %eax,%eax
  call   <paw_alloc_LogGrid@plt>
  mov    %rax,0x30(%rsp)
  xor    %eax,%eax
  call   <paw_alloc_LogGrid@plt>
  mov    %r14d,%edi
  mov    %rax,0x38(%rsp)
  call   <paw_alloc_1d_array@plt>
  mov    %r14d,%edi
  mov    %rax,0x40(%rsp)
  call   <paw_alloc_1d_array@plt>
  mov    %r14d,%edi
  mov    %rax,0x48(%rsp)
  call   <paw_alloc_1d_array@plt>
  pxor   %xmm0,%xmm0
  movsd  0x88(%rsp),%xmm1
  subsd  0x20(%rsp),%xmm1
  cvtsi2sd %r14d,%xmm0
  mov    %rax,0x50(%rsp)
  xor    %eax,%eax
  divsd  %xmm0,%xmm1
  movsd  %xmm1,0x70(%rsp)
  call   <paw_get_kohn_sham_potential@plt>
  movsd  0x28(%rsp),%xmm0
  mov    %rax,0x78(%rsp)
  call   <paw_get_grid_index@plt>
  mov    %eax,0x84(%rsp)
  test   %r14d,%r14d
  jle    L55
  cltq
  mov    0x38(%rsp),%rcx
  lea    -0x8(,%rax,8),%r15
  movslq %r14d,%rax
  xor    %r14d,%r14d
  lea    (%r12,%r15,1),%r10
  lea    (%rcx,%r15,1),%r12
  add    %r15,%r13
  add    %r15,%rbx
  mov    %rax,0x18(%rsp)
  mov    %r12,%rax
  mov    %rbx,%r9
  mov    %r13,%r12
  mov    %ebp,%ebx
  add    0x30(%rsp),%r15
  mov    %r10,%rbp
  mov    %rax,%r13
  nopw   0x0(%rax,%rax,1)
L54:
  pxor   %xmm1,%xmm1
  mov    0x50(%rsp),%rax
  mov    0x38(%rsp),%rdx
  mov    %ebx,%edi
  cvtsi2sd %r14d,%xmm1
  mulsd  0x70(%rsp),%xmm1
  mov    0x30(%rsp),%rsi
  mov    %r9,0x10(%rsp)
  addsd  0x20(%rsp),%xmm1
  movsd  0x28(%rsp),%xmm0
  movsd  %xmm1,(%rax,%r14,8)
  movsd  %xmm1,0x8(%rsp)
  call   <paw_solve_paw_scattering@plt>
  movsd  0x8(%rsp),%xmm1
  mov    %ebx,%edi
  mov    0x68(%rsp),%r8
  mov    0x60(%rsp),%rcx
  mov    0x84(%rsp),%edx
  mov    0x78(%rsp),%rsi
  movapd %xmm1,%xmm0
  call   <paw_R_Schrodinger_Fixed_E@plt>
  mov    0x10(%rsp),%r9
  movsd  (%r12),%xmm0
  movsd  0x58(%rsp),%xmm3
  movsd  0x0(%rbp),%xmm1
  mulsd  (%r9),%xmm0
  mov    0x40(%rsp),%rax
  mulsd  %xmm3,%xmm0
  divsd  %xmm0,%xmm1
  movsd  %xmm1,(%rax,%r14,8)
  movsd  (%r15),%xmm0
  mulsd  (%r9),%xmm0
  movsd  0x0(%r13),%xmm1
  mov    0x48(%rsp),%rax
  mulsd  %xmm3,%xmm0
  divsd  %xmm0,%xmm1
  movsd  %xmm1,(%rax,%r14,8)
  add    $0x1,%r14
  cmp    %r14,0x18(%rsp)
  jne    L54
  xor    %eax,%eax
  mov    %ebx,%ebp
  call   <paw_debug@plt>
  test   %rax,%rax
  jne    L78
L5:
  mov    0x2f8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L22
  add    $0x308,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L78:
  mov    %ebp,%edi
  lea    0x90(%rsp),%r12
  xor    %r14d,%r14d
  call   <paw_spd_Name@plt>
  mov    %rax,%rbx
  xor    %eax,%eax
  call   <paw_get_atom_name@plt>
  mov    %rax,%r13
  xor    %eax,%eax
  call   <paw_sdir@plt>
  mov    %rbx,%r8
  mov    %r13,%rcx
  mov    %r12,%rdi
  lea    D59(%rip),%r13
  mov    %rax,%rdx
  lea    D95(%rip),%rsi
  call   <sprintf@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  lea    D152(%rip),%rbx
  call   <fopen@plt>
  mov    %ebp,0x8(%rsp)
  mov    %r14,%rbp
  mov    0x50(%rsp),%r14
  mov    %r13,0x10(%rsp)
  mov    0x48(%rsp),%r13
  mov    %rax,%r15
  mov    %r12,0x30(%rsp)
  mov    0x40(%rsp),%r12
  nopw   0x0(%rax,%rax,1)
L3:
  movsd  (%r14,%rbp,8),%xmm0
  movsd  0x0(%r13,%rbp,8),%xmm2
  mov    %rbx,%rsi
  mov    %r15,%rdi
  movsd  (%r12,%rbp,8),%xmm1
  mov    $0x3,%eax
  add    $0x1,%rbp
  call   <fprintf@plt>
  cmp    %rbp,0x18(%rsp)
  jne    L3
  mov    0x8(%rsp),%ebp
  mov    0x10(%rsp),%r13
  mov    0x30(%rsp),%r12
L73:
  mov    %r15,%rdi
  lea    0x1c0(%rsp),%r14
  call   <fclose@plt>
  mov    %ebp,%edi
  call   <paw_spd_Name@plt>
  mov    %rax,%rbx
  xor    %eax,%eax
  call   <paw_get_atom_name@plt>
  mov    %rax,%r15
  xor    %eax,%eax
  call   <paw_sdir@plt>
  mov    %rbx,%r8
  mov    %r15,%rcx
  mov    %r14,%rdi
  mov    %rax,%rdx
  lea    D175(%rip),%rsi
  call   <sprintf@plt>
  mov    %r14,%rsi
  lea    D98(%rip),%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %r14,%rdi
  lea    D90(%rip),%r14
  call   <fopen@plt>
  mov    $0x16,%edx
  mov    $0x1,%esi
  lea    D29(%rip),%rdi
  mov    %rax,%r13
  mov    %rax,%rcx
  call   <fwrite@plt>
  mov    %r13,%rcx
  mov    %r14,%rdi
  mov    $0xd,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    %r13,%rcx
  mov    $0xf,%edx
  mov    $0x1,%esi
  lea    D94(%rip),%rdi
  call   <fwrite@plt>
  movsd  0x20(%rsp),%xmm0
  mov    %r13,%rdi
  movsd  0x88(%rsp),%xmm1
  lea    D156(%rip),%rsi
  mov    $0x2,%eax
  call   <fprintf@plt>
  mov    %r13,%rcx
  mov    $0xa,%edx
  mov    $0x1,%esi
  lea    D67(%rip),%rdi
  call   <fwrite@plt>
  mov    %r13,%rcx
  mov    %r14,%rdi
  mov    $0xd,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    %r13,%rcx
  mov    $0x1a,%edx
  mov    $0x1,%esi
  lea    D52(%rip),%rdi
  call   <fwrite@plt>
  movsd  0x28(%rsp),%xmm0
  mov    %r13,%rdi
  lea    D87(%rip),%rsi
  mov    $0x1,%eax
  call   <fprintf@plt>
  mov    %ebp,%edi
  call   <paw_spd_Name@plt>
  mov    %rax,%r14
  xor    %eax,%eax
  call   <paw_get_atom_name@plt>
  mov    %r14,%rcx
  mov    %r13,%rdi
  lea    D49(%rip),%rsi
  mov    %rax,%rdx
  xor    %eax,%eax
  call   <fprintf@plt>
  mov    %r12,%rdx
  mov    %r13,%rdi
  xor    %eax,%eax
  lea    D127(%rip),%rsi
  call   <fprintf@plt>
  mov    %r13,%rcx
  mov    $0x1a,%edx
  mov    $0x1,%esi
  lea    D64(%rip),%rdi
  call   <fwrite@plt>
  mov    %r13,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  mov    %r13,%rcx
  mov    $0x9,%edx
  mov    $0x1,%esi
  lea    D173(%rip),%rdi
  call   <fwrite@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  jmp    L5
  cs nopw 0x0(%rax,%rax,1)
L55:
  xor    %eax,%eax
  call   <paw_debug@plt>
  test   %rax,%rax
  je     L5
  mov    %ebp,%edi
  lea    0x90(%rsp),%r12
  call   <paw_spd_Name@plt>
  mov    %rax,%rbx
  xor    %eax,%eax
  call   <paw_get_atom_name@plt>
  mov    %rax,%r13
  xor    %eax,%eax
  call   <paw_sdir@plt>
  mov    %r13,%rcx
  mov    %rbx,%r8
  mov    %r12,%rdi
  mov    %rax,%rdx
  lea    D95(%rip),%rsi
  lea    D59(%rip),%r13
  call   <sprintf@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,%r15
  jmp    L73
L22:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D59
type_guessed: string
name: retrieve_data
arguments: data_label: D95
type_guessed: string
name: retrieve_data
arguments: data_label: D152
type_guessed: string
name: retrieve_data
arguments: data_label: D175
type_guessed: string
name: retrieve_data
arguments: data_label: D98
type_guessed: string
name: retrieve_data
arguments: data_label: D90
type_guessed: string
name: retrieve_data
arguments: data_label: D29
type_guessed: string
name: retrieve_data
arguments: data_label: D94
type_guessed: string
name: retrieve_data
arguments: data_label: D156
type_guessed: string
name: retrieve_data
arguments: data_label: D67
type_guessed: string
name: retrieve_data
arguments: data_label: D52
type_guessed: string
name: retrieve_data
arguments: data_label: D87
type_guessed: string
name: retrieve_data
arguments: data_label: D49
type_guessed: string
name: retrieve_data
arguments: data_label: D127
type_guessed: string
name: retrieve_data
arguments: data_label: D64
type_guessed: string
name: retrieve_data
arguments: data_label: D173
type_guessed: string

tool: D59: w+

tool: D95: %s%s_%s_scat_test.dat

tool: D152: %le	%le	%le


tool: D175: %s%s_%s_scat_test.plt

tool: D98: script_filename: %s


tool: D90: set nolabel 


tool: D29: set style data lines 


tool: D94: set autoscale 


tool: D156: set xr[%f:%f] 


tool: D67: set grid 


tool: D52: set xlabel "e (Hartree)" 


tool: D87: set ylabel "logarithmic derivative at r=%f" 


tool: D49: set title " %s %s channel scattering test


tool: D127: plot "%s" using 1:2 title "all electron",

tool: D64: "" using 1:3 title "paw" 


tool: D173: pause -1


assistant: ```c
void paw_scattering_test(double e1, double e2, int number_points, int l, double r) {
  int i;
  int k;
  int i_end_point;
  int Ngrid;
  double *rgrid;
  FILE *fp;
  double *V_ks;
  double *psi1;
  double *psi1_prime;
  double *psi;
  double *psi_prime;
  double *log_grid_ae;
  double *log_grid_paw;
  double de;
  double *e3;
  double e_test;
  double log_amesh;
  char data_filename[300];
  char script_filename[300];
  Ngrid = paw_N_LogGrid();
  rgrid = paw_r_LogGrid();
  log_amesh = paw_log_amesh_LogGrid();
  psi1 = paw_alloc_LogGrid();
  psi1_prime = paw_alloc_LogGrid();
  psi = paw_alloc_LogGrid();
  psi_prime = paw_alloc_LogGrid();
  log_grid_ae = paw_alloc_1d_array(number_points);
  log_grid_paw = paw_alloc_1d_array(number_points);
  e3 = paw_alloc_1d_array(number_points);
  de = (e2 - e1) / number_points;
  V_ks = paw_get_kohn_sham_potential();
  i_end_point = paw_get_grid_index(r);
  for (i = 0; i <= number_points - 1; i++) {
    e_test = e1 + de * i;
    e3[i] = e_test;
    paw_solve_paw_scattering(l, r, e_test, psi, psi_prime);
    paw_R_Schrodinger_Fixed_E(l, V_ks, i_end_point, e_test, psi1, psi1_prime);
    log_grid_ae[i] = psi1_prime[i_end_point - 1] / (psi1[i_end_point - 1] * rgrid[i_end_point - 1] * log_amesh);
    log_grid_paw[i] = psi_prime[i_end_point - 1] / (psi[i_end_point - 1] * rgrid[i_end_point - 1] * log_amesh);
  }
  if (paw_debug()) {
    sprintf(data_filename, "%s%s_%s_scat_test.dat", paw_sdir(), paw_get_atom_name(), paw_spd_Name(l));
    fp = fopen(data_filename, "w+");
    for (k = 0; k <= number_points - 1; k++) {
      fprintf(fp, "%le\t%le\t%le\n", e3[k], log_grid_ae[k], log_grid_paw[k]);
    }
    fclose(fp);
    sprintf(script_filename, "%s%s_%s_scat_test.plt", paw_sdir(), paw_get_atom_name(), paw_spd_Name(l));
    printf("script_filename: %s\n", script_filename);
    fp = fopen(script_filename, "w+");
    fprintf(fp, "set style data lines \n");
    fprintf(fp, "set nolabel \n");
    fprintf(fp, "set autoscale \n");
    fprintf(fp, "set xr[%f:%f] \n", e1, e2);
    fprintf(fp, "set grid \n");
    fprintf(fp, "set nolabel \n");
    fprintf(fp, "set xlabel \"e (Hartree)\" \n");
    fprintf(fp, "set ylabel \"logarithmic derivative at r=%f\" \n", r);
    fprintf(fp, "set title \" %s %s channel scattering test\n", paw_get_atom_name(), paw_spd_Name(l));
    fprintf(fp, "plot \"%s\" using 1:2 title \"all electron\",", data_filename);
    fprintf(fp, "\"\" using 1:3 title \"paw\" \n");
    fprintf(fp, "\n");
    fprintf(fp, "pause -1\n");
    fclose(fp);
  }
}
```