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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
je     121c <main+0xfc>
cmpl   $0x28,-0x8(%rbp)
jle    11a7 <main+0x87>
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe71(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x28,-0x8(%rbp)
jg     11e0 <main+0xc0>
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe45(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf8(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    115f <main+0x3f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf11(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     122c <main+0x10c>
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
lea    0xec6(%rip),%r15
lea    0x14(%rsp),%r12
lea    0xebd(%rip),%r13
lea    0xec6(%rip),%rbx
lea    0xe7e(%rip),%rbp
lea    0xc(%rsp),%r14
jmp    11ca <main+0xaa>
nopl   (%rax)
movss  0x10(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
cvtss2sd %xmm0,%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>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     122c <main+0x10c>
cmp    $0x29,%eax
jl     11f2 <main+0xd2>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x14(%rsp),%xmm1
mulss  %xmm1,%xmm0
mulss  0xe18(%rip),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x10(%rsp)
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x29,%eax
jge    1190 <main+0x70>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x14(%rsp),%xmm0
jmp    1196 <main+0x76>
xor    %eax,%eax
add    $0x18,%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 = [16 x i8] c"Salary is %.2f\0A\00"
@.str.5 = [39 x i8] c"\0AEnter # of hours worked (-1 to end): \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %34, %0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, -1
br i1 %10, label %11, label %40
11: ; preds = %8
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 40
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to float
%17 = load float, float* %3
%18 = fmul float %16, %17
store float %18, float* %4
%19 = load float, float* %3
%20 = fdiv float %19, 2.000000e+00
store float %20, float* %5
%21 = load float, float* %5
%22 = load float, float* %4
%23 = fadd float %22, %21
store float %23, float* %4
br label %24
24: ; preds = %14, %11
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%27 = load i32, i32* %2
%28 = icmp sle i32 %27, 40
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i32, i32* %2
%31 = sitofp i32 %30 to float
%32 = load float, float* %3
%33 = fmul float %31, %32
store float %33, float* %4
br label %34
34: ; preds = %29, %24
%35 = load float, float* %4
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
40: ; preds = %8
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 = [16 x i8] c"Salary is %.2f\0A\00"
@.str.5 = [39 x i8] c"\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 %35, label %9
9: ; preds = %0, %19
%10 = phi i32 [ %33, %19 ], [ %7, %0 ]
%11 = phi float [ %28, %19 ], [ 0.000000e+00, %0 ]
%12 = icmp sgt i32 %10, 40
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = sitofp i32 %10 to float
%15 = load float, float* %2
%16 = fmul float %15, %14
%17 = fmul float %15, 5.000000e-01
%18 = fadd float %16, %17
br label %19
19: ; preds = %13, %9
%20 = phi float [ %18, %13 ], [ %11, %9 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%23 = load i32, i32* %1
%24 = icmp slt i32 %23, 41
%25 = sitofp i32 %23 to float
%26 = load float, float* %2
%27 = fmul float %26, %25
%28 = select i1 %24, float %27, float %20
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%33 = load i32, i32* %1
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %9
35: ; preds = %19, %0
ret i32 0
}