#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() {
  int works;
  int hours;
  int extra = 10;
  int sum;
  int sum2;
  while (works != -1) {
    printf("Enter hourly rate of the worker ($00.00): \n");
    scanf("%d", &hours);
    printf("Enter # of hours worked: \n");
    scanf("%d", &works);
    if (works == -1) {
      printf("Program is closing now");
      return 0;
    }
    if (works <= 40) {
      sum = works * hours;
      printf("Salary is %d \n", sum);
    }
    if (works > 40) {
      sum2 = works * hours + extra;
      printf("Salary is %d \n", sum2);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x10(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     11f2 <main+0xd2>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    11a0 <main+0x80>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f2 <main+0xd2>
cmpl   $0x28,-0x8(%rbp)
jg     11c5 <main+0xa5>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x28,-0x8(%rbp)
jle    11ed <main+0xcd>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee7(%rip),%r14
lea    0xeb7(%rip),%rbx
lea    0x4(%rsp),%r15
lea    0xeff(%rip),%r12
mov    %rsp,%r13
lea    0xebb(%rip),%rbp
jmp    118a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
imul   0x4(%rsp),%esi
add    $0xa,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
cmp    $0xffffffff,%esi
je     11e4 <main+0xb4>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%esi
cmp    $0xffffffff,%esi
je     11d6 <main+0xa6>
cmp    $0x28,%esi
jg     1170 <main+0x40>
imul   0x4(%rsp),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
cmp    $0x29,%esi
jge    1170 <main+0x40>
jmp    1185 <main+0x55>
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Enter hourly rate of the worker ($00.00): \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Enter # of hours worked: \0A\00"
@.str.3 = [23 x i8] c"Program is closing now\00"
@.str.4 = [15 x i8] c"Salary is %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %4
br label %7
7: ; preds = %39, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, -1
br i1 %9, label %10, label %40
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %40
19: ; preds = %10
%20 = load i32, i32* %2
%21 = icmp sle i32 %20, 40
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = mul nsw i32 %23, %24
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %22, %19
%29 = load i32, i32* %2
%30 = icmp sgt i32 %29, 40
br i1 %30, label %31, label %39
31: ; preds = %28
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = mul nsw i32 %32, %33
%35 = load i32, i32* %4
%36 = add nsw i32 %34, %35
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %31, %28
br label %7
40: ; preds = %17, %7
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"Program is closing now\00"
@.str.4 = [15 x i8] c"Salary is %d \0A\00"
@str = [43 x i8] c"Enter hourly rate of the worker ($00.00): \00"
@str.5 = [26 x i8] c"Enter # of hours worked: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %29
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 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 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %32
14: ; preds = %5
%15 = icmp slt i32 %10, 41
br i1 %15, label %16, label %22
16: ; preds = %14
%17 = load i32, i32* %2
%18 = mul nsw i32 %17, %10
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %1
%21 = icmp sgt i32 %20, 40
br i1 %21, label %22, label %29
22: ; preds = %14, %16
%23 = phi i32 [ %20, %16 ], [ %10, %14 ]
%24 = load i32, i32* %2
%25 = mul nsw i32 %24, %23
%26 = add nsw i32 %25, 10
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %1
br label %29
29: ; preds = %22, %16
%30 = phi i32 [ %28, %22 ], [ %20, %16 ]
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %5
32: ; preds = %29, %12
ret i32 0
}