#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 *, int *);
int main(void) {
  int hours;
  double gross, tax, net;
  printf("How many hours do you work in a week?\n");
  scanf("%d", &hours);
  if (hours <= 40)
    gross = 10 * hours;
  else
    gross = 10 * hours + 1.5 * 10 * (hours - 40);
  if (gross <= 300)
    tax = gross * 0.15;
  else if (gross <= 450)
    tax = 300 * 0.15 + (gross - 300) * 0.20;
  else
    tax = 300 * 0.15 + (450 - 300) * 0.20 + (gross - 450) * 0.25;
  net = gross - tax;
  printf("Your gross pay: $%.2f\n", gross);
  printf("Your taxes: $%.2f\n", tax);
  printf("Your net pay: $%.2f\n", net);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf23(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x28,-0x8(%rbp)
jg     1169 <main+0x49>
imul   $0xa,-0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1190 <main+0x70>
imul   $0xa,-0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
mov    -0x8(%rbp),%eax
sub    $0x28,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe7d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe70(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11ba <main+0x9a>
movsd  0xe8d(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1233 <main+0x113>
movsd  0xe4e(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1200 <main+0xe0>
movsd  -0x10(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe42(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe3e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    122e <main+0x10e>
movsd  -0x10(%rbp),%xmm0
movsd  0xe03(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdff(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdfb(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1233 <main+0x113>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe1c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf57(%rip),%rdi
call   1030 <puts@plt>
lea    0xf09(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
cvtsi2sd %ecx,%xmm0
cmp    $0x29,%eax
jl     1177 <main+0x47>
add    $0xffffffd8,%eax
cvtsi2sd %eax,%xmm1
mulsd  0xe8d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe89(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11b1 <main+0x81>
movsd  0xe8b(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bf <main+0x8f>
movsd  0xe9d(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe99(%rip),%xmm1
addsd  0xe99(%rip),%xmm1
jmp    11db <main+0xab>
movsd  0xe57(%rip),%xmm1
mulsd  %xmm0,%xmm1
jmp    11db <main+0xab>
movsd  0xe59(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe55(%rip),%xmm1
addsd  0xe55(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
lea    0xe5d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"How many hours do you work in a week?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"Your gross pay: $%.2f\0A\00"
@.str.3 = [19 x i8] c"Your taxes: $%.2f\0A\00"
@.str.4 = [21 x i8] c"Your net pay: $%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 40
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* %2
%12 = mul nsw i32 10, %11
%13 = sitofp i32 %12 to double
store double %13, double* %3
br label %22
14: ; preds = %0
%15 = load i32, i32* %2
%16 = mul nsw i32 10, %15
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 40
%20 = sitofp i32 %19 to double
%21 = call double @llvm.fmuladd.f64(double 1.500000e+01, double %20, double %17)
store double %21, double* %3
br label %22
22: ; preds = %14, %10
%23 = load double, double* %3
%24 = fcmp ole double %23, 3.000000e+02
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load double, double* %3
%27 = fmul double %26, 1.500000e-01
store double %27, double* %4
br label %40
28: ; preds = %22
%29 = load double, double* %3
%30 = fcmp ole double %29, 4.500000e+02
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load double, double* %3
%33 = fsub double %32, 3.000000e+02
%34 = call double @llvm.fmuladd.f64(double %33, double 2.000000e-01, double 4.500000e+01)
store double %34, double* %4
br label %39
35: ; preds = %28
%36 = load double, double* %3
%37 = fsub double %36, 4.500000e+02
%38 = call double @llvm.fmuladd.f64(double %37, double 2.500000e-01, double 7.500000e+01)
store double %38, double* %4
br label %39
39: ; preds = %35, %31
br label %40
40: ; preds = %39, %25
%41 = load double, double* %3
%42 = load double, double* %4
%43 = fsub double %41, %42
store double %43, double* %5
%44 = load double, double* %3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %44)
%46 = load double, double* %4
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %46)
%48 = load double, double* %5
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %48)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"Your gross pay: $%.2f\0A\00"
@.str.3 = [19 x i8] c"Your taxes: $%.2f\0A\00"
@.str.4 = [21 x i8] c"Your net pay: $%.2f\0A\00"
@str = [38 x i8] c"How many hours do you work in a week?\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 41
%7 = mul nsw i32 %5, 10
%8 = sitofp i32 %7 to double
%9 = add nsw i32 %5, -40
%10 = sitofp i32 %9 to double
%11 = call double @llvm.fmuladd.f64(double %10, double 1.500000e+01, double %8)
%12 = select i1 %6, double %8, double %11
%13 = fcmp ugt double %12, 3.000000e+02
br i1 %13, label %16, label %14
14: ; preds = %0
%15 = fmul double %12, 1.500000e-01
br label %24
16: ; preds = %0
%17 = fcmp ugt double %12, 4.500000e+02
br i1 %17, label %21, label %18
18: ; preds = %16
%19 = fadd double %12, -3.000000e+02
%20 = call double @llvm.fmuladd.f64(double %19, double 2.000000e-01, double 4.500000e+01)
br label %24
21: ; preds = %16
%22 = fadd double %12, -4.500000e+02
%23 = call double @llvm.fmuladd.f64(double %22, double 2.500000e-01, double 7.500000e+01)
br label %24
24: ; preds = %18, %21, %14
%25 = phi double [ %15, %14 ], [ %20, %18 ], [ %23, %21 ]
%26 = fsub double %12, %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %12)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %25)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %26)
ret i32 0
}