#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 */
double Range(int, double, int *, double *, double *, int, int, double);
double dEdX(int, double, int *, double *, double *, int, int, double);
double ELoss(int ZP, double MP, int ZT[], double MT[], double CT[], int NTarEl,
             int IsGas, double TT, double E) {
  double EIn = 0.0, dEdX_ = 0.0, dX = 0.0, X = 0.0;
  EIn = E;
  dEdX_ = dEdX(ZP, MP, ZT, MT, CT, NTarEl, IsGas, EIn);
  dX = 0.1 / dEdX_;
  if ((Range(ZP, MP, ZT, MT, CT, NTarEl, IsGas, E) - TT) > 0) {
    while ((TT - X - dX) >= 0) {
      if ((E = E - (dEdX_ * dX)) < 0)
        return EIn;
      X = X + dX;
      dEdX_ = dEdX(ZP, MP, ZT, MT, CT, NTarEl, IsGas, E);
    };
    E = E - (TT - X) * dEdX_;
    return (EIn - E);
  } else
    return EIn;
}


x86 assembly (clang, -O0):
<ELoss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
mov    %r9d,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
movsd  %xmm2,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
movsd  -0x50(%rbp),%xmm1
call   1030 <dEdX@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  0xe55(%rip),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
movsd  -0x48(%rbp),%xmm1
call   1040 <Range@plt>
subsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12e8 <ELoss+0x1c8>
jmp    11f2 <ELoss+0xd2>
movsd  -0x40(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     129c <ELoss+0x17c>
movsd  -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    125d <ELoss+0x13d>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f2 <ELoss+0x1d2>
movsd  -0x68(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x38(%rbp),%r9d
movsd  -0x48(%rbp),%xmm1
call   1030 <dEdX@plt>
movsd  %xmm0,-0x58(%rbp)
jmp    11f2 <ELoss+0xd2>
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f2 <ELoss+0x1d2>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ELoss>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x20(%rsp)
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
movsd  %xmm0,0x18(%rsp)
mov    %edi,%ebp
movaps %xmm2,%xmm1
call   1030 <dEdX@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
movsd  0x18(%rsp),%xmm0
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15d,%r8d
mov    %r14d,%r9d
movsd  0x8(%rsp),%xmm1
call   1040 <Range@plt>
movsd  0x20(%rsp),%xmm2
subsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1262 <ELoss+0x142>
movsd  0xe5f(%rip),%xmm4
movsd  0x10(%rsp),%xmm3
divsd  %xmm3,%xmm4
movapd %xmm2,%xmm0
subsd  %xmm4,%xmm0
ucomisd %xmm1,%xmm0
movapd %xmm3,%xmm0
jae    11cc <ELoss+0xac>
movsd  0x8(%rsp),%xmm1
movapd %xmm2,%xmm3
jmp    124e <ELoss+0x12e>
xorpd  %xmm5,%xmm5
xorpd  %xmm6,%xmm6
movsd  0x8(%rsp),%xmm1
movsd  %xmm4,0x28(%rsp)
mulsd  %xmm4,%xmm0
subsd  %xmm0,%xmm1
ucomisd %xmm1,%xmm5
ja     1262 <ELoss+0x142>
addsd  %xmm4,%xmm6
movsd  %xmm6,0x30(%rsp)
mov    %ebp,%edi
movsd  0x18(%rsp),%xmm0
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15d,%r8d
mov    %r14d,%r9d
movsd  %xmm1,0x10(%rsp)
movsd  0x10(%rsp),%xmm1
call   1030 <dEdX@plt>
movsd  0x30(%rsp),%xmm6
xorpd  %xmm5,%xmm5
movsd  0x28(%rsp),%xmm4
movsd  0x20(%rsp),%xmm3
subsd  %xmm6,%xmm3
movapd %xmm3,%xmm1
subsd  %xmm4,%xmm1
ucomisd %xmm5,%xmm1
movsd  0x10(%rsp),%xmm1
jae    11e0 <ELoss+0xc0>
mulsd  %xmm3,%xmm0
subsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
jmp    1268 <ELoss+0x148>
movsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @ELoss(i32 %0, double %1, i32* %2, double* %3, double* %4, i32 %5, i32 %6, double %7, double %8) {
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca i32*
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store i32 %0, i32* %11
store double %1, double* %12
store i32* %2, i32** %13
store double* %3, double** %14
store double* %4, double** %15
store i32 %5, i32* %16
store i32 %6, i32* %17
store double %7, double* %18
store double %8, double* %19
store double 0.000000e+00, double* %20
store double 0.000000e+00, double* %21
store double 0.000000e+00, double* %22
store double 0.000000e+00, double* %23
%24 = load double, double* %19
store double %24, double* %20
%25 = load i32, i32* %11
%26 = load double, double* %12
%27 = load i32*, i32** %13
%28 = load double*, double** %14
%29 = load double*, double** %15
%30 = load i32, i32* %16
%31 = load i32, i32* %17
%32 = load double, double* %20
%33 = call double @dEdX(i32 %25, double %26, i32* %27, double* %28, double* %29, i32 %30, i32 %31, double %32)
store double %33, double* %21
%34 = load double, double* %21
%35 = fdiv double 1.000000e-01, %34
store double %35, double* %22
%36 = load i32, i32* %11
%37 = load double, double* %12
%38 = load i32*, i32** %13
%39 = load double*, double** %14
%40 = load double*, double** %15
%41 = load i32, i32* %16
%42 = load i32, i32* %17
%43 = load double, double* %19
%44 = call double @Range(i32 %36, double %37, i32* %38, double* %39, double* %40, i32 %41, i32 %42, double %43)
%45 = load double, double* %18
%46 = fsub double %44, %45
%47 = fcmp ogt double %46, 0.000000e+00
br i1 %47, label %48, label %89
48: ; preds = %9
br label %49
49: ; preds = %65, %48
%50 = load double, double* %18
%51 = load double, double* %23
%52 = fsub double %50, %51
%53 = load double, double* %22
%54 = fsub double %52, %53
%55 = fcmp oge double %54, 0.000000e+00
br i1 %55, label %56, label %78
56: ; preds = %49
%57 = load double, double* %19
%58 = load double, double* %21
%59 = load double, double* %22
%60 = fneg double %58
%61 = call double @llvm.fmuladd.f64(double %60, double %59, double %57)
store double %61, double* %19
%62 = fcmp olt double %61, 0.000000e+00
br i1 %62, label %63, label %65
63: ; preds = %56
%64 = load double, double* %20
store double %64, double* %10
br label %91
65: ; preds = %56
%66 = load double, double* %23
%67 = load double, double* %22
%68 = fadd double %66, %67
store double %68, double* %23
%69 = load i32, i32* %11
%70 = load double, double* %12
%71 = load i32*, i32** %13
%72 = load double*, double** %14
%73 = load double*, double** %15
%74 = load i32, i32* %16
%75 = load i32, i32* %17
%76 = load double, double* %19
%77 = call double @dEdX(i32 %69, double %70, i32* %71, double* %72, double* %73, i32 %74, i32 %75, double %76)
store double %77, double* %21
br label %49
78: ; preds = %49
%79 = load double, double* %19
%80 = load double, double* %18
%81 = load double, double* %23
%82 = fsub double %80, %81
%83 = load double, double* %21
%84 = fneg double %82
%85 = call double @llvm.fmuladd.f64(double %84, double %83, double %79)
store double %85, double* %19
%86 = load double, double* %20
%87 = load double, double* %19
%88 = fsub double %86, %87
store double %88, double* %10
br label %91
89: ; preds = %9
%90 = load double, double* %20
store double %90, double* %10
br label %91
91: ; preds = %89, %78, %63
%92 = load double, double* %10
ret double %92
}

LLVM IR (-O2):
define double @ELoss(i32 %0, double %1, i32* %2, double* %3, double* %4, i32 %5, i32 %6, double %7, double %8) {
%10 = tail call double @dEdX(i32 %0, double %1, i32* %2, double* %3, double* %4, i32 %5, i32 %6, double %8)
%11 = fdiv double 1.000000e-01, %10
%12 = tail call double @Range(i32 %0, double %1, i32* %2, double* %3, double* %4, i32 %5, i32 %6, double %8)
%13 = fsub double %12, %7
%14 = fcmp ogt double %13, 0.000000e+00
br i1 %14, label %15, label %38
15: ; preds = %9
%16 = fsub double %7, %11
%17 = fcmp ult double %16, 0.000000e+00
br i1 %17, label %31, label %18
18: ; preds = %15, %25
%19 = phi double [ %26, %25 ], [ 0.000000e+00, %15 ]
%20 = phi double [ %27, %25 ], [ %10, %15 ]
%21 = phi double [ %23, %25 ], [ %8, %15 ]
%22 = fneg double %20
%23 = tail call double @llvm.fmuladd.f64(double %22, double %11, double %21)
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %38, label %25
25: ; preds = %18
%26 = fadd double %11, %19
%27 = tail call double @dEdX(i32 %0, double %1, i32* %2, double* %3, double* %4, i32 %5, i32 %6, double %23)
%28 = fsub double %7, %26
%29 = fsub double %28, %11
%30 = fcmp ult double %29, 0.000000e+00
br i1 %30, label %31, label %18
31: ; preds = %25, %15
%32 = phi double [ %8, %15 ], [ %23, %25 ]
%33 = phi double [ %10, %15 ], [ %27, %25 ]
%34 = phi double [ %7, %15 ], [ %28, %25 ]
%35 = fneg double %34
%36 = tail call double @llvm.fmuladd.f64(double %35, double %33, double %32)
%37 = fsub double %8, %36
br label %38
38: ; preds = %18, %9, %31
%39 = phi double [ %37, %31 ], [ %8, %9 ], [ %8, %18 ]
ret double %39
}