#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 *, char *);
int main() {
  char input = '!';
  while (input != '7') {
    printf("please input a number(1~3), 7 is quit :");
    scanf(" %d", &input);
    switch (input) {
    case 7:
      printf("quit the function\n");
      return 0;
      break;
    case 0x01:
      printf("get msg id(%d), name(%s)\n", 0x01, "QUEUEFULL");
      break;
    case 0x02:
      printf("get msg id(%d), name(%s)\n", 0x02, "MULTIKEY");
      break;
    case 0x03:
      printf("get msg id(%d), name(%s)\n", 0x03, "INVALIDKEY");
      break;
    default:
      printf("invalid nember\n");
      continue;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x21,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x37,%eax
je     1217 <main+0xf7>
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11ff <main+0xdf>
mov    -0x10(%rbp),%rax
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    121e <main+0xfe>
lea    0xeb2(%rip),%rdi
mov    $0x1,%esi
lea    0xec0(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
lea    0xe93(%rip),%rdi
mov    $0x2,%esi
lea    0xeab(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
lea    0xe74(%rip),%rdi
mov    $0x3,%esi
lea    0xe95(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1133 <main+0x13>
jmp    1133 <main+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
movb   $0x21,0x7(%rsp)
lea    0xed5(%rip),%r14
lea    0xef6(%rip),%r15
lea    0x7(%rsp),%rbx
lea    0xea6(%rip),%r12
lea    0xee7(%rip),%r13
lea    0xf0d(%rip),%rbp
jmp    11a3 <main+0x73>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x1,%esi
lea    0xee3(%rip),%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmpb   $0x37,0x7(%rsp)
jne    11a3 <main+0x73>
jmp    11f9 <main+0xc9>
nop
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
cmpb   $0x37,0x7(%rsp)
je     11f9 <main+0xc9>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     1190 <main+0x60>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    %r13,%rdi
mov    $0x2,%esi
lea    0xe8f(%rip),%rdx
jmp    117f <main+0x4f>
nop
mov    %r13,%rdi
mov    $0x3,%esi
mov    %rbp,%rdx
jmp    117f <main+0x4f>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"please input a number(1~3), 7 is quit :\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [19 x i8] c"quit the function\0A\00"
@.str.3 = [26 x i8] c"get msg id(%d), name(%s)\0A\00"
@.str.4 = [10 x i8] c"QUEUEFULL\00"
@.str.5 = [9 x i8] c"MULTIKEY\00"
@.str.6 = [11 x i8] c"INVALIDKEY\00"
@.str.7 = [16 x i8] c"invalid nember\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
store i8 33, i8* %2
br label %3
3: ; preds = %22, %20, %0
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = icmp ne i32 %5, 55
br i1 %6, label %7, label %23
7: ; preds = %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
switch i32 %11, label %20 [
i32 7, label %12
i32 1, label %14
i32 2, label %16
i32 3, label %18
]
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %24
14: ; preds = %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %22
16: ; preds = %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %22
18: ; preds = %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %22
20: ; preds = %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %3
22: ; preds = %18, %16, %14
br label %3
23: ; preds = %3
store i32 0, i32* %1
br label %24
24: ; preds = %23, %12
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str = [40 x i8] c"please input a number(1~3), 7 is quit :\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.3 = [26 x i8] c"get msg id(%d), name(%s)\0A\00"
@.str.4 = [10 x i8] c"QUEUEFULL\00"
@.str.5 = [9 x i8] c"MULTIKEY\00"
@.str.6 = [11 x i8] c"INVALIDKEY\00"
@str = [18 x i8] c"quit the function\00"
@str.8 = [15 x i8] c"invalid nember\00"
define i32 @main() {
%1 = alloca i8
store i8 33, i8* %1
br label %5
2: ; preds = %12, %14, %16, %18
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 55
br i1 %4, label %20, label %5
5: ; preds = %0, %2
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
switch i32 %9, label %18 [
i32 7, label %10
i32 1, label %12
i32 2, label %14
i32 3, label %16
]
10: ; preds = %5
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %20
12: ; preds = %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %2
14: ; preds = %5
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %2
16: ; preds = %5
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %2
18: ; preds = %5
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0))
br label %2
20: ; preds = %2, %10
ret i32 0
}