#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() {
  float wages, hourlyRate, amountPerItem, weeklySales;
  int paycode = 0, hoursWorked, itemsProduced;
  float commission = 0.057;
  while (paycode != -1) {
    printf("Enter employee paycode or -1 to exit: ");
    scanf("%d", &paycode);
    wages = 0.0;
    switch (paycode) {
    case 1:
      printf("Enter the employee's weekly wages: ");
      scanf("%f", &wages);
      break;
    case 2:
      printf("Enter the worker's hourly rate: ");
      scanf("%f", &hourlyRate);
      printf("Enter the number of hours worked: ");
      scanf("%d", &hoursWorked);
      if (hoursWorked > 40) {
        wages = (hoursWorked - 40) * (hourlyRate * 1.5);
        hoursWorked = 40;
      }
      wages += (hoursWorked * hourlyRate);
      break;
    case 3:
      wages = 250.0;
      printf("Enter the worker's weekly sales total: ");
      scanf("%f", &weeklySales);
      wages += (weeklySales * commission);
      break;
    case 4:
      printf("Enter the price paid per item made: ");
      scanf("%f", &amountPerItem);
      printf("Enter the number of items made: ");
      scanf("%d", &itemsProduced);
      wages = amountPerItem * itemsProduced;
      break;
    case -1:
      break;
    default:
      printf("\n<< Invalid employee code!!! >>\n");
      break;
    }
    if (paycode >= 1 && paycode <= 4)
      printf("The employees weekly wage is $%.2f\n\n", wages);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movss  0xec2(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
je     134d <main+0x22d>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x31(%rbp)
call   1030 <printf@plt>
mov    -0x31(%rbp),%al
lea    0xee7(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x5,%eax
ja     130f <main+0x1ef>
mov    -0x30(%rbp),%rax
lea    0xe78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    131d <main+0x1fd>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe54(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x28,-0x1c(%rbp)
jle    1243 <main+0x123>
mov    -0x1c(%rbp),%eax
sub    $0x28,%eax
cvtsi2sd %eax,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xddd(%rip),%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x28,-0x1c(%rbp)
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    131d <main+0x1fd>
movss  0xd98(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf0(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    131d <main+0x1fd>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdaf(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd68(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    131d <main+0x1fd>
jmp    131d <main+0x1fd>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x18(%rbp)
jl     1348 <main+0x228>
cmpl   $0x4,-0x18(%rbp)
jg     1348 <main+0x228>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1143 <main+0x23>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,0x10(%rsp)
lea    0xedb(%rip),%r14
lea    0xefb(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xfcb(%rip),%r13
lea    0xea9(%rip),%rbp
lea    0xf08(%rip),%r12
jmp    1179 <main+0x49>
cmp    $0xffffffff,%eax
je     134d <main+0x21d>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movl   $0x0,0xc(%rsp)
mov    0x10(%rsp),%eax
add    $0x1,%eax
cmp    $0x5,%eax
ja     11d0 <main+0xa0>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
jmp    1320 <main+0x1f0>
lea    0xf79(%rip),%rdi
call   1030 <puts@plt>
jmp    1320 <main+0x1f0>
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0x18(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x28,%eax
jle    12f6 <main+0x1c6>
add    $0xffffffd8,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movss  0x18(%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mulsd  0xdc1(%rip),%xmm2
mulsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
movl   $0x28,0x14(%rsp)
mov    $0x28,%eax
jmp    1302 <main+0x1d2>
movl   $0x437a0000,0xc(%rsp)
43
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x20(%rsp),%xmm0
mulss  0xd69(%rip),%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
jmp    1320 <main+0x1f0>
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0x24(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x1c(%rsp),%xmm0
mulss  0x24(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
jmp    1320 <main+0x1f0>
movss  0x18(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
mulss  %xmm0,%xmm2
addss  %xmm1,%xmm2
movss  %xmm2,0xc(%rsp)
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
ja     1170 <main+0x40>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x10(%rsp),%eax
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Enter employee paycode or -1 to exit: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"Enter the employee's weekly wages: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [33 x i8] c"Enter the worker's hourly rate: \00"
@.str.5 = [35 x i8] c"Enter the number of hours worked: \00"
@.str.6 = [40 x i8] c"Enter the worker's weekly sales total: \00"
@.str.7 = [37 x i8] c"Enter the price paid per item made: \00"
@.str.8 = [33 x i8] c"Enter the number of items made: \00"
@.str.9 = [33 x i8] c"\0A<< Invalid employee code!!! >>\0A\00"
@.str.10 = [37 x i8] c"The employees weekly wage is $%.2f\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
store i32 0, i32* %1
store i32 0, i32* %6
store float 0x3FAD2F1AA0000000, float* %9
br label %10
10: ; preds = %71, %0
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %72
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store float 0.000000e+00, float* %2
%16 = load i32, i32* %6
switch i32 %16, label %59 [
i32 1, label %17
i32 2, label %20
i32 3, label %42
i32 4, label %49
i32 -1, label %58
]
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
br label %61
20: ; preds = %13
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, 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* %3)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%25 = load i32, i32* %7
%26 = icmp sgt i32 %25, 40
br i1 %26, label %27, label %36
27: ; preds = %20
%28 = load i32, i32* %7
%29 = sub nsw i32 %28, 40
%30 = sitofp i32 %29 to double
%31 = load float, float* %3
%32 = fpext float %31 to double
%33 = fmul double %32, 1.500000e+00
%34 = fmul double %30, %33
%35 = fptrunc double %34 to float
store float %35, float* %2
store i32 40, i32* %7
br label %36
36: ; preds = %27, %20
%37 = load i32, i32* %7
%38 = sitofp i32 %37 to float
%39 = load float, float* %3
%40 = load float, float* %2
%41 = call float @llvm.fmuladd.f32(float %38, float %39, float %40)
store float %41, float* %2
br label %61
42: ; preds = %13
store float 2.500000e+02, float* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%45 = load float, float* %5
%46 = load float, float* %9
%47 = load float, float* %2
%48 = call float @llvm.fmuladd.f32(float %45, float %46, float %47)
store float %48, float* %2
br label %61
49: ; preds = %13
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%54 = load float, float* %4
%55 = load i32, i32* %8
%56 = sitofp i32 %55 to float
%57 = fmul float %54, %56
store float %57, float* %2
br label %61
58: ; preds = %13
br label %61
59: ; preds = %13
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
br label %61
61: ; preds = %59, %58, %49, %42, %36, %17
%62 = load i32, i32* %6
%63 = icmp sge i32 %62, 1
br i1 %63, label %64, label %71
64: ; preds = %61
%65 = load i32, i32* %6
%66 = icmp sle i32 %65, 4
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = load float, float* %2
%69 = fpext float %68 to double
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), double %69)
br label %71
71: ; preds = %67, %64, %61
br label %10
72: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"Enter employee paycode or -1 to exit: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"Enter the employee's weekly wages: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [33 x i8] c"Enter the worker's hourly rate: \00"
@.str.5 = [35 x i8] c"Enter the number of hours worked: \00"
@.str.6 = [40 x i8] c"Enter the worker's weekly sales total: \00"
@.str.7 = [37 x i8] c"Enter the price paid per item made: \00"
@.str.8 = [33 x i8] c"Enter the number of items made: \00"
@.str.10 = [37 x i8] c"The employees weekly wage is $%.2f\0A\0A\00"
@str = [32 x i8] c"\0A<< Invalid employee code!!! >>\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast float* %1 to i8*
%9 = bitcast float* %2 to i8*
%10 = bitcast float* %3 to i8*
%11 = bitcast float* %4 to i8*
%12 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
br label %15
15: ; preds = %0, %72
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store float 0.000000e+00, float* %1
%18 = load i32, i32* %5
switch i32 %18, label %61 [
i32 1, label %19
i32 2, label %22
i32 3, label %46
i32 4, label %52
i32 -1, label %63
]
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %1)
br label %63
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 40
br i1 %28, label %32, label %29
29: ; preds = %22
%30 = load float, float* %2
%31 = load float, float* %1
br label %40
32: ; preds = %22
%33 = add nsw i32 %27, -40
%34 = sitofp i32 %33 to double
%35 = load float, float* %2
%36 = fpext float %35 to double
%37 = fmul double %36, 1.500000e+00
%38 = fmul double %37, %34
%39 = fptrunc double %38 to float
store i32 40, i32* %6
br label %40
40: ; preds = %29, %32
%41 = phi float [ %39, %32 ], [ %31, %29 ]
%42 = phi float [ %35, %32 ], [ %30, %29 ]
%43 = phi i32 [ 40, %32 ], [ %27, %29 ]
%44 = sitofp i32 %43 to float
%45 = call float @llvm.fmuladd.f32(float %44, float %42, float %41)
store float %45, float* %1
br label %63
46: ; preds = %15
store float 2.500000e+02, float* %1
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%48 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%49 = load float, float* %4
%50 = load float, float* %1
%51 = call float @llvm.fmuladd.f32(float %49, float 0x3FAD2F1AA0000000, float %50)
store float %51, float* %1
br label %63
52: ; preds = %15
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%56 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%57 = load float, float* %3
%58 = load i32, i32* %7
%59 = sitofp i32 %58 to float
%60 = fmul float %57, %59
store float %60, float* %1
br label %63
61: ; preds = %15
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %63
63: ; preds = %61, %15, %52, %46, %40, %19
%64 = load i32, i32* %5
%65 = add i32 %64, -1
%66 = icmp ult i32 %65, 4
br i1 %66, label %67, label %72
67: ; preds = %63
%68 = load float, float* %1
%69 = fpext float %68 to double
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), double %69)
%71 = load i32, i32* %5
br label %72
72: ; preds = %67, %63
%73 = phi i32 [ %71, %67 ], [ %64, %63 ]
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %15
75: ; preds = %72
ret i32 0
}