#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int paw_N_LogGrid();
int /*<<< orphan*/ paw_R_Schrodinger_Fixed_E(int, double *, int, double,
                                             double *, double *);
double *paw_alloc_1d_array(int);
double *paw_alloc_LogGrid();
scalar_t__ paw_debug();
char *paw_get_atom_name();
int paw_get_grid_index(double);
double *paw_get_kohn_sham_potential();
double paw_log_amesh_LogGrid();
double *paw_r_LogGrid();
char *paw_sdir();
int /*<<< orphan*/ paw_solve_paw_scattering(int, double, double, double *,
                                            double *);
char *paw_spd_Name(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
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);
  }
}


x86 assembly (clang, -O0):
<paw_scattering_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    $0x0,%al
call   1070 <paw_N_LogGrid@plt>
mov    %eax,-0x30(%rbp)
mov    $0x0,%al
call   10d0 <paw_r_LogGrid@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   10c0 <paw_log_amesh_LogGrid@plt>
movsd  %xmm0,-0x98(%rbp)
ff
mov    $0x0,%al
call   10e0 <paw_alloc_LogGrid@plt>
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   10e0 <paw_alloc_LogGrid@plt>
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   10e0 <paw_alloc_LogGrid@plt>
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   10e0 <paw_alloc_LogGrid@plt>
mov    %rax,-0x68(%rbp)
mov    -0x14(%rbp),%edi
call   10f0 <paw_alloc_1d_array@plt>
mov    %rax,-0x70(%rbp)
mov    -0x14(%rbp),%edi
call   10f0 <paw_alloc_1d_array@plt>
mov    %rax,-0x78(%rbp)
mov    -0x14(%rbp),%edi
call   10f0 <paw_alloc_1d_array@plt>
mov    %rax,-0x88(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    $0x0,%al
call   1140 <paw_get_kohn_sham_potential@plt>
mov    %rax,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   10b0 <paw_get_grid_index@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     141e <paw_scattering_test+0x1fe>
movsd  -0x8(%rbp),%xmm1
movsd  -0x80(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x88(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x90(%rbp),%xmm1
ff
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
call   1110 <paw_solve_paw_scattering@plt>
mov    -0x18(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x2c(%rbp),%edx
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x50(%rbp),%rcx
mov    -0x58(%rbp),%r8
call   1130 <paw_R_Schrodinger_Fixed_E@plt>
mov    -0x58(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x50(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  -0x98(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
mov    -0x70(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  -0x98(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
mov    -0x78(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12ee <paw_scattering_test+0xce>
mov    $0x0,%al
call   1090 <paw_debug@plt>
cmp    $0x0,%rax
je     16be <paw_scattering_test+0x49e>
lea    -0x1d0(%rbp),%rax
mov    %rax,-0x318(%rbp)
mov    $0x0,%al
call   1030 <paw_sdir@plt>
mov    %rax,-0x310(%rbp)
mov    $0x0,%al
call   1040 <paw_get_atom_name@plt>
mov    %rax,-0x308(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <paw_spd_Name@plt>
mov    -0x318(%rbp),%rdi
mov    -0x310(%rbp),%rdx
mov    -0x308(%rbp),%rcx
mov    %rax,%r8
lea    0xb80(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x1d0(%rbp),%rdi
lea    0xb83(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     14fe <paw_scattering_test+0x2de>
mov    -0x40(%rbp),%rdi
mov    -0x88(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x70(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x78(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
lea    0xb30(%rip),%rsi
mov    $0x3,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    14a3 <paw_scattering_test+0x283>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
lea    -0x300(%rbp),%rax
mov    %rax,-0x340(%rbp)
mov    $0x0,%al
call   1030 <paw_sdir@plt>
mov    %rax,-0x338(%rbp)
mov    $0x0,%al
call   1040 <paw_get_atom_name@plt>
mov    %rax,-0x330(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <paw_spd_Name@plt>
mov    -0x340(%rbp),%rdi
mov    -0x338(%rbp),%rdx
mov    -0x330(%rbp),%rcx
mov    %rax,%r8
lea    0xace(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x300(%rbp),%rsi
lea    0xad1(%rip),%rdi
call   1060 <printf@plt>
lea    -0x300(%rbp),%rdi
lea    0xa98(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xabf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xac4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xac0(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xab4(%rip),%rsi
mov    $0x2,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xab2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xa72(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xa99(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xa9d(%rip),%rsi
mov    $0x1,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x328(%rbp)
mov    $0x0,%al
call   1040 <paw_get_atom_name@plt>
mov    %rax,-0x320(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <paw_spd_Name@plt>
mov    -0x328(%rbp),%rdi
mov    -0x320(%rbp),%rdx
mov    %rax,%rcx
lea    0xa8b(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    -0x1d0(%rbp),%rdx
lea    0xa9d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xab5(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xa1e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
lea    0xaac(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<paw_scattering_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2f8,%rsp
movsd  %xmm2,0x20(%rsp)
mov    %esi,0xc(%rsp)
mov    %edi,%ebx
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1080 <paw_N_LogGrid@plt>
xor    %eax,%eax
call   10e0 <paw_r_LogGrid@plt>
mov    %rax,0x70(%rsp)
xor    %eax,%eax
call   10d0 <paw_log_amesh_LogGrid@plt>
movsd  %xmm0,0x80(%rsp)
xor    %eax,%eax
call   10f0 <paw_alloc_LogGrid@plt>
mov    %rax,0x68(%rsp)
xor    %eax,%eax
call   10f0 <paw_alloc_LogGrid@plt>
mov    %rax,0x78(%rsp)
xor    %eax,%eax
call   10f0 <paw_alloc_LogGrid@plt>
mov    %rax,%r13
xor    %eax,%eax
call   10f0 <paw_alloc_LogGrid@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1100 <paw_alloc_1d_array@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   1100 <paw_alloc_1d_array@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1100 <paw_alloc_1d_array@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1160 <paw_get_kohn_sham_potential@plt>
mov    %rax,0x60(%rsp)
movsd  0x20(%rsp),%xmm0
call   10c0 <paw_get_grid_index@plt>
mov    %eax,0x14(%rsp)
mov    %ebx,%edx
mov    %ebx,0x10(%rsp)
test   %ebx,%ebx
mov    %rbp,0x38(%rsp)
mov    %rdx,0x30(%rsp)
jle    1437 <paw_scattering_test+0x1f7>
mov    %r14,%rcx
movsd  0x28(%rsp),%xmm1
subsd  0x18(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x10(%rsp),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x50(%rsp)
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cltq
mov    %rax,0x48(%rsp)
xor    %ebx,%ebx
mov    %r13,0x40(%rsp)
mov    %r15,0x58(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  0x50(%rsp),%xmm1
addsd  0x18(%rsp),%xmm1
movsd  %xmm1,0x88(%rsp)
movsd  %xmm1,0x0(%rbp,%rbx,8)
mov    0xc(%rsp),%r14d
mov    %r14d,%edi
movsd  0x20(%rsp),%xmm0
mov    0x40(%rsp),%rsi
mov    %rcx,%r13
mov    %rcx,%rdx
call   1120 <paw_solve_paw_scattering@plt>
mov    %r14d,%edi
mov    0x70(%rsp),%r15
mov    %r12,%r14
mov    0x68(%rsp),%r12
mov    0x78(%rsp),%rbp
mov    0x60(%rsp),%rsi
mov    0x14(%rsp),%edx
movsd  0x88(%rsp),%xmm0
mov    %r12,%rcx
mov    %rbp,%r8
call   1150 <paw_R_Schrodinger_Fixed_E@plt>
mov    0x30(%rsp),%rdx
mov    %r13,%rcx
mov    0x40(%rsp),%r13
mov    0x48(%rsp),%rax
movsd  0x0(%rbp,%rax,8),%xmm0
movsd  (%r12,%rax,8),%xmm1
mov    %r14,%r12
mulsd  (%r15,%rax,8),%xmm1
movsd  0x80(%rsp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movsd  (%rcx,%rax,8),%xmm0
movsd  0x0(%r13,%rax,8),%xmm1
mulsd  (%r15,%rax,8),%xmm1
mov    0x38(%rsp),%rbp
mov    0x58(%rsp),%r15
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rdx
jne    1350 <paw_scattering_test+0x110>
mov    %r15,%r13
mov    0xc(%rsp),%r15d
xor    %eax,%eax
call   10a0 <paw_debug@plt>
test   %rax,%rax
je     1699 <paw_scattering_test+0x459>
xor    %eax,%eax
call   1030 <paw_sdir@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <paw_get_atom_name@plt>
mov    %rax,%rbp
mov    %r15d,%edi
call   1090 <paw_spd_Name@plt>
lea    0xb8e(%rip),%rsi
lea    0x90(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %rax,%r8
call   1130 <sprintf@plt>
lea    0xb84(%rip),%rsi
mov    %r14,%rdi
call   1110 <fopen@plt>
mov    %rax,%rbx
cmpl   $0x0,0x10(%rsp)
mov    0x38(%rsp),%r15
mov    0x30(%rsp),%r14
jle    14dd <paw_scattering_test+0x29d>
xor    %ebp,%ebp
movsd  (%r15,%rbp,8),%xmm0
movsd  (%r12,%rbp,8),%xmm1
movsd  0x0(%r13,%rbp,8),%xmm2
mov    %rbx,%rdi
lea    0xb4c(%rip),%rsi
mov    $0x3,%al
call   10b0 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    14b0 <paw_scattering_test+0x270>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
call   1030 <paw_sdir@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <paw_get_atom_name@plt>
mov    %rax,%rbp
mov    0xc(%rsp),%r15d
mov    %r15d,%edi
call   1090 <paw_spd_Name@plt>
lea    0xb19(%rip),%rsi
lea    0x1c0(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %rbp,%rcx
mov    %rax,%r8
call   1130 <sprintf@plt>
lea    0xb0f(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
lea    0xada(%rip),%rsi
mov    %r14,%rdi
call   1110 <fopen@plt>
mov    %rax,%rbx
lea    0xb03(%rip),%rdi
mov    $0x16,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1140 <fwrite@plt>
lea    0xb01(%rip),%rbp
mov    $0xd,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1140 <fwrite@plt>
lea    0xaf3(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1140 <fwrite@plt>
lea    0xaea(%rip),%rsi
mov    %rbx,%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mov    $0x2,%al
call   10b0 <fprintf@plt>
lea    0xadd(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1140 <fwrite@plt>
mov    $0xd,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1140 <fwrite@plt>
lea    0xaba(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1140 <fwrite@plt>
lea    0xabc(%rip),%rsi
mov    %rbx,%rdi
movsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   10b0 <fprintf@plt>
xor    %eax,%eax
call   1040 <paw_get_atom_name@plt>
mov    %rax,%rbp
mov    %r15d,%edi
call   1090 <paw_spd_Name@plt>
lea    0xac1(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xad5(%rip),%rsi
lea    0x90(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xae6(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1140 <fwrite@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
lea    0xadb(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1140 <fwrite@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x2f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"%s%s_%s_scat_test.dat\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [13 x i8] c"%le\09%le\09%le\0A\00"
@.str.3 = [22 x i8] c"%s%s_%s_scat_test.plt\00"
@.str.4 = [21 x i8] c"script_filename: %s\0A\00"
@.str.5 = [23 x i8] c"set style data lines \0A\00"
@.str.6 = [14 x i8] c"set nolabel \0A\00"
@.str.7 = [16 x i8] c"set autoscale \0A\00"
@.str.8 = [16 x i8] c"set xr[%f:%f] \0A\00"
@.str.9 = [11 x i8] c"set grid \0A\00"
@.str.10 = [27 x i8] c"set xlabel \22e (Hartree)\22 \0A\00"
@.str.11 = [46 x i8] c"set ylabel \22logarithmic derivative at r=%f\22 \0A\00"
@.str.12 = [43 x i8] c"set title \22 %s %s channel scattering test\0A\00"
@.str.13 = [42 x i8] c"plot \22%s\22 using 1:2 title \22all electron\22,\00"
@.str.14 = [27 x i8] c"\22\22 using 1:3 title \22paw\22 \0A\00"
@.str.15 = [2 x i8] c"\0A\00"
@.str.16 = [10 x i8] c"pause -1\0A\00"
define void @paw_scattering_test(double %0, double %1, i32 %2, i32 %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double*
%16 = alloca i32*
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double*
%23 = alloca double*
%24 = alloca double
%25 = alloca double*
%26 = alloca double
%27 = alloca double
%28 = alloca [300 x i8]
%29 = alloca [300 x i8]
store double %0, double* %6
store double %1, double* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store double %4, double* %10
%30 = call i32 (...) @paw_N_LogGrid()
store i32 %30, i32* %14
%31 = call double* (...) @paw_r_LogGrid()
store double* %31, double** %15
%32 = call double (...) @paw_log_amesh_LogGrid()
store double %32, double* %27
%33 = call double* (...) @paw_alloc_LogGrid()
store double* %33, double** %18
%34 = call double* (...) @paw_alloc_LogGrid()
store double* %34, double** %19
%35 = call double* (...) @paw_alloc_LogGrid()
store double* %35, double** %20
%36 = call double* (...) @paw_alloc_LogGrid()
store double* %36, double** %21
%37 = load i32, i32* %8
%38 = call double* @paw_alloc_1d_array(i32 %37)
store double* %38, double** %22
%39 = load i32, i32* %8
%40 = call double* @paw_alloc_1d_array(i32 %39)
store double* %40, double** %23
%41 = load i32, i32* %8
%42 = call double* @paw_alloc_1d_array(i32 %41)
store double* %42, double** %25
%43 = load double, double* %7
%44 = load double, double* %6
%45 = fsub double %43, %44
%46 = load i32, i32* %8
%47 = sitofp i32 %46 to double
%48 = fdiv double %45, %47
store double %48, double* %24
%49 = call double* (...) @paw_get_kohn_sham_potential()
store double* %49, double** %17
%50 = load double, double* %10
%51 = call i32 @paw_get_grid_index(double %50)
store i32 %51, i32* %13
store i32 0, i32* %11
br label %52
52: ; preds = %133, %5
%53 = load i32, i32* %11
%54 = load i32, i32* %8
%55 = sub nsw i32 %54, 1
%56 = icmp sle i32 %53, %55
br i1 %56, label %57, label %136
57: ; preds = %52
%58 = load double, double* %6
%59 = load double, double* %24
%60 = load i32, i32* %11
%61 = sitofp i32 %60 to double
%62 = call double @llvm.fmuladd.f64(double %59, double %61, double %58)
store double %62, double* %26
%63 = load double, double* %26
%64 = load double*, double** %25
%65 = load i32, i32* %11
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
store double %63, double* %67
%68 = load i32, i32* %9
%69 = load double, double* %10
%70 = load double, double* %26
%71 = load double*, double** %20
%72 = load double*, double** %21
%73 = call i32 @paw_solve_paw_scattering(i32 %68, double %69, double %70, double* %71, double* %72)
%74 = load i32, i32* %9
%75 = load double*, double** %17
%76 = load i32, i32* %13
%77 = load double, double* %26
%78 = load double*, double** %18
%79 = load double*, double** %19
%80 = call i32 @paw_R_Schrodinger_Fixed_E(i32 %74, double* %75, i32 %76, double %77, double* %78, double* %79)
%81 = load double*, double** %19
%82 = load i32, i32* %13
%83 = sub nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %81, i64 %84
%86 = load double, double* %85
%87 = load double*, double** %18
%88 = load i32, i32* %13
%89 = sub nsw i32 %88, 1
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %87, i64 %90
%92 = load double, double* %91
%93 = load double*, double** %15
%94 = load i32, i32* %13
%95 = sub nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %93, i64 %96
%98 = load double, double* %97
%99 = fmul double %92, %98
%100 = load double, double* %27
%101 = fmul double %99, %100
%102 = fdiv double %86, %101
%103 = load double*, double** %22
%104 = load i32, i32* %11
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds double, double* %103, i64 %105
store double %102, double* %106
%107 = load double*, double** %21
%108 = load i32, i32* %13
%109 = sub nsw i32 %108, 1
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds double, double* %107, i64 %110
%112 = load double, double* %111
%113 = load double*, double** %20
%114 = load i32, i32* %13
%115 = sub nsw i32 %114, 1
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %113, i64 %116
%118 = load double, double* %117
%119 = load double*, double** %15
%120 = load i32, i32* %13
%121 = sub nsw i32 %120, 1
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %119, i64 %122
%124 = load double, double* %123
%125 = fmul double %118, %124
%126 = load double, double* %27
%127 = fmul double %125, %126
%128 = fdiv double %112, %127
%129 = load double*, double** %23
%130 = load i32, i32* %11
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds double, double* %129, i64 %131
store double %128, double* %132
br label %133
133: ; preds = %57
%134 = load i32, i32* %11
%135 = add nsw i32 %134, 1
store i32 %135, i32* %11
br label %52
136: ; preds = %52
%137 = call i64 (...) @paw_debug()
%138 = icmp ne i64 %137, 0
br i1 %138, label %139, label %222
139: ; preds = %136
%140 = getelementptr inbounds [300 x i8], [300 x i8]* %28, i64 0, i64 0
%141 = call i8* (...) @paw_sdir()
%142 = call i8* (...) @paw_get_atom_name()
%143 = load i32, i32* %9
%144 = call i8* @paw_spd_Name(i32 %143)
%145 = call i32 @sprintf(i8* %140, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %141, i8* %142, i8* %144)
%146 = getelementptr inbounds [300 x i8], [300 x i8]* %28, i64 0, i64 0
%147 = call i32* @fopen(i8* %146, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %147, i32** %16
store i32 0, i32* %12
br label %148
148: ; preds = %171, %139
%149 = load i32, i32* %12
%150 = load i32, i32* %8
%151 = sub nsw i32 %150, 1
%152 = icmp sle i32 %149, %151
br i1 %152, label %153, label %174
153: ; preds = %148
%154 = load i32*, i32** %16
%155 = load double*, double** %25
%156 = load i32, i32* %12
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds double, double* %155, i64 %157
%159 = load double, double* %158
%160 = load double*, double** %22
%161 = load i32, i32* %12
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds double, double* %160, i64 %162
%164 = load double, double* %163
%165 = load double*, double** %23
%166 = load i32, i32* %12
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %165, i64 %167
%169 = load double, double* %168
%170 = call i32 (i32*, i8*, ...) @fprintf(i32* %154, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %159, double %164, double %169)
br label %171
171: ; preds = %153
%172 = load i32, i32* %12
%173 = add nsw i32 %172, 1
store i32 %173, i32* %12
br label %148
174: ; preds = %148
%175 = load i32*, i32** %16
%176 = call i32 @fclose(i32* %175)
%177 = getelementptr inbounds [300 x i8], [300 x i8]* %29, i64 0, i64 0
%178 = call i8* (...) @paw_sdir()
%179 = call i8* (...) @paw_get_atom_name()
%180 = load i32, i32* %9
%181 = call i8* @paw_spd_Name(i32 %180)
%182 = call i32 @sprintf(i8* %177, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %178, i8* %179, i8* %181)
%183 = getelementptr inbounds [300 x i8], [300 x i8]* %29, i64 0, i64 0
%184 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %183)
%185 = getelementptr inbounds [300 x i8], [300 x i8]* %29, i64 0, i64 0
%186 = call i32* @fopen(i8* %185, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %186, i32** %16
%187 = load i32*, i32** %16
%188 = call i32 (i32*, i8*, ...) @fprintf(i32* %187, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%189 = load i32*, i32** %16
%190 = call i32 (i32*, i8*, ...) @fprintf(i32* %189, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%191 = load i32*, i32** %16
%192 = call i32 (i32*, i8*, ...) @fprintf(i32* %191, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%193 = load i32*, i32** %16
%194 = load double, double* %6
%195 = load double, double* %7
%196 = call i32 (i32*, i8*, ...) @fprintf(i32* %193, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double %194, double %195)
%197 = load i32*, i32** %16
%198 = call i32 (i32*, i8*, ...) @fprintf(i32* %197, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%199 = load i32*, i32** %16
%200 = call i32 (i32*, i8*, ...) @fprintf(i32* %199, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%201 = load i32*, i32** %16
%202 = call i32 (i32*, i8*, ...) @fprintf(i32* %201, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%203 = load i32*, i32** %16
%204 = load double, double* %10
%205 = call i32 (i32*, i8*, ...) @fprintf(i32* %203, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0), double %204)
%206 = load i32*, i32** %16
%207 = call i8* (...) @paw_get_atom_name()
%208 = load i32, i32* %9
%209 = call i8* @paw_spd_Name(i32 %208)
%210 = call i32 (i32*, i8*, ...) @fprintf(i32* %206, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i8* %207, i8* %209)
%211 = load i32*, i32** %16
%212 = getelementptr inbounds [300 x i8], [300 x i8]* %28, i64 0, i64 0
%213 = call i32 (i32*, i8*, ...) @fprintf(i32* %211, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.13, i64 0, i64 0), i8* %212)
%214 = load i32*, i32** %16
%215 = call i32 (i32*, i8*, ...) @fprintf(i32* %214, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0))
%216 = load i32*, i32** %16
%217 = call i32 (i32*, i8*, ...) @fprintf(i32* %216, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%218 = load i32*, i32** %16
%219 = call i32 (i32*, i8*, ...) @fprintf(i32* %218, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
%220 = load i32*, i32** %16
%221 = call i32 @fclose(i32* %220)
br label %222
222: ; preds = %174, %136
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"%s%s_%s_scat_test.dat\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [13 x i8] c"%le\09%le\09%le\0A\00"
@.str.3 = [22 x i8] c"%s%s_%s_scat_test.plt\00"
@.str.4 = [21 x i8] c"script_filename: %s\0A\00"
@.str.5 = [23 x i8] c"set style data lines \0A\00"
@.str.6 = [14 x i8] c"set nolabel \0A\00"
@.str.7 = [16 x i8] c"set autoscale \0A\00"
@.str.8 = [16 x i8] c"set xr[%f:%f] \0A\00"
@.str.9 = [11 x i8] c"set grid \0A\00"
@.str.10 = [27 x i8] c"set xlabel \22e (Hartree)\22 \0A\00"
@.str.11 = [46 x i8] c"set ylabel \22logarithmic derivative at r=%f\22 \0A\00"
@.str.12 = [43 x i8] c"set title \22 %s %s channel scattering test\0A\00"
@.str.13 = [42 x i8] c"plot \22%s\22 using 1:2 title \22all electron\22,\00"
@.str.14 = [27 x i8] c"\22\22 using 1:3 title \22paw\22 \0A\00"
@.str.16 = [10 x i8] c"pause -1\0A\00"
define void @paw_scattering_test(double %0, double %1, i32 %2, i32 %3, double %4) {
%6 = alloca [300 x i8]
%7 = alloca [300 x i8]
%8 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%10 = tail call i32 (...) @paw_N_LogGrid()
%11 = tail call double* (...) @paw_r_LogGrid()
%12 = tail call double (...) @paw_log_amesh_LogGrid()
%13 = tail call double* (...) @paw_alloc_LogGrid()
%14 = tail call double* (...) @paw_alloc_LogGrid()
%15 = tail call double* (...) @paw_alloc_LogGrid()
%16 = tail call double* (...) @paw_alloc_LogGrid()
%17 = tail call double* @paw_alloc_1d_array(i32 %2)
%18 = tail call double* @paw_alloc_1d_array(i32 %2)
%19 = tail call double* @paw_alloc_1d_array(i32 %2)
%20 = fsub double %1, %0
%21 = sitofp i32 %2 to double
%22 = fdiv double %20, %21
%23 = tail call double* (...) @paw_get_kohn_sham_potential()
%24 = tail call i32 @paw_get_grid_index(double %4)
%25 = icmp sgt i32 %2, 0
br i1 %25, label %26, label %59
26: ; preds = %5
%27 = add nsw i32 %24, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %14, i64 %28
%30 = getelementptr inbounds double, double* %13, i64 %28
%31 = getelementptr inbounds double, double* %11, i64 %28
%32 = getelementptr inbounds double, double* %16, i64 %28
%33 = getelementptr inbounds double, double* %15, i64 %28
%34 = zext i32 %2 to i64
br label %35
35: ; preds = %26, %35
%36 = phi i64 [ 0, %26 ], [ %57, %35 ]
%37 = trunc i64 %36 to i32
%38 = sitofp i32 %37 to double
%39 = tail call double @llvm.fmuladd.f64(double %22, double %38, double %0)
%40 = getelementptr inbounds double, double* %19, i64 %36
store double %39, double* %40
%41 = tail call i32 @paw_solve_paw_scattering(i32 %3, double %4, double %39, double* %15, double* %16)
%42 = tail call i32 @paw_R_Schrodinger_Fixed_E(i32 %3, double* %23, i32 %24, double %39, double* %13, double* %14)
%43 = load double, double* %29
%44 = load double, double* %30
%45 = load double, double* %31
%46 = fmul double %44, %45
%47 = fmul double %12, %46
%48 = fdiv double %43, %47
%49 = getelementptr inbounds double, double* %17, i64 %36
store double %48, double* %49
%50 = load double, double* %32
%51 = load double, double* %33
%52 = load double, double* %31
%53 = fmul double %51, %52
%54 = fmul double %12, %53
%55 = fdiv double %50, %54
%56 = getelementptr inbounds double, double* %18, i64 %36
store double %55, double* %56
%57 = add nuw nsw i64 %36, 1
%58 = icmp eq i64 %57, %34
br i1 %58, label %59, label %35
59: ; preds = %35, %5
%60 = tail call i64 (...) @paw_debug()
%61 = icmp eq i64 %60, 0
br i1 %61, label %105, label %62
62: ; preds = %59
%63 = tail call i8* (...) @paw_sdir()
%64 = tail call i8* (...) @paw_get_atom_name()
%65 = tail call i8* @paw_spd_Name(i32 %3)
%66 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %63, i8* %64, i8* %65)
%67 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br i1 %25, label %68, label %81
68: ; preds = %62
%69 = zext i32 %2 to i64
br label %70
70: ; preds = %68, %70
%71 = phi i64 [ 0, %68 ], [ %79, %70 ]
%72 = getelementptr inbounds double, double* %19, i64 %71
%73 = load double, double* %72
%74 = getelementptr inbounds double, double* %17, i64 %71
%75 = load double, double* %74
%76 = getelementptr inbounds double, double* %18, i64 %71
%77 = load double, double* %76
%78 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double %73, double %75, double %77)
%79 = add nuw nsw i64 %71, 1
%80 = icmp eq i64 %79, %69
br i1 %80, label %81, label %70
81: ; preds = %70, %62
%82 = tail call i32 @fclose(i32* %67)
%83 = tail call i8* (...) @paw_sdir()
%84 = tail call i8* (...) @paw_get_atom_name()
%85 = tail call i8* @paw_spd_Name(i32 %3)
%86 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %83, i8* %84, i8* %85)
%87 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%88 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%89 = call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i64 22, i64 1, i32* %88)
%90 = call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i64 13, i64 1, i32* %88)
%91 = call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i64 15, i64 1, i32* %88)
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double %0, double %1)
%93 = call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i64 10, i64 1, i32* %88)
%94 = call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i64 13, i64 1, i32* %88)
%95 = call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i64 26, i64 1, i32* %88)
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0), double %4)
%97 = call i8* (...) @paw_get_atom_name()
%98 = call i8* @paw_spd_Name(i32 %3)
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0), i8* %97, i8* %98)
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.13, i64 0, i64 0), i8* %8)
%101 = call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), i64 26, i64 1, i32* %88)
%102 = call i32 @fputc(i32 10, i32* %88)
%103 = call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i64 9, i64 1, i32* %88)
%104 = call i32 @fclose(i32* %88)
br label %105
105: ; preds = %81, %59
ret void
}