#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 */
struct atomic_shell {
  int dummy;
};

/* Variables and functions */
double electronic_density_effect(int, struct atomic_shell *, double const);
int log(int);
double electronic_energy_loss(double ZoA, double I, int n_shells,
                              struct atomic_shell *shells, double mass,
                              double kinetic, double *delta_ptr) {
  const double E = kinetic + mass;
  const double P2 = kinetic * (kinetic + 2. * mass);
  const double beta2 = P2 / (E * E);
  const double gamma = E / mass;
  const double r = 0.510998910E-03 / mass;
  const double Qmax = 2. * r * P2 / (mass * (1. + r * r) + 2. * r * E);
  const double lQ = log(1. + 2. * Qmax / 0.510998910E-03);
  const double Delta = 7.2973525693E-03 / (2 * 3.14159265358979323846) *
                       (log(2. * gamma) - lQ / 3.) * lQ * lQ;
  const double delta = electronic_density_effect(n_shells, shells, gamma);
  if (delta_ptr != NULL)
    *delta_ptr = delta;
  return 2 * 3.14159265358979323846 * 2.817940285E-15 * 2.817940285E-15 *
         0.510998910E-03 * 6.02214076E+23 * ZoA / (beta2 * 1E-03) *
         (log(2. * 0.510998910E-03 * beta2 * gamma * gamma * Qmax / (I * I)) -
          2 * beta2 - delta + 0.25 * Qmax * Qmax / (E * E) + Delta);
}


