#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int Employee[8] = {27000, 32000, 32500, 27500, 3000029000, 31000, 32500};
  int Index;
  int NewSalary;
  int Selection;
  while (1) {
    printf("=========================================\n");
    printf("=Simple Employe Salary Management System    =\n");
    printf("=1.Display employee salary             =\n");
    printf("=2.Modify employee salary              =\n");
    printf("=3.Quit               =\n");
    printf("Please input your choose:");
    scanf("%d", &Selection);
    if (Selection == 1 || Selection == 2) {
      printf("**Please input the employee number:");
      scanf("%d", &Index);
      if (Index < 8) {
        printf("**Employee Mumber is %d.", Index);
        printf("The Salary is %d\n", Employee[Index]);
      } else {
        printf("##The error employee number!\n");
        exit(1);
      }
    }
    switch (Selection) {
    case 1:
      break;
    case 2:
      printf("**Please input new salary:");
      scanf("%d", &NewSalary);
      Employee[Index] = NewSalary;
      break;
    case 3:
      exit(1);
      break;
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf42(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x2c(%rbp)
je     11dc <main+0xac>
cmpl   $0x2,-0x2c(%rbp)
jne    124d <main+0x11d>
lea    0xf21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x8,-0x24(%rbp)
jge    1230 <main+0x100>
mov    -0x24(%rbp),%esi
lea    0xf1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xf1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1248 <main+0x118>
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    124d <main+0x11d>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x1,%eax
je     1283 <main+0x153>
jmp    1261 <main+0x131>
mov    -0x30(%rbp),%eax
sub    $0x2,%eax
je     1288 <main+0x158>
jmp    1272 <main+0x142>
mov    -0x30(%rbp),%eax
sub    $0x3,%eax
je     12b6 <main+0x186>
jmp    12c0 <main+0x190>
jmp    12c0 <main+0x190>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x28(%rbp),%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    12c0 <main+0x190>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1164 <main+0x34>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movaps 0xeab(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xf82(%rip),%r12
lea    0xfa4(%rip),%r13
lea    0xfc6(%rip),%rbx
lea    0xe8e(%rip),%rbp
lea    0xea1(%rip),%r14
lea    0x8(%rsp),%r15
jmp    11d2 <main+0x82>
lea    0xee5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
movslq 0x4(%rsp),%rcx
mov    %eax,0x10(%rsp,%rcx,4)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
lea    0xeec(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x1,%ecx
ja     1270 <main+0x120>
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x7,%esi
jg     128c <main+0x13c>
lea    0xe13(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x4(%rsp),%rax
mov    0x10(%rsp,%rax,4),%esi
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%eax
cmp    $0x2,%eax
je     11a0 <main+0x50>
cmp    $0x3,%eax
jne    11c8 <main+0x78>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xed6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.main.Employee = [8 x i32] [i32 27000, i32 32000, i32 32500, i32 27500, i32 -1294938296, i32 31000, i32 32500, i32 0]
@.str = [43 x i8] c"=========================================\0A\00"
@.str.1 = [47 x i8] c"=Simple Employe Salary Management System =\0A\00"
@.str.2 = [42 x i8] c"=1.Display employee salary =\0A\00"
@.str.3 = [42 x i8] c"=2.Modify employee salary =\0A\00"
@.str.4 = [25 x i8] c"=3.Quit =\0A\00"
@.str.5 = [26 x i8] c"Please input your choose:\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [36 x i8] c"**Please input the employee number:\00"
@.str.8 = [25 x i8] c"**Employee Mumber is %d.\00"
@.str.9 = [18 x i8] c"The Salary is %d\0A\00"
@.str.10 = [30 x i8] c"##The error employee number!\0A\00"
@.str.11 = [27 x i8] c"**Please input new salary:\00"
@.str.12 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca [8 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [8 x i32]* %1 to i8*
br label %6
6: ; preds = %0, %48
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %6
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 2
br i1 %18, label %19, label %36
19: ; preds = %16, %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 8
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %30)
br label %35
32: ; preds = %19
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %24
br label %36
36: ; preds = %35, %16
%37 = load i32, i32* %4
switch i32 %37, label %48 [
i32 1, label %38
i32 2, label %39
i32 3, label %46
]
38: ; preds = %36
br label %48
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
%41 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%42 = load i32, i32* %3
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %44
store i32 %42, i32* %45
br label %48
46: ; preds = %36
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %36, %39, %38
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %6
}

LLVM IR (-O2):
@__const.main.Employee = [8 x i32] [i32 27000, i32 32000, i32 32500, i32 27500, i32 -1294938296, i32 31000, i32 32500, i32 0]
@.str.5 = [26 x i8] c"Please input your choose:\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [36 x i8] c"**Please input the employee number:\00"
@.str.8 = [25 x i8] c"**Employee Mumber is %d.\00"
@.str.9 = [18 x i8] c"The Salary is %d\0A\00"
@.str.11 = [27 x i8] c"**Please input new salary:\00"
@str = [42 x i8] c"=========================================\00"
@str.13 = [46 x i8] c"=Simple Employe Salary Management System =\00"
@str.14 = [41 x i8] c"=1.Display employee salary =\00"
@str.15 = [41 x i8] c"=2.Modify employee salary =\00"
@str.16 = [24 x i8] c"=3.Quit =\00"
@str.17 = [29 x i8] c"##The error employee number!\00"
define void @main() {
%1 = alloca [8 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [8 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
br label %9
9: ; preds = %47, %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.13, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.14, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.15, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.16, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %4
%18 = add i32 %17, -1
%19 = icmp ult i32 %18, 2
br i1 %19, label %20, label %36
20: ; preds = %9
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 8
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %23)
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %4
br label %36
33: ; preds = %20
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.17, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %9, %25
%37 = phi i32 [ %17, %9 ], [ %32, %25 ]
switch i32 %37, label %47 [
i32 3, label %45
i32 2, label %38
]
38: ; preds = %36
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%41 = load i32, i32* %3
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %43
store i32 %41, i32* %44
br label %47
45: ; preds = %36
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %36, %38
%48 = call i32 @putchar(i32 10)
br label %9
}