#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 */

/* Variables and functions */
int /*<<< orphan*/ coulomb_frame_parameters(double, double, double, double,
                                            double *, double *);
double coulomb_normalisation(double, double, double, double, double);
int /*<<< orphan*/ coulomb_pole_reduction(int, double *, double *,
                                          long double *, long double *,
                                          long double *);
int /*<<< orphan*/ coulomb_screening_parameters(double, double, double, double,
                                                double, int *, double *,
                                                double *);
double coulomb_spin_factor(double, double);
int /*<<< orphan*/ coulomb_transport_coefficients(int, double const, int,
                                                  double *, long double *,
                                                  long double *, long double *,
                                                  double *);
double pumas_elastic_path(int order, double Z, double A, double mass,
                          double kinetic) {
  if ((order < 0) || (order > 1) || (kinetic <= 0.))
    return 0.;
  int n_parameters;
  double kinetic0, amplitude[3], screening[4], coefficient[2], fCM[2];
  coulomb_frame_parameters(Z, A, mass, kinetic, &kinetic0, fCM);
  coulomb_screening_parameters(Z, A, mass, kinetic, kinetic0, &n_parameters,
                               amplitude, screening);
  const double fspin = coulomb_spin_factor(mass, kinetic);
  long double a[3], b[3], c[4];
  coulomb_pole_reduction(n_parameters, amplitude, screening, a, b, c);
  coulomb_transport_coefficients(1., fspin, n_parameters, screening, a, b, c,
                                 coefficient);
  if (order == 1) {
    const double d = 1. / (fCM[0] * (1. + fCM[1]));
    coefficient[order] *= d * d;
  }
  return coulomb_normalisation(Z, A, mass, kinetic, kinetic0) /
         coefficient[order];
}


