#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 INFINITY;
int floor(double);
double modSwitcher(int, double, double);
double costManager(double modSpeed, double modSpeedAdj1, double modSpeedAdj2,
                   double modSpeedAdj3, double slope, double dist,
                   int total_reviewed, int returnPath, double dnullval) {
  if (returnPath == 1)
    slope = -slope;
  int mod = floor(modSpeed / 1e6);
  double speed = (modSpeed - (mod * 1e6)) / 1e3;
  int modAdj1 = floor(modSpeedAdj1 / 1e6);
  int modAdj2 = floor(modSpeedAdj2 / 1e6);
  int modAdj3 = floor(modSpeedAdj3 / 1e6);
  double speedAdj1 = (modSpeedAdj1 - (modAdj1 * 1e6)) / 1e3;
  double speedAdj2 = (modSpeedAdj2 - (modAdj2 * 1e6)) / 1e3;
  double speedAdj3 = (modSpeedAdj3 - (modAdj3 * 1e6)) / 1e3;
  double speedCurrent;
  double costTimeFinal;
  double d2;
  double d4;
  d2 = dist / 2000;
  d4 = dist / 4000;
  speedCurrent = modSwitcher(mod, speed, slope);
  if (total_reviewed == 16) {
    costTimeFinal = (1 / (speedCurrent / d4) +
                     1 / (modSwitcher(modAdj1, speedAdj1, slope) / d4) +
                     1 / (modSwitcher(modAdj2, speedAdj2, slope) / d4) +
                     1 / (modSwitcher(modAdj3, speedAdj3, slope) / d4));
  } else {
    costTimeFinal = (1 / (speedCurrent / d2) +
                     1 / (modSwitcher(modAdj1, speedAdj1, slope) / d2));
  };
  if (costTimeFinal == INFINITY)
    costTimeFinal = dnullval;
  return costTimeFinal * 3600;
}


