#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 ceil(float);
float calculateCharges(float hr) {
  float charge = 0;
  int x = 0;
  if (hr <= 3) {
    charge = 2;
  } else {
    x = ceil(hr);
    charge = (x - 3) * 0.5 + 2;
    if (charge > 10.00) {
      charge = 10.00;
    }
  }
  return charge;
}


x86 assembly (clang, -O0):
<calculateCharges>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movss  0xecc(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     1150 <calculateCharges+0x40>
movss  0xec2(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11b5 <calculateCharges+0xa5>
movss  -0x4(%rbp),%xmm0
call   1030 <ceil@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
cvtsi2sd %eax,%xmm0
movsd  0xea9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea5(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe77(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b0 <calculateCharges+0xa0>
movss  0xe59(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11b5 <calculateCharges+0xa5>
movss  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculateCharges>:
push   %rax
movss  0xeeb(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1154 <calculateCharges+0x44>
call   1030 <ceil@plt>
add    $0xfffffffd,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xedb(%rip),%xmm0
addsd  0xedb(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
ucomiss 0xec0(%rip),%xmm0
jbe    1152 <calculateCharges+0x42>
movss  0xeb6(%rip),%xmm0
pop    %rax
ret
movss  0xea4(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @calculateCharges(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca i32
store float %0, float* %2
store float 0.000000e+00, float* %3
store i32 0, i32* %4
%5 = load float, float* %2
%6 = fcmp ole float %5, 3.000000e+00
br i1 %6, label %7, label %8
7: ; preds = %1
store float 2.000000e+00, float* %3
br label %21
8: ; preds = %1
%9 = load float, float* %2
%10 = call i32 @ceil(float %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 3
%13 = sitofp i32 %12 to double
%14 = call double @llvm.fmuladd.f64(double %13, double 5.000000e-01, double 2.000000e+00)
%15 = fptrunc double %14 to float
store float %15, float* %3
%16 = load float, float* %3
%17 = fpext float %16 to double
%18 = fcmp ogt double %17, 1.000000e+01
br i1 %18, label %19, label %20
19: ; preds = %8
store float 1.000000e+01, float* %3
br label %20
20: ; preds = %19, %8
br label %21
21: ; preds = %20, %7
%22 = load float, float* %3
ret float %22
}

LLVM IR (-O2):
define float @calculateCharges(float %0) {
%2 = fcmp ugt float %0, 3.000000e+00
br i1 %2, label %3, label %11
3: ; preds = %1
%4 = tail call i32 @ceil(float %0)
%5 = add nsw i32 %4, -3
%6 = sitofp i32 %5 to double
%7 = tail call double @llvm.fmuladd.f64(double %6, double 5.000000e-01, double 2.000000e+00)
%8 = fptrunc double %7 to float
%9 = fcmp ogt float %8, 1.000000e+01
br i1 %9, label %10, label %11
10: ; preds = %3
br label %11
11: ; preds = %1, %3, %10
%12 = phi float [ 1.000000e+01, %10 ], [ %8, %3 ], [ 2.000000e+00, %1 ]
ret float %12
}