#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(int argc, char const *argv[]) {
  double kwh;
  double bill;
  printf("Please enter the kwh used.\n");
  scanf("%lf", &kwh);
  if (kwh <= 360.0) {
    bill = 0.12589 * kwh;
  } else if (kwh <= 680.0) {
    bill = (0.12589 * 360.0) + (0.17901 * (kwh - 360.0));
  } else {
    bill = ((0.12589 * 360.0) + (0.17901 * (680.0 - 360.0))) +
           (0.20971 * (kwh - 680.0));
  }
  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)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movsd  0xea4(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     117e <main+0x5e>
movsd  0xec1(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <main+0xd7>
movsd  0xe82(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11c4 <main+0xa4>
movsd  -0x18(%rbp),%xmm0
movsd  0xe62(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe76(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe72(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f2 <main+0xd2>
movsd  -0x18(%rbp),%xmm0
movsd  0xe37(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe33(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11f7 <main+0xd7>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe50(%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    0xf39(%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 = [37 x i8] c"The charge for %.1f kwh is $%1.2f .\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %6)
%10 = load double, double* %6
%11 = fcmp ole double %10, 3.600000e+02
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load double, double* %6
%14 = fmul double 1.258900e-01, %13
store double %14, double* %7
br label %27
15: ; preds = %2
%16 = load double, double* %6
%17 = fcmp ole double %16, 6.800000e+02
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load double, double* %6
%20 = fsub double %19, 3.600000e+02
%21 = call double @llvm.fmuladd.f64(double 1.790100e-01, double %20, double 4.532040e+01)
store double %21, double* %7
br label %26
22: ; preds = %15
%23 = load double, double* %6
%24 = fsub double %23, 6.800000e+02
%25 = call double @llvm.fmuladd.f64(double 2.097100e-01, double %24, double 0x4059A6A161E4F766)
store double %25, double* %7
br label %26
26: ; preds = %22, %18
br label %27
27: ; preds = %26, %12
%28 = load double, double* %6
%29 = load double, double* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %28, double %29)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [37 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(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%7 = load double, double* %3
%8 = fcmp ugt double %7, 3.600000e+02
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = fmul double %7, 1.258900e-01
br label %19
11: ; preds = %2
%12 = fcmp ugt double %7, 6.800000e+02
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = fadd double %7, -3.600000e+02
%15 = call double @llvm.fmuladd.f64(double %14, double 1.790100e-01, double 4.532040e+01)
br label %19
16: ; preds = %11
%17 = fadd double %7, -6.800000e+02
%18 = call double @llvm.fmuladd.f64(double %17, double 2.097100e-01, double 0x4059A6A161E4F766)
br label %19
19: ; preds = %13, %16, %9
%20 = phi double [ %10, %9 ], [ %15, %13 ], [ %18, %16 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), double %7, double %20)
ret i32 0
}