#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  double kwh;
  double bill;
  printf("Please enter the kwh used.\n");
  scanf("%lf", &kwh);
  if (kwh <= 360)
    bill = 0.12589 * kwh;
  else if (kwh <= 680)
    bill = (0.12589 * 360) + (0.17901 * (kwh - 360));
  else
    bill = (0.17901 * (680 - 360)) + (0.20971 * (kwh - 680));
  printf("The charge for %.1f kwh is $%1.2f.\n", kwh, bill);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  0xeab(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1177 <main+0x57>
movsd  0xec8(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11f0 <main+0xd0>
movsd  0xe89(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11bd <main+0x9d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe7d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe79(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11eb <main+0xcb>
movsd  -0x10(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe3a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe36(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11f0 <main+0xd0>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe57(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf38(%rip),%rdi
call   1030 <puts@plt>
lea    0xf04(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
movsd  0xea7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    118b <main+0x5b>
movsd  0xea9(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1199 <main+0x69>
movsd  0xebb(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xeb7(%rip),%xmm1
addsd  0xeb7(%rip),%xmm1
jmp    11b5 <main+0x85>
movsd  0xe75(%rip),%xmm1
mulsd  %xmm0,%xmm1
jmp    11b5 <main+0x85>
movsd  0xe77(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe73(%rip),%xmm1
addsd  0xe73(%rip),%xmm1
lea    0xe90(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Please enter the kwh used.\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [36 x i8] c"The charge for %.1f kwh is $%1.2f.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%6 = load double, double* %2
%7 = fcmp ole double %6, 3.600000e+02
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load double, double* %2
%10 = fmul double 1.258900e-01, %9
store double %10, double* %3
br label %23
11: ; preds = %0
%12 = load double, double* %2
%13 = fcmp ole double %12, 6.800000e+02
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load double, double* %2
%16 = fsub double %15, 3.600000e+02
%17 = call double @llvm.fmuladd.f64(double 1.790100e-01, double %16, double 4.532040e+01)
store double %17, double* %3
br label %22
18: ; preds = %11
%19 = load double, double* %2
%20 = fsub double %19, 6.800000e+02
%21 = call double @llvm.fmuladd.f64(double 2.097100e-01, double %20, double 5.728320e+01)
store double %21, double* %3
br label %22
22: ; preds = %18, %14
br label %23
23: ; preds = %22, %8
%24 = load double, double* %2
%25 = load double, double* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double %24, double %25)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [36 x i8] c"The charge for %.1f kwh is $%1.2f.\0A\00"
@str = [27 x i8] c"Please enter the kwh used.\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp ugt double %5, 3.600000e+02
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = fmul double %5, 1.258900e-01
br label %17
9: ; preds = %0
%10 = fcmp ugt double %5, 6.800000e+02
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = fadd double %5, -3.600000e+02
%13 = call double @llvm.fmuladd.f64(double %12, double 1.790100e-01, double 4.532040e+01)
br label %17
14: ; preds = %9
%15 = fadd double %5, -6.800000e+02
%16 = call double @llvm.fmuladd.f64(double %15, double 2.097100e-01, double 5.728320e+01)
br label %17
17: ; preds = %11, %14, %7
%18 = phi double [ %8, %7 ], [ %13, %11 ], [ %16, %14 ]
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), double %5, double %18)
ret i32 0
}