#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*/ deb_printf(int, char *, double, ...);
int /*<<< orphan*/ err_printf(char *, double, double, double);
double exp(double);
double log(int);
double scintillation(double t, double d, double am) {
  double sn;
  if (t <= 0.00001 || d <= 0.00001 || am < 1.0) {
    err_printf("bad scintillation pars: t %.1f d %.1f am %.1f\n", t, d, am);
  } else {
    deb_printf(3, "scintillation pars: t %.1f d %.1f am %.1f\n", t, d, am);
  }
  sn = log(0.09) - 0.66666 * log(d) + 1.75 * log(am) - 0.5 * log(2 * t);
  sn = exp(sn);
  deb_printf(3, "calculated scint is %.3f\n", sn);
  return sn;
}


x86 assembly (clang, -O0):
<scintillation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  0xea1(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jae    1190 <scintillation+0x50>
movsd  0xe8e(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    1190 <scintillation+0x50>
movsd  0xe83(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11b0 <scintillation+0x70>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    0xe8a(%rip),%rdi
call   1060 <err_printf@plt>
jmp    11d2 <scintillation+0x92>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mov    $0x3,%edi
lea    0xe69(%rip),%rsi
mov    $0x3,%al
call   1030 <deb_printf@plt>
xor    %edi,%edi
call   1050 <log@plt>
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x10(%rbp),%edi
call   1050 <log@plt>
movsd  -0x38(%rbp),%xmm1
movsd  0xe33(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x18(%rbp),%edi
call   1050 <log@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xe07(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdea(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
movsd  -0x28(%rbp),%xmm1
movsd  0xdc7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x3,%edi
lea    0xde9(%rip),%rsi
mov    $0x1,%al
call   1030 <deb_printf@plt>
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scintillation>:
sub    $0x28,%rsp
movsd  0xeb4(%rip),%xmm3
ucomisd %xmm0,%xmm3
movsd  %xmm0,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
jae    118d <scintillation+0x4d>
ucomisd %xmm1,%xmm3
jae    118d <scintillation+0x4d>
movsd  0xe96(%rip),%xmm3
ucomisd %xmm2,%xmm3
ja     118d <scintillation+0x4d>
lea    0xead(%rip),%rsi
mov    $0x3,%edi
mov    $0x3,%al
call   1030 <deb_printf@plt>
jmp    1199 <scintillation+0x59>
lea    0xe94(%rip),%rdi
call   1060 <err_printf@plt>
xor    %edi,%edi
call   1050 <log@plt>
movsd  %xmm0,0x20(%rsp)
cvttsd2si 0x8(%rsp),%edi
call   1050 <log@plt>
mulsd  0xe57(%rip),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si 0x10(%rsp),%edi
call   1050 <log@plt>
mulsd  0xe40(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
mulsd  0xe21(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x18(%rsp)
lea    0xe40(%rip),%rsi
mov    $0x3,%edi
mov    $0x1,%al
call   1030 <deb_printf@plt>
movsd  0x18(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"bad scintillation pars: t %.1f d %.1f am %.1f\0A\00"
@.str.1 = [43 x i8] c"scintillation pars: t %.1f d %.1f am %.1f\0A\00"
@.str.2 = [26 x i8] c"calculated scint is %.3f\0A\00"
define double @scintillation(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%8 = load double, double* %4
%9 = fcmp ole double %8, 1.000000e-05
br i1 %9, label %16, label %10
10: ; preds = %3
%11 = load double, double* %5
%12 = fcmp ole double %11, 1.000000e-05
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load double, double* %6
%15 = fcmp olt double %14, 1.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %13, %10, %3
%17 = load double, double* %4
%18 = load double, double* %5
%19 = load double, double* %6
%20 = call i32 @err_printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), double %17, double %18, double %19)
br label %26
21: ; preds = %13
%22 = load double, double* %4
%23 = load double, double* %5
%24 = load double, double* %6
%25 = call i32 (i32, i8*, double, ...) @deb_printf(i32 3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), double %22, double %23, double %24)
br label %26
26: ; preds = %21, %16
%27 = call double @log(i32 0)
%28 = load double, double* %5
%29 = fptosi double %28 to i32
%30 = call double @log(i32 %29)
%31 = call double @llvm.fmuladd.f64(double -6.666600e-01, double %30, double %27)
%32 = load double, double* %6
%33 = fptosi double %32 to i32
%34 = call double @log(i32 %33)
%35 = call double @llvm.fmuladd.f64(double 1.750000e+00, double %34, double %31)
%36 = load double, double* %4
%37 = fmul double 2.000000e+00, %36
%38 = fptosi double %37 to i32
%39 = call double @log(i32 %38)
%40 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %39, double %35)
store double %40, double* %7
%41 = load double, double* %7
%42 = call double @exp(double %41)
store double %42, double* %7
%43 = load double, double* %7
%44 = call i32 (i32, i8*, double, ...) @deb_printf(i32 3, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %43)
%45 = load double, double* %7
ret double %45
}

LLVM IR (-O2):
@.str = [47 x i8] c"bad scintillation pars: t %.1f d %.1f am %.1f\0A\00"
@.str.1 = [43 x i8] c"scintillation pars: t %.1f d %.1f am %.1f\0A\00"
@.str.2 = [26 x i8] c"calculated scint is %.3f\0A\00"
define double @scintillation(double %0, double %1, double %2) {
%4 = fcmp ole double %0, 1.000000e-05
%5 = fcmp ole double %1, 1.000000e-05
%6 = or i1 %4, %5
%7 = fcmp olt double %2, 1.000000e+00
%8 = or i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @err_printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), double %0, double %1, double %2)
br label %13
11: ; preds = %3
%12 = tail call i32 (i32, i8*, double, ...) @deb_printf(i32 3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), double %0, double %1, double %2)
br label %13
13: ; preds = %11, %9
%14 = tail call double @log(i32 0)
%15 = fptosi double %1 to i32
%16 = tail call double @log(i32 %15)
%17 = tail call double @llvm.fmuladd.f64(double %16, double -6.666600e-01, double %14)
%18 = fptosi double %2 to i32
%19 = tail call double @log(i32 %18)
%20 = tail call double @llvm.fmuladd.f64(double %19, double 1.750000e+00, double %17)
%21 = fmul double %0, 2.000000e+00
%22 = fptosi double %21 to i32
%23 = tail call double @log(i32 %22)
%24 = tail call double @llvm.fmuladd.f64(double %23, double -5.000000e-01, double %20)
%25 = tail call double @exp(double %24)
%26 = tail call i32 (i32, i8*, double, ...) @deb_printf(i32 3, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %25)
ret double %25
}