x86 assembly (clang, -O0):
<pumas_elastic_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11a4 <pumas_elastic_path+0x44>
cmpl   $0x1,-0xc(%rbp)
jg     11a4 <pumas_elastic_path+0x44>
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     11b1 <pumas_elastic_path+0x51>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1304 <pumas_elastic_path+0x1a4>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    -0xa0(%rbp),%rsi
lea    -0x40(%rbp),%rdi
call   1070 <coulomb_frame_parameters@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    -0x34(%rbp),%rdi
call   1040 <coulomb_screening_parameters@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1050 <coulomb_spin_factor@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x34(%rbp),%edi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
lea    -0xe0(%rbp),%rcx
lea    -0x110(%rbp),%r8
lea    -0x150(%rbp),%r9
call   1030 <coulomb_pole_reduction@plt>
movsd  -0xa8(%rbp),%xmm0
ff
mov    -0x34(%rbp),%esi
lea    -0x80(%rbp),%rdx
lea    -0xe0(%rbp),%rcx
lea    -0x110(%rbp),%r8
lea    -0x150(%rbp),%r9
lea    -0x90(%rbp),%rax
mov    $0x1,%edi
mov    %rax,(%rsp)
call   1060 <coulomb_transport_coefficients@plt>
cmpl   $0x1,-0xc(%rbp)
jne    12d4 <pumas_elastic_path+0x174>
movsd  -0xa0(%rbp),%xmm1
ff
movsd  0xd72(%rip),%xmm0
addsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm0,%xmm1
movsd  0xd5e(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x158(%rbp)
ff
movsd  -0x158(%rbp),%xmm0
ff
mulsd  -0x158(%rbp),%xmm0
ff
movslq -0xc(%rbp),%rax
mulsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x90(%rbp,%rax,8)
ff ff
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
call   1080 <coulomb_normalisation@plt>
movslq -0xc(%rbp),%rax
divsd  -0x90(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pumas_elastic_path>:
movapd %xmm0,%xmm5
xorpd  %xmm0,%xmm0
cmp    $0x1,%edi
ja     12d5 <pumas_elastic_path+0x175>
xorpd  %xmm4,%xmm4
ucomisd %xmm3,%xmm4
jae    12d5 <pumas_elastic_path+0x175>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    %edi,%ebx
lea    0x38(%rsp),%rdi
lea    0x60(%rsp),%rsi
movapd %xmm5,%xmm0
movsd  %xmm2,0x18(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm5,0x28(%rsp)
call   1070 <coulomb_frame_parameters@plt>
movsd  0x38(%rsp),%xmm4
lea    0x14(%rsp),%rdi
lea    0x70(%rsp),%r15
lea    0x90(%rsp),%r14
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <coulomb_screening_parameters@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1050 <coulomb_spin_factor@plt>
movsd  %xmm0,0x58(%rsp)
mov    0x14(%rsp),%edi
lea    0xe0(%rsp),%r12
lea    0xb0(%rsp),%r13
lea    0x110(%rsp),%rbp
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbp,%r9
call   1030 <coulomb_pole_reduction@plt>
mov    0x14(%rsp),%esi
lea    0x40(%rsp),%rax
mov    %rax,(%rsp)
mov    $0x1,%edi
movsd  0x58(%rsp),%xmm0
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbp,%r9
call   1060 <coulomb_transport_coefficients@plt>
cmp    $0x1,%ebx
jne    1299 <pumas_elastic_path+0x139>
movsd  0xd8b(%rip),%xmm0
movsd  0x68(%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x60(%rsp),%xmm1
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
mulsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x48(%rsp)
movsd  0x38(%rsp),%xmm4
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
call   1080 <coulomb_normalisation@plt>
mov    %ebx,%eax
divsd  0x40(%rsp,%rax,8),%xmm0
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @pumas_elastic_path(i32 %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca double
%14 = alloca [3 x double]
%15 = alloca [4 x double]
%16 = alloca [2 x double]
%17 = alloca [2 x double]
%18 = alloca double
%19 = alloca [3 x x86_fp80]
%20 = alloca [3 x x86_fp80]
%21 = alloca [4 x x86_fp80]
%22 = alloca double
store i32 %0, i32* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %5
%26 = load i32, i32* %7
%27 = icmp sgt i32 %26, 1
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load double, double* %11
%30 = fcmp ole double %29, 0.000000e+00
br i1 %30, label %31, label %32
31: ; preds = %28, %25, %5
store double 0.000000e+00, double* %6
br label %95
32: ; preds = %28
%33 = load double, double* %8
%34 = load double, double* %9
%35 = load double, double* %10
%36 = load double, double* %11
%37 = getelementptr inbounds [2 x double], [2 x double]* %17, i64 0, i64 0
%38 = call i32 @coulomb_frame_parameters(double %33, double %34, double %35, double %36, double* %13, double* %37)
%39 = load double, double* %8
%40 = load double, double* %9
%41 = load double, double* %10
%42 = load double, double* %11
%43 = load double, double* %13
%44 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%45 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 0
%46 = call i32 @coulomb_screening_parameters(double %39, double %40, double %41, double %42, double %43, i32* %12, double* %44, double* %45)
%47 = load double, double* %10
%48 = load double, double* %11
%49 = call double @coulomb_spin_factor(double %47, double %48)
store double %49, double* %18
%50 = load i32, i32* %12
%51 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%52 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 0
%53 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %19, i64 0, i64 0
%54 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %20, i64 0, i64 0
%55 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %21, i64 0, i64 0
%56 = call i32 @coulomb_pole_reduction(i32 %50, double* %51, double* %52, x86_fp80* %53, x86_fp80* %54, x86_fp80* %55)
%57 = load double, double* %18
%58 = load i32, i32* %12
%59 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 0
%60 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %19, i64 0, i64 0
%61 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %20, i64 0, i64 0
%62 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %21, i64 0, i64 0
%63 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 0
%64 = call i32 @coulomb_transport_coefficients(i32 1, double %57, i32 %58, double* %59, x86_fp80* %60, x86_fp80* %61, x86_fp80* %62, double* %63)
%65 = load i32, i32* %7
%66 = icmp eq i32 %65, 1
br i1 %66, label %67, label %83
67: ; preds = %32
%68 = getelementptr inbounds [2 x double], [2 x double]* %17, i64 0, i64 0
%69 = load double, double* %68
%70 = getelementptr inbounds [2 x double], [2 x double]* %17, i64 0, i64 1
%71 = load double, double* %70
%72 = fadd double 1.000000e+00, %71
%73 = fmul double %69, %72
%74 = fdiv double 1.000000e+00, %73
store double %74, double* %22
%75 = load double, double* %22
%76 = load double, double* %22
%77 = fmul double %75, %76
%78 = load i32, i32* %7
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 %79
%81 = load double, double* %80
%82 = fmul double %81, %77
store double %82, double* %80
br label %83
83: ; preds = %67, %32
%84 = load double, double* %8
%85 = load double, double* %9
%86 = load double, double* %10
%87 = load double, double* %11
%88 = load double, double* %13
%89 = call double @coulomb_normalisation(double %84, double %85, double %86, double %87, double %88)
%90 = load i32, i32* %7
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [2 x double], [2 x double]* %16, i64 0, i64 %91
%93 = load double, double* %92
%94 = fdiv double %89, %93
store double %94, double* %6
br label %95
95: ; preds = %83, %31
%96 = load double, double* %6
ret double %96
}

LLVM IR (-O2):
define double @pumas_elastic_path(i32 %0, double %1, double %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca [3 x double]
%9 = alloca [4 x double]
%10 = alloca [2 x double]
%11 = alloca [2 x double]
%12 = alloca [3 x x86_fp80]
%13 = alloca [3 x x86_fp80]
%14 = alloca [4 x x86_fp80]
%15 = icmp ugt i32 %0, 1
%16 = fcmp ole double %4, 0.000000e+00
%17 = or i1 %15, %16
br i1 %17, label %62, label %18
18: ; preds = %5
%19 = bitcast i32* %6 to i8*
%20 = bitcast double* %7 to i8*
%21 = bitcast [3 x double]* %8 to i8*
%22 = bitcast [4 x double]* %9 to i8*
%23 = bitcast [2 x double]* %10 to i8*
%24 = bitcast [2 x double]* %11 to i8*
%25 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 0
%26 = call i32 @coulomb_frame_parameters(double %1, double %2, double %3, double %4, double* %7, double* %25)
%27 = load double, double* %7
%28 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%29 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 0
%30 = call i32 @coulomb_screening_parameters(double %1, double %2, double %3, double %4, double %27, i32* %6, double* %28, double* %29)
%31 = call double @coulomb_spin_factor(double %3, double %4)
%32 = bitcast [3 x x86_fp80]* %12 to i8*
%33 = bitcast [3 x x86_fp80]* %13 to i8*
%34 = bitcast [4 x x86_fp80]* %14 to i8*
%35 = load i32, i32* %6
%36 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %12, i64 0, i64 0
%37 = getelementptr inbounds [3 x x86_fp80], [3 x x86_fp80]* %13, i64 0, i64 0
%38 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %14, i64 0, i64 0
%39 = call i32 @coulomb_pole_reduction(i32 %35, double* %28, double* %29, x86_fp80* %36, x86_fp80* %37, x86_fp80* %38)
%40 = load i32, i32* %6
%41 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%42 = call i32 @coulomb_transport_coefficients(i32 1, double %31, i32 %40, double* %29, x86_fp80* %36, x86_fp80* %37, x86_fp80* %38, double* %41)
%43 = icmp eq i32 %0, 1
br i1 %43, label %44, label %55
44: ; preds = %18
%45 = load double, double* %25
%46 = getelementptr inbounds [2 x double], [2 x double]* %11, i64 0, i64 1
%47 = load double, double* %46
%48 = fadd double %47, 1.000000e+00
%49 = fmul double %45, %48
%50 = fdiv double 1.000000e+00, %49
%51 = fmul double %50, %50
%52 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 1
%53 = load double, double* %52
%54 = fmul double %53, %51
store double %54, double* %52
br label %55
55: ; preds = %44, %18
%56 = load double, double* %7
%57 = call double @coulomb_normalisation(double %1, double %2, double %3, double %4, double %56)
%58 = zext i32 %0 to i64
%59 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 %58
%60 = load double, double* %59
%61 = fdiv double %57, %60
br label %62
62: ; preds = %5, %55
%63 = phi double [ %61, %55 ], [ 0.000000e+00, %5 ]
ret double %63
}