#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 exp(int);
int factorial(int);
int powf(float, int);
float gammacutoff(float alpha, float theta, float percent) {
  percent = percent / 100.0;
  int a = alpha;
  float b = theta;
  int faca = factorial(a);
  float x = 0.0;
  float total = 0.0;
  while (total < percent) {
    total = total +
            ((1 / (faca * b)) * (powf((x / b), (a - 1))) * exp((-1 * x) / b));
    x = x + 0.001;
  }
  return x;
}


x86 assembly (clang, -O0):
<gammacutoff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea8(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
cvttss2si -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    124a <gammacutoff+0x11a>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
movss  0xe53(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%edi
sub    $0x1,%edi
call   1040 <powf@plt>
movss  -0x2c(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  0xe17(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1050 <exp@plt>
movss  -0x28(%rbp),%xmm0
movss  -0x24(%rbp),%xmm1
cvtsi2ss %eax,%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd0(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1192 <gammacutoff+0x62>
movss  -0x1c(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammacutoff>:
push   %rbx
sub    $0x30,%rsp
movss  %xmm1,0xc(%rsp)
divss  0xebd(%rip),%xmm2
movss  %xmm2,0x10(%rsp)
cvttss2si %xmm0,%ebx
mov    %ebx,%edi
call   1030 <factorial@plt>
movss  0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jbe    120d <gammacutoff+0xdd>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xc(%rsp),%xmm0
movss  0xe89(%rip),%xmm2
divss  %xmm0,%xmm2
movss  %xmm2,0x14(%rsp)
add    $0xffffffff,%ebx
xorps  %xmm2,%xmm2
xorps  %xmm0,%xmm0
xchg   %ax,%ax
movss  %xmm2,0x1c(%rsp)
movaps %xmm0,0x20(%rsp)
divss  0xc(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <powf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x14(%rsp),%xmm0
movss  %xmm0,0x18(%rsp)
movaps 0x20(%rsp),%xmm0
xorps  0xe49(%rip),%xmm0
divss  0xc(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1050 <exp@plt>
movss  0x1c(%rsp),%xmm2
movss  0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x18(%rsp),%xmm0
addss  %xmm0,%xmm2
movaps 0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xe1c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
ucomiss %xmm2,%xmm1
ja     1190 <gammacutoff+0x60>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @gammacutoff(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca float
%9 = alloca i32
%10 = alloca float
%11 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%12 = load float, float* %6
%13 = fpext float %12 to double
%14 = fdiv double %13, 1.000000e+02
%15 = fptrunc double %14 to float
store float %15, float* %6
%16 = load float, float* %4
%17 = fptosi float %16 to i32
store i32 %17, i32* %7
%18 = load float, float* %5
store float %18, float* %8
%19 = load i32, i32* %7
%20 = call i32 @factorial(i32 %19)
store i32 %20, i32* %9
store float 0.000000e+00, float* %10
store float 0.000000e+00, float* %11
br label %21
21: ; preds = %25, %3
%22 = load float, float* %11
%23 = load float, float* %6
%24 = fcmp olt float %22, %23
br i1 %24, label %25, label %52
25: ; preds = %21
%26 = load float, float* %11
%27 = load i32, i32* %9
%28 = sitofp i32 %27 to float
%29 = load float, float* %8
%30 = fmul float %28, %29
%31 = fdiv float 1.000000e+00, %30
%32 = load float, float* %10
%33 = load float, float* %8
%34 = fdiv float %32, %33
%35 = load i32, i32* %7
%36 = sub nsw i32 %35, 1
%37 = call i32 @powf(float %34, i32 %36)
%38 = sitofp i32 %37 to float
%39 = fmul float %31, %38
%40 = load float, float* %10
%41 = fmul float -1.000000e+00, %40
%42 = load float, float* %8
%43 = fdiv float %41, %42
%44 = fptosi float %43 to i32
%45 = call i32 @exp(i32 %44)
%46 = sitofp i32 %45 to float
%47 = call float @llvm.fmuladd.f32(float %39, float %46, float %26)
store float %47, float* %11
%48 = load float, float* %10
%49 = fpext float %48 to double
%50 = fadd double %49, 1.000000e-03
%51 = fptrunc double %50 to float
store float %51, float* %10
br label %21
52: ; preds = %21
%53 = load float, float* %10
ret float %53
}

LLVM IR (-O2):
define float @gammacutoff(float %0, float %1, float %2) {
%4 = fdiv float %2, 1.000000e+02
%5 = fptosi float %0 to i32
%6 = tail call i32 @factorial(i32 %5)
%7 = fcmp ogt float %4, 0.000000e+00
br i1 %7, label %8, label %30
8: ; preds = %3
%9 = sitofp i32 %6 to float
%10 = fmul float %9, %1
%11 = fdiv float 1.000000e+00, %10
%12 = add nsw i32 %5, -1
br label %13
13: ; preds = %8, %13
%14 = phi float [ 0.000000e+00, %8 ], [ %25, %13 ]
%15 = phi float [ 0.000000e+00, %8 ], [ %28, %13 ]
%16 = fdiv float %15, %1
%17 = tail call i32 @powf(float %16, i32 %12)
%18 = sitofp i32 %17 to float
%19 = fmul float %11, %18
%20 = fneg float %15
%21 = fdiv float %20, %1
%22 = fptosi float %21 to i32
%23 = tail call i32 @exp(i32 %22)
%24 = sitofp i32 %23 to float
%25 = tail call float @llvm.fmuladd.f32(float %19, float %24, float %14)
%26 = fpext float %15 to double
%27 = fadd double %26, 1.000000e-03
%28 = fptrunc double %27 to float
%29 = fcmp olt float %25, %4
br i1 %29, label %13, label %30
30: ; preds = %13, %3
%31 = phi float [ 0.000000e+00, %3 ], [ %28, %13 ]
ret float %31
}