#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 main() {
  int hoursWorked;
  float hourlyRate, salary;
  printf("Enter # of hours worked (-1 to end): ");
  scanf("%d", &hoursWorked);
  while (hoursWorked != -1) {
    salary = 0;
    printf("Enter hourly rate of the worker ($00.00): ");
    scanf("%f", &hourlyRate);
    if (hoursWorked > 40) {
      salary += (hoursWorked - 40) * (hourlyRate * 1.5);
      hoursWorked = 40;
    }
    salary += hoursWorked * hourlyRate;
    printf("Salary is $%.2f\n", salary);
    printf("\n\nEnter # of hours worked (-1 to end): ");
    scanf("%d", &hoursWorked);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
je     1223 <main+0x103>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x28,-0x8(%rbp)
jle    11cb <main+0xab>
mov    -0x8(%rbp),%eax
sub    $0x28,%eax
cvtsi2sd %eax,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe5a(%rip),%xmm1
mulsd  %xmm1,%xmm2
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x28,-0x8(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe42(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf5(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    114f <main+0x2f>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf22(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0xffffffff,(%rsp)
je     122d <main+0x10d>
lea    0xee3(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xeda(%rip),%r13
lea    0xee4(%rip),%rbx
lea    0xe9b(%rip),%rbp
mov    %rsp,%r14
jmp    11fb <main+0xdb>
nopl   (%rax)
add    $0xffffffd8,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movss  0x4(%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mulsd  0xe61(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe5d(%rip),%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
movl   $0x28,(%rsp)
mov    $0x28,%eax
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
mulss  %xmm0,%xmm2
addss  %xmm1,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0xffffffff,(%rsp)
je     122d <main+0x10d>
lea    0xe11(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    (%rsp),%eax
cmp    $0x28,%eax
jg     1180 <main+0x60>
xorps  %xmm1,%xmm1
movss  0x4(%rsp),%xmm0
jmp    11be <main+0x9e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Enter # of hours worked (-1 to end): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"Enter hourly rate of the worker ($00.00): \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [17 x i8] c"Salary is $%.2f\0A\00"
@.str.5 = [40 x i8] c"\0A\0AEnter # of hours worked (-1 to end): \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %26, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %37
10: ; preds = %7
store float 0.000000e+00, float* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 40
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = load i32, i32* %2
%17 = sub nsw i32 %16, 40
%18 = sitofp i32 %17 to double
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = fmul double %20, 1.500000e+00
%22 = load float, float* %4
%23 = fpext float %22 to double
%24 = call double @llvm.fmuladd.f64(double %18, double %21, double %23)
%25 = fptrunc double %24 to float
store float %25, float* %4
store i32 40, i32* %2
br label %26
26: ; preds = %15, %10
%27 = load i32, i32* %2
%28 = sitofp i32 %27 to float
%29 = load float, float* %3
%30 = load float, float* %4
%31 = call float @llvm.fmuladd.f32(float %28, float %29, float %30)
store float %31, float* %4
%32 = load float, float* %4
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
37: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Enter # of hours worked (-1 to end): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"Enter hourly rate of the worker ($00.00): \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [17 x i8] c"Salary is $%.2f\0A\00"
@.str.5 = [40 x i8] c"\0A\0AEnter # of hours worked (-1 to end): \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, -1
br i1 %8, label %36, label %9
9: ; preds = %0, %24
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 40
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = load float, float* %2
br label %24
16: ; preds = %9
%17 = add nsw i32 %12, -40
%18 = sitofp i32 %17 to double
%19 = load float, float* %2
%20 = fpext float %19 to double
%21 = fmul double %20, 1.500000e+00
%22 = call double @llvm.fmuladd.f64(double %18, double %21, double 0.000000e+00)
%23 = fptrunc double %22 to float
store i32 40, i32* %1
br label %24
24: ; preds = %14, %16
%25 = phi float [ %19, %16 ], [ %15, %14 ]
%26 = phi i32 [ 40, %16 ], [ %12, %14 ]
%27 = phi float [ %23, %16 ], [ 0.000000e+00, %14 ]
%28 = sitofp i32 %26 to float
%29 = call float @llvm.fmuladd.f32(float %28, float %25, float %27)
%30 = fpext float %29 to double
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%34 = load i32, i32* %1
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %9
36: ; preds = %24, %0
ret i32 0
}