#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int a;
  char *s = (char *)malloc(sizeof(char));
  printf("a=");
  scanf("%d", &a);
  switch (a) {
  case 1:
    s = "baby";
    break;
  case 2:
    s = "child";
    break;
  case 3:
    s = "tinager";
    break;
  case 4:
    s = "student";
    break;
  case 5:
    s = "worker";
    break;
  case 6:
    s = "oldman";
    break;
  default:
    s = "wrong";
  }
  printf("%s\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     11fb <main+0xcb>
mov    -0x28(%rbp),%rax
lea    0xe6e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe7c(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1206 <main+0xd6>
lea    0xe71(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1206 <main+0xd6>
lea    0xe67(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1206 <main+0xd6>
lea    0xe5f(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1206 <main+0xd6>
lea    0xe57(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1206 <main+0xd6>
lea    0xe4e(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1206 <main+0xd6>
lea    0xe45(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%edi
call   1050 <malloc@plt>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     1188 <main+0x48>
cltq
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    118f <main+0x4f>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"a=\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"baby\00"
@.str.3 = [6 x i8] c"child\00"
@.str.4 = [8 x i8] c"tinager\00"
@.str.5 = [8 x i8] c"student\00"
@.str.6 = [7 x i8] c"worker\00"
@.str.7 = [7 x i8] c"oldman\00"
@.str.8 = [6 x i8] c"wrong\00"
@.str.9 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @malloc(i32 1)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %6
switch i32 %12, label %19 [
i32 1, label %13
i32 2, label %14
i32 3, label %15
i32 4, label %16
i32 5, label %17
i32 6, label %18
]
13: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %20
14: ; preds = %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %20
15: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %20
16: ; preds = %2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %7
br label %20
17: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %7
br label %20
18: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %7
br label %20
19: ; preds = %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %7
br label %20
20: ; preds = %19, %18, %17, %16, %15, %14, %13
%21 = load i8*, i8** %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"a=\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"baby\00"
@.str.3 = [6 x i8] c"child\00"
@.str.4 = [8 x i8] c"tinager\00"
@.str.5 = [8 x i8] c"student\00"
@.str.6 = [7 x i8] c"worker\00"
@.str.7 = [7 x i8] c"oldman\00"
@.str.8 = [6 x i8] c"wrong\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.6 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.7 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i64 @malloc(i32 1)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 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* %3)
%8 = load i32, i32* %3
%9 = add i32 %8, -1
%10 = icmp ult i32 %9, 6
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = sext i32 %9 to i64
%13 = shl i64 %12, 2
%14 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %13)
br label %15
15: ; preds = %2, %11
%16 = phi i8* [ %14, %11 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), %2 ]
%17 = call i32 @puts(i8* dereferenceable(1) %16)
ret i32 0
}