x86 assembly (clang, -O0):
<costManager>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
mov    %edi,-0x34(%rbp)
mov    %esi,-0x38(%rbp)
movsd  %xmm6,-0x40(%rbp)
cmpl   $0x1,-0x38(%rbp)
jne    117f <costManager+0x5f>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %eax,-0x44(%rbp)
movsd  -0x8(%rbp),%xmm1
cvtsi2sdl -0x44(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe57(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe31(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %eax,-0x54(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe18(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %eax,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xdff(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %eax,-0x5c(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x54(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdca(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdb2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd88(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd70(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x5c(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd46(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd2e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd10(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
movsd  0xcef(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x44(%rbp),%edi
movsd  -0x50(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <modSwitcher@plt>
movsd  %xmm0,-0x80(%rbp)
cmpl   $0x10,-0x34(%rbp)
jne    141b <costManager+0x2fb>
movsd  -0x80(%rbp),%xmm1
divsd  -0x98(%rbp),%xmm1
ff
movsd  0xccd(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    -0x54(%rbp),%edi
movsd  -0x68(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <modSwitcher@plt>
movaps %xmm0,%xmm2
movsd  -0xb0(%rbp),%xmm0
ff
divsd  -0x98(%rbp),%xmm2
ff
movsd  0xc94(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x58(%rbp),%edi
movsd  -0x70(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <modSwitcher@plt>
movaps %xmm0,%xmm2
movsd  -0xa8(%rbp),%xmm0
ff
divsd  -0x98(%rbp),%xmm2
ff
movsd  0xc57(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x5c(%rbp),%edi
movsd  -0x78(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <modSwitcher@plt>
movaps %xmm0,%xmm2
movsd  -0xa0(%rbp),%xmm0
ff
divsd  -0x98(%rbp),%xmm2
ff
movsd  0xc1a(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1479 <costManager+0x359>
movsd  -0x80(%rbp),%xmm1
divsd  -0x90(%rbp),%xmm1
ff
movsd  0xbf0(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x54(%rbp),%edi
movsd  -0x68(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <modSwitcher@plt>
movaps %xmm0,%xmm2
movsd  -0xb8(%rbp),%xmm0
ff
divsd  -0x90(%rbp),%xmm2
ff
movsd  0xbb7(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
mov    0x2b60(%rip),%rax
ucomisd (%rax),%xmm0
jne    14a5 <costManager+0x385>
jp     14a5 <costManager+0x385>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xb7b(%rip),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<costManager>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
movaps %xmm6,0x50(%rsp)
mov    %edi,%r15d
movaps %xmm5,0x30(%rsp)
cmp    $0x1,%esi
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
jne    1157 <costManager+0x37>
xorps  0xea9(%rip),%xmm4
movaps %xmm4,0x40(%rsp)
movsd  %xmm0,0x20(%rsp)
divsd  0xeb6(%rip),%xmm0
call   1040 <floor@plt>
mov    %eax,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xea0(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  0xe92(%rip),%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
divsd  %xmm2,%xmm0
call   1040 <floor@plt>
mov    %eax,%ebx
movsd  0x10(%rsp),%xmm0
divsd  0xe65(%rip),%xmm0
call   1040 <floor@plt>
mov    %eax,%r12d
movsd  0x18(%rsp),%xmm0
divsd  0xe4f(%rip),%xmm0
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mov    %eax,%r14d
mulsd  0xe38(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  0xe2e(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %ebp,%edi
movsd  0x20(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
call   1030 <modSwitcher@plt>
cmp    $0x10,%r15d
jne    130a <costManager+0x1ea>
movapd %xmm0,0x20(%rsp)
movapd 0x30(%rsp),%xmm0
divsd  0xe08(%rip),%xmm0
movapd %xmm0,0x30(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  0xdda(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm3
subsd  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movsd  0xdc4(%rip),%xmm2
divsd  %xmm2,%xmm3
movsd  %xmm3,0x18(%rsp)
mulsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
call   1030 <modSwitcher@plt>
divsd  0x30(%rsp),%xmm0
movsd  0xd9a(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r12d,%edi
movsd  0x10(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
call   1030 <modSwitcher@plt>
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movapd 0x30(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movapd 0xd2d(%rip),%xmm0
divpd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
mov    %r14d,%edi
movsd  0x18(%rsp),%xmm0
jmp    133c <costManager+0x21c>
movapd 0x30(%rsp),%xmm1
divsd  0xd18(%rip),%xmm1
movapd %xmm1,0x30(%rsp)
divsd  %xmm1,%xmm0
movsd  0xd16(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
call   1030 <modSwitcher@plt>
divsd  0x30(%rsp),%xmm0
movsd  0xcec(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0x20(%rsp),%xmm1
mov    0x2c83(%rip),%rax
movsd  (%rax),%xmm0
cmpeqsd %xmm1,%xmm0
movapd %xmm0,%xmm2
andnpd %xmm1,%xmm2
andpd  0x50(%rsp),%xmm0
orpd   %xmm2,%xmm0
mulsd  0xcc0(%rip),%xmm0
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INFINITY = global double 0.000000e+00
define double @costManager(double %0, double %1, double %2, double %3, double %4, double %5, i32 %6, i32 %7, double %8) {
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca i32
%20 = alloca double
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
store double %0, double* %10
store double %1, double* %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store double %5, double* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store double %8, double* %18
%31 = load i32, i32* %17
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %36
33: ; preds = %9
%34 = load double, double* %14
%35 = fneg double %34
store double %35, double* %14
br label %36
36: ; preds = %33, %9
%37 = load double, double* %10
%38 = fdiv double %37, 1.000000e+06
%39 = call i32 @floor(double %38)
store i32 %39, i32* %19
%40 = load double, double* %10
%41 = load i32, i32* %19
%42 = sitofp i32 %41 to double
%43 = fneg double %42
%44 = call double @llvm.fmuladd.f64(double %43, double 1.000000e+06, double %40)
%45 = fdiv double %44, 1.000000e+03
store double %45, double* %20
%46 = load double, double* %11
%47 = fdiv double %46, 1.000000e+06
%48 = call i32 @floor(double %47)
store i32 %48, i32* %21
%49 = load double, double* %12
%50 = fdiv double %49, 1.000000e+06
%51 = call i32 @floor(double %50)
store i32 %51, i32* %22
%52 = load double, double* %13
%53 = fdiv double %52, 1.000000e+06
%54 = call i32 @floor(double %53)
store i32 %54, i32* %23
%55 = load double, double* %11
%56 = load i32, i32* %21
%57 = sitofp i32 %56 to double
%58 = fneg double %57
%59 = call double @llvm.fmuladd.f64(double %58, double 1.000000e+06, double %55)
%60 = fdiv double %59, 1.000000e+03
store double %60, double* %24
%61 = load double, double* %12
%62 = load i32, i32* %22
%63 = sitofp i32 %62 to double
%64 = fneg double %63
%65 = call double @llvm.fmuladd.f64(double %64, double 1.000000e+06, double %61)
%66 = fdiv double %65, 1.000000e+03
store double %66, double* %25
%67 = load double, double* %13
%68 = load i32, i32* %23
%69 = sitofp i32 %68 to double
%70 = fneg double %69
%71 = call double @llvm.fmuladd.f64(double %70, double 1.000000e+06, double %67)
%72 = fdiv double %71, 1.000000e+03
store double %72, double* %26
%73 = load double, double* %15
%74 = fdiv double %73, 2.000000e+03
store double %74, double* %29
%75 = load double, double* %15
%76 = fdiv double %75, 4.000000e+03
store double %76, double* %30
%77 = load i32, i32* %19
%78 = load double, double* %20
%79 = load double, double* %14
%80 = call double @modSwitcher(i32 %77, double %78, double %79)
store double %80, double* %27
%81 = load i32, i32* %16
%82 = icmp eq i32 %81, 16
br i1 %82, label %83, label %112
83: ; preds = %36
%84 = load double, double* %27
%85 = load double, double* %30
%86 = fdiv double %84, %85
%87 = fdiv double 1.000000e+00, %86
%88 = load i32, i32* %21
%89 = load double, double* %24
%90 = load double, double* %14
%91 = call double @modSwitcher(i32 %88, double %89, double %90)
%92 = load double, double* %30
%93 = fdiv double %91, %92
%94 = fdiv double 1.000000e+00, %93
%95 = fadd double %87, %94
%96 = load i32, i32* %22
%97 = load double, double* %25
%98 = load double, double* %14
%99 = call double @modSwitcher(i32 %96, double %97, double %98)
%100 = load double, double* %30
%101 = fdiv double %99, %100
%102 = fdiv double 1.000000e+00, %101
%103 = fadd double %95, %102
%104 = load i32, i32* %23
%105 = load double, double* %26
%106 = load double, double* %14
%107 = call double @modSwitcher(i32 %104, double %105, double %106)
%108 = load double, double* %30
%109 = fdiv double %107, %108
%110 = fdiv double 1.000000e+00, %109
%111 = fadd double %103, %110
store double %111, double* %28
br label %125
112: ; preds = %36
%113 = load double, double* %27
%114 = load double, double* %29
%115 = fdiv double %113, %114
%116 = fdiv double 1.000000e+00, %115
%117 = load i32, i32* %21
%118 = load double, double* %24
%119 = load double, double* %14
%120 = call double @modSwitcher(i32 %117, double %118, double %119)
%121 = load double, double* %29
%122 = fdiv double %120, %121
%123 = fdiv double 1.000000e+00, %122
%124 = fadd double %116, %123
store double %124, double* %28
br label %125
125: ; preds = %112, %83
%126 = load double, double* %28
%127 = load double, double* @INFINITY
%128 = fcmp oeq double %126, %127
br i1 %128, label %129, label %131
129: ; preds = %125
%130 = load double, double* %18
store double %130, double* %28
br label %131
131: ; preds = %129, %125
%132 = load double, double* %28
%133 = fmul double %132, 3.600000e+03
ret double %133
}

LLVM IR (-O2):
@INFINITY = global double 0.000000e+00
define double @costManager(double %0, double %1, double %2, double %3, double %4, double %5, i32 %6, i32 %7, double %8) {
%10 = icmp eq i32 %7, 1
%11 = fneg double %4
%12 = select i1 %10, double %11, double %4
%13 = fdiv double %0, 1.000000e+06
%14 = tail call i32 @floor(double %13)
%15 = sitofp i32 %14 to double
%16 = fneg double %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double 1.000000e+06, double %0)
%18 = fdiv double %17, 1.000000e+03
%19 = fdiv double %1, 1.000000e+06
%20 = tail call i32 @floor(double %19)
%21 = fdiv double %2, 1.000000e+06
%22 = tail call i32 @floor(double %21)
%23 = fdiv double %3, 1.000000e+06
%24 = tail call i32 @floor(double %23)
%25 = sitofp i32 %20 to double
%26 = fneg double %25
%27 = tail call double @llvm.fmuladd.f64(double %26, double 1.000000e+06, double %1)
%28 = fdiv double %27, 1.000000e+03
%29 = fdiv double %5, 2.000000e+03
%30 = fdiv double %5, 4.000000e+03
%31 = tail call double @modSwitcher(i32 %14, double %18, double %12)
%32 = icmp eq i32 %6, 16
br i1 %32, label %33, label %58
33: ; preds = %9
%34 = sitofp i32 %24 to double
%35 = fneg double %34
%36 = tail call double @llvm.fmuladd.f64(double %35, double 1.000000e+06, double %3)
%37 = fdiv double %36, 1.000000e+03
%38 = sitofp i32 %22 to double
%39 = fneg double %38
%40 = tail call double @llvm.fmuladd.f64(double %39, double 1.000000e+06, double %2)
%41 = fdiv double %40, 1.000000e+03
%42 = tail call double @modSwitcher(i32 %20, double %28, double %12)
%43 = fdiv double %42, %30
%44 = fdiv double 1.000000e+00, %43
%45 = tail call double @modSwitcher(i32 %22, double %41, double %12)
%46 = insertelement <2 x double> poison, double %31, i64 0
%47 = insertelement <2 x double> %46, double %45, i64 1
%48 = insertelement <2 x double> poison, double %30, i64 0
%49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> zeroinitializer
%50 = fdiv <2 x double> %47, %49
%51 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %50
%52 = extractelement <2 x double> %51, i64 0
%53 = fadd double %52, %44
%54 = extractelement <2 x double> %51, i64 1
%55 = fadd double %53, %54
%56 = tail call double @modSwitcher(i32 %24, double %37, double %12)
%57 = fdiv double %56, %30
br label %63
58: ; preds = %9
%59 = fdiv double %31, %29
%60 = fdiv double 1.000000e+00, %59
%61 = tail call double @modSwitcher(i32 %20, double %28, double %12)
%62 = fdiv double %61, %29
br label %63
63: ; preds = %58, %33
%64 = phi double [ %62, %58 ], [ %57, %33 ]
%65 = phi double [ %60, %58 ], [ %55, %33 ]
%66 = fdiv double 1.000000e+00, %64
%67 = fadd double %65, %66
%68 = load double, double* @INFINITY
%69 = fcmp oeq double %67, %68
%70 = select i1 %69, double %8, double %67
%71 = fmul double %70, 3.600000e+03
ret double %71
}