#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ Log(int, char *, ...);
int calculate_icpif(uint32_t delay, double loss) {
  int idd = 0;
  int ie = 0;
  Log(7, "Calculating ICPIF");
  if (delay < 50000) {
    idd = 0;
  } else if (delay < 100000) {
    idd = 1;
  } else if (delay < 150000) {
    idd = 2;
  } else if (delay < 200000) {
    idd = 4;
  } else {
    idd = 7;
  }
  Log(7, "  Delay Impairment Factor: %d", idd);
  if (loss < 2.0) {
    ie = 0;
  } else if (loss < 4.0) {
    ie = 12;
  } else if (loss < 6.0) {
    ie = 22;
  } else if (loss < 8.0) {
    ie = 28;
  } else {
    ie = 32;
  }
  Log(7, "  Equipment Impairment Factor: %d", ie);
  return idd + ie;
}


x86 assembly (clang, -O0):
<calculate_icpif>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x7,%edi
lea    0xee6(%rip),%rsi
mov    $0x0,%al
call   1030 <Log@plt>
cmpl   $0xc350,-0x4(%rbp)
jge    115a <calculate_icpif+0x4a>
movl   $0x0,-0x14(%rbp)
jmp    11bb <calculate_icpif+0xab>
cmpl   $0x186a0,-0x4(%rbp)
jge    1173 <calculate_icpif+0x63>
movl   $0x1,-0x14(%rbp)
jmp    11b6 <calculate_icpif+0xa6>
cmpl   $0x249f0,-0x4(%rbp)
jge    118c <calculate_icpif+0x7c>
movl   $0x2,-0x14(%rbp)
jmp    11b1 <calculate_icpif+0xa1>
cmpl   $0x30d40,-0x4(%rbp)
jge    11a5 <calculate_icpif+0x95>
movl   $0x4,-0x14(%rbp)
jmp    11ac <calculate_icpif+0x9c>
movl   $0x7,-0x14(%rbp)
jmp    11b1 <calculate_icpif+0xa1>
jmp    11b6 <calculate_icpif+0xa6>
jmp    11bb <calculate_icpif+0xab>
mov    -0x14(%rbp),%edx
mov    $0x7,%edi
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1030 <Log@plt>
movsd  0xe27(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11f0 <calculate_icpif+0xe0>
movl   $0x0,-0x18(%rbp)
jmp    1263 <calculate_icpif+0x153>
movsd  0xe10(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    120f <calculate_icpif+0xff>
movl   $0xc,-0x18(%rbp)
jmp    125e <calculate_icpif+0x14e>
movsd  0xdf9(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    122e <calculate_icpif+0x11e>
movl   $0x16,-0x18(%rbp)
jmp    1259 <calculate_icpif+0x149>
movsd  0xde2(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    124d <calculate_icpif+0x13d>
movl   $0x1c,-0x18(%rbp)
jmp    1254 <calculate_icpif+0x144>
movl   $0x20,-0x18(%rbp)
jmp    1259 <calculate_icpif+0x149>
jmp    125e <calculate_icpif+0x14e>
jmp    1263 <calculate_icpif+0x153>
mov    -0x18(%rbp),%edx
mov    $0x7,%edi
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1030 <Log@plt>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_icpif>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %edi,%ebx
lea    0xef9(%rip),%rsi
xor    %r14d,%r14d
mov    $0x7,%edi
xor    %eax,%eax
call   1030 <Log@plt>
mov    $0x0,%ebp
cmp    $0xc350,%ebx
jl     116e <calculate_icpif+0x5e>
mov    $0x1,%ebp
cmp    $0x186a0,%ebx
jb     116e <calculate_icpif+0x5e>
mov    $0x2,%ebp
cmp    $0x249f0,%ebx
jb     116e <calculate_icpif+0x5e>
xor    %eax,%eax
cmp    $0x30d40,%ebx
setae  %al
lea    (%rax,%rax,2),%ebp
or     $0x4,%ebp
lea    0xebd(%rip),%rsi
mov    $0x7,%edi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <Log@plt>
movsd  0xe75(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
ja     11d8 <calculate_icpif+0xc8>
mov    $0xc,%r14d
movsd  0xe63(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     11d8 <calculate_icpif+0xc8>
mov    $0x16,%r14d
movsd  0xe57(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     11d8 <calculate_icpif+0xc8>
movsd  0xe51(%rip),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
setbe  %al
lea    0x1c(,%rax,4),%r14d
lea    0xe71(%rip),%rsi
mov    $0x7,%edi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <Log@plt>
add    %r14d,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Calculating ICPIF\00"
@.str.1 = [30 x i8] c" Delay Impairment Factor: %d\00"
@.str.2 = [34 x i8] c" Equipment Impairment Factor: %d\00"
define i32 @calculate_icpif(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store double %1, double* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 (i32, i8*, ...) @Log(i32 7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 50000
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %5
br label %27
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 100000
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* %5
br label %26
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 150000
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 2, i32* %5
br label %25
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 200000
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 4, i32* %5
br label %24
23: ; preds = %19
store i32 7, i32* %5
br label %24
24: ; preds = %23, %22
br label %25
25: ; preds = %24, %18
br label %26
26: ; preds = %25, %14
br label %27
27: ; preds = %26, %10
%28 = load i32, i32* %5
%29 = call i32 (i32, i8*, ...) @Log(i32 7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load double, double* %4
%31 = fcmp olt double %30, 2.000000e+00
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 0, i32* %6
br label %49
33: ; preds = %27
%34 = load double, double* %4
%35 = fcmp olt double %34, 4.000000e+00
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 12, i32* %6
br label %48
37: ; preds = %33
%38 = load double, double* %4
%39 = fcmp olt double %38, 6.000000e+00
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 22, i32* %6
br label %47
41: ; preds = %37
%42 = load double, double* %4
%43 = fcmp olt double %42, 8.000000e+00
br i1 %43, label %44, label %45
44: ; preds = %41
store i32 28, i32* %6
br label %46
45: ; preds = %41
store i32 32, i32* %6
br label %46
46: ; preds = %45, %44
br label %47
47: ; preds = %46, %40
br label %48
48: ; preds = %47, %36
br label %49
49: ; preds = %48, %32
%50 = load i32, i32* %6
%51 = call i32 (i32, i8*, ...) @Log(i32 7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %5
%53 = load i32, i32* %6
%54 = add nsw i32 %52, %53
ret i32 %54
}

LLVM IR (-O2):
@.str = [18 x i8] c"Calculating ICPIF\00"
@.str.1 = [30 x i8] c" Delay Impairment Factor: %d\00"
@.str.2 = [34 x i8] c" Equipment Impairment Factor: %d\00"
define i32 @calculate_icpif(i32 %0, double %1) {
%3 = tail call i32 (i32, i8*, ...) @Log(i32 7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i32 %0, 50000
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = icmp ult i32 %0, 100000
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 150000
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 200000
%11 = select i1 %10, i32 4, i32 7
br label %12
12: ; preds = %9, %7, %5, %2
%13 = phi i32 [ 0, %2 ], [ 1, %5 ], [ 2, %7 ], [ %11, %9 ]
%14 = tail call i32 (i32, i8*, ...) @Log(i32 7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = fcmp olt double %1, 2.000000e+00
br i1 %15, label %23, label %16
16: ; preds = %12
%17 = fcmp olt double %1, 4.000000e+00
br i1 %17, label %23, label %18
18: ; preds = %16
%19 = fcmp olt double %1, 6.000000e+00
br i1 %19, label %23, label %20
20: ; preds = %18
%21 = fcmp olt double %1, 8.000000e+00
%22 = select i1 %21, i32 28, i32 32
br label %23
23: ; preds = %20, %18, %16, %12
%24 = phi i32 [ 0, %12 ], [ 12, %16 ], [ 22, %18 ], [ %22, %20 ]
%25 = tail call i32 (i32, i8*, ...) @Log(i32 7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = add nuw nsw i32 %24, %13
ret i32 %26
}