x86 assembly (clang, -O0):
<electronic_energy_loss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe78(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe56(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm2,%xmm3
movsd  0xe39(%rip),%xmm2
addsd  %xmm2,%xmm3
movsd  0xe25(%rip),%xmm2
mulsd  -0x60(%rbp),%xmm2
mulsd  -0x40(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe02(%rip),%xmm1
mulsd  -0x68(%rbp),%xmm1
movsd  0xe05(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdf1(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xdcb(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
cvtsi2sd %eax,%xmm1
movsd  -0x70(%rbp),%xmm0
movsd  0xda4(%rip),%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
movsd  0xd8c(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x70(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
movsd  -0x58(%rbp),%xmm0
call   1030 <electronic_density_effect@plt>
movsd  %xmm0,-0x80(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     12b5 <electronic_energy_loss+0x195>
movsd  -0x80(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd83(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xd6e(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xd4d(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
movsd  -0x88(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
movsd  -0x50(%rbp),%xmm2
addsd  %xmm2,%xmm2
subsd  %xmm2,%xmm1
subsd  -0x80(%rbp),%xmm1
movsd  0xcf4(%rip),%xmm2
mulsd  -0x68(%rbp),%xmm2
mulsd  -0x68(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
mulsd  -0x40(%rbp),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
addsd  -0x78(%rbp),%xmm1
mulsd  %xmm1,%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<electronic_energy_loss>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r15d
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x18(%rsp)
movapd %xmm2,%xmm0
addsd  %xmm3,%xmm0
movapd %xmm0,%xmm6
movsd  0xeac(%rip),%xmm8
movapd %xmm8,%xmm1
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm4
addsd  %xmm1,%xmm4
movapd %xmm4,%xmm7
mulsd  %xmm1,%xmm1
movsd  0xe93(%rip),%xmm5
addsd  %xmm5,%xmm1
mulsd  %xmm0,%xmm4
divsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
mulsd  %xmm2,%xmm1
addsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm3,%xmm2
mulsd  %xmm6,%xmm6
mulsd  %xmm2,%xmm7
movsd  %xmm6,0x40(%rsp)
divsd  %xmm6,%xmm2
movsd  %xmm2,0x20(%rsp)
addsd  %xmm4,%xmm1
divsd  %xmm1,%xmm7
movsd  %xmm7,0x28(%rsp)
movapd %xmm7,%xmm1
addsd  %xmm7,%xmm1
divsd  %xmm8,%xmm1
addsd  %xmm5,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
mov    %eax,%ebp
mov    %r15d,%edi
mov    %r14,%rsi
movsd  0x10(%rsp),%xmm0
call   1030 <electronic_density_effect@plt>
test   %rbx,%rbx
je     1213 <electronic_energy_loss+0xf3>
movsd  %xmm0,(%rbx)
movsd  %xmm0,0x30(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm1
divsd  0xdde(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xdda(%rip),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm1
mulsd  0xdc6(%rip),%xmm1
movsd  0xdc6(%rip),%xmm0
movsd  0x20(%rsp),%xmm2
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0xdb2(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0x28(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
mulsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x20(%rsp),%xmm0
addsd  %xmm0,%xmm0
subsd  %xmm0,%xmm1
subsd  0x30(%rsp),%xmm1
movsd  0xd68(%rip),%xmm0
movsd  0x28(%rsp),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
divsd  0x40(%rsp),%xmm0
addsd  %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.atomic_shell = type { i32 }
define double @electronic_energy_loss(double %0, double %1, i32 %2, %struct.atomic_shell* %3, double %4, double %5, double* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca %struct.atomic_shell*
%12 = alloca double
%13 = alloca double
%14 = alloca double*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store double %0, double* %8
store double %1, double* %9
store i32 %2, i32* %10
store %struct.atomic_shell* %3, %struct.atomic_shell** %11
store double %4, double* %12
store double %5, double* %13
store double* %6, double** %14
%24 = load double, double* %13
%25 = load double, double* %12
%26 = fadd double %24, %25
store double %26, double* %15
%27 = load double, double* %13
%28 = load double, double* %13
%29 = load double, double* %12
%30 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %29, double %28)
%31 = fmul double %27, %30
store double %31, double* %16
%32 = load double, double* %16
%33 = load double, double* %15
%34 = load double, double* %15
%35 = fmul double %33, %34
%36 = fdiv double %32, %35
store double %36, double* %17
%37 = load double, double* %15
%38 = load double, double* %12
%39 = fdiv double %37, %38
store double %39, double* %18
%40 = load double, double* %12
%41 = fdiv double 0x3F40BE91CDA9B5D6, %40
store double %41, double* %19
%42 = load double, double* %19
%43 = fmul double 2.000000e+00, %42
%44 = load double, double* %16
%45 = fmul double %43, %44
%46 = load double, double* %12
%47 = load double, double* %19
%48 = load double, double* %19
%49 = call double @llvm.fmuladd.f64(double %47, double %48, double 1.000000e+00)
%50 = load double, double* %19
%51 = fmul double 2.000000e+00, %50
%52 = load double, double* %15
%53 = fmul double %51, %52
%54 = call double @llvm.fmuladd.f64(double %46, double %49, double %53)
%55 = fdiv double %45, %54
store double %55, double* %20
%56 = load double, double* %20
%57 = fmul double 2.000000e+00, %56
%58 = fdiv double %57, 0x3F40BE91CDA9B5D6
%59 = fadd double 1.000000e+00, %58
%60 = fptosi double %59 to i32
%61 = call i32 @log(i32 %60)
%62 = sitofp i32 %61 to double
store double %62, double* %21
%63 = load double, double* %18
%64 = fmul double 2.000000e+00, %63
%65 = fptosi double %64 to i32
%66 = call i32 @log(i32 %65)
%67 = sitofp i32 %66 to double
%68 = load double, double* %21
%69 = fdiv double %68, 3.000000e+00
%70 = fsub double %67, %69
%71 = fmul double 0x3F53074E347B1358, %70
%72 = load double, double* %21
%73 = fmul double %71, %72
%74 = load double, double* %21
%75 = fmul double %73, %74
store double %75, double* %22
%76 = load i32, i32* %10
%77 = load %struct.atomic_shell*, %struct.atomic_shell** %11
%78 = load double, double* %18
%79 = call double @electronic_density_effect(i32 %76, %struct.atomic_shell* %77, double %78)
store double %79, double* %23
%80 = load double*, double** %14
%81 = icmp ne double* %80, null
br i1 %81, label %82, label %85
82: ; preds = %7
%83 = load double, double* %23
%84 = load double*, double** %14
store double %83, double* %84
br label %85
85: ; preds = %82, %7
%86 = load double, double* %8
%87 = fmul double 0x3E507C67BC49A9D3, %86
%88 = load double, double* %17
%89 = fmul double %88, 1.000000e-03
%90 = fdiv double %87, %89
%91 = load double, double* %17
%92 = fmul double 0x3F50BE91CDA9B5D6, %91
%93 = load double, double* %18
%94 = fmul double %92, %93
%95 = load double, double* %18
%96 = fmul double %94, %95
%97 = load double, double* %20
%98 = fmul double %96, %97
%99 = load double, double* %9
%100 = load double, double* %9
%101 = fmul double %99, %100
%102 = fdiv double %98, %101
%103 = fptosi double %102 to i32
%104 = call i32 @log(i32 %103)
%105 = sitofp i32 %104 to double
%106 = load double, double* %17
%107 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %106, double %105)
%108 = load double, double* %23
%109 = fsub double %107, %108
%110 = load double, double* %20
%111 = fmul double 2.500000e-01, %110
%112 = load double, double* %20
%113 = fmul double %111, %112
%114 = load double, double* %15
%115 = load double, double* %15
%116 = fmul double %114, %115
%117 = fdiv double %113, %116
%118 = fadd double %109, %117
%119 = load double, double* %22
%120 = fadd double %118, %119
%121 = fmul double %90, %120
ret double %121
}

LLVM IR (-O2):
%struct.atomic_shell = type { i32 }
define double @electronic_energy_loss(double %0, double %1, i32 %2, %struct.atomic_shell* %3, double %4, double %5, double* writeonly %6) {
%8 = fadd double %4, %5
%9 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double %5)
%10 = fmul double %9, %5
%11 = fmul double %8, %8
%12 = fdiv double %10, %11
%13 = fdiv double %8, %4
%14 = fdiv double 0x3F40BE91CDA9B5D6, %4
%15 = fmul double %14, 2.000000e+00
%16 = fmul double %15, %10
%17 = tail call double @llvm.fmuladd.f64(double %14, double %14, double 1.000000e+00)
%18 = fmul double %15, %8
%19 = tail call double @llvm.fmuladd.f64(double %4, double %17, double %18)
%20 = fdiv double %16, %19
%21 = fmul double %20, 2.000000e+00
%22 = fdiv double %21, 0x3F40BE91CDA9B5D6
%23 = fadd double %22, 1.000000e+00
%24 = fptosi double %23 to i32
%25 = tail call i32 @log(i32 %24)
%26 = sitofp i32 %25 to double
%27 = fmul double %13, 2.000000e+00
%28 = fptosi double %27 to i32
%29 = tail call i32 @log(i32 %28)
%30 = tail call double @electronic_density_effect(i32 %2, %struct.atomic_shell* %3, double %13)
%31 = icmp eq double* %6, null
br i1 %31, label %33, label %32
32: ; preds = %7
store double %30, double* %6
br label %33
33: ; preds = %32, %7
%34 = sitofp i32 %29 to double
%35 = fdiv double %26, 3.000000e+00
%36 = fsub double %34, %35
%37 = fmul double %36, 0x3F53074E347B1358
%38 = fmul double %37, %26
%39 = fmul double %38, %26
%40 = fmul double %0, 0x3E507C67BC49A9D3
%41 = fmul double %12, 1.000000e-03
%42 = fdiv double %40, %41
%43 = fmul double %12, 0x3F50BE91CDA9B5D6
%44 = fmul double %13, %43
%45 = fmul double %13, %44
%46 = fmul double %20, %45
%47 = fmul double %1, %1
%48 = fdiv double %46, %47
%49 = fptosi double %48 to i32
%50 = tail call i32 @log(i32 %49)
%51 = sitofp i32 %50 to double
%52 = tail call double @llvm.fmuladd.f64(double %12, double -2.000000e+00, double %51)
%53 = fsub double %52, %30
%54 = fmul double %20, 2.500000e-01
%55 = fmul double %20, %54
%56 = fdiv double %55, %11
%57 = fadd double %56, %53
%58 = fadd double %39, %57
%59 = fmul double %42, %58
ret double %59
}