#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 /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main() {
  char cmd[128];
  while (1) {
    scanf("%s", cmd);
    if (strcmp(cmd, "help") == 0) {
      printf("This is help cmd!\n");
    } else if (strcmp(cmd, "others") == 0) {
      printf("This is others cmd!\n");
    } else if (strcmp(cmd, "hello") == 0) {
      printf("This is hello cmd!\n");
    } else if (strcmp(cmd, "greet") == 0) {
      printf("This is greet cmd!\n");
    } else if (strcmp(cmd, "square") == 0) {
      printf("This is square cmd!\n");
    } else if (strcmp(cmd, "div") == 0) {
      printf("This is div cmd!\n");
    } else if (strcmp(cmd, "quit") == 0) {
      exit(0);
    } else {
      printf("wrong cmd!\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1193 <main+0x53>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    12c7 <main+0x187>
lea    -0x90(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c1 <main+0x81>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    12c2 <main+0x182>
lea    -0x90(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ef <main+0xaf>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
jmp    12bd <main+0x17d>
lea    -0x90(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    121d <main+0xdd>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
jmp    12b8 <main+0x178>
lea    -0x90(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    124b <main+0x10b>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
jmp    12b3 <main+0x173>
lea    -0x90(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1279 <main+0x139>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x16e>
lea    -0x90(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    129d <main+0x15d>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
jmp    12ae <main+0x16e>
jmp    12b3 <main+0x173>
jmp    12b8 <main+0x178>
jmp    12bd <main+0x17d>
jmp    12c2 <main+0x182>
jmp    12c7 <main+0x187>
jmp    1152 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xea8(%rip),%r14
mov    %rsp,%rbx
lea    0xea1(%rip),%r15
lea    0xf2c(%rip),%rbp
lea    0xe98(%rip),%r12
lea    0xf0a(%rip),%r13
jmp    1185 <main+0x45>
nopl   0x0(%rax)
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
mov    %rbp,%rdi
test   %rax,%rax
je     1180 <main+0x40>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
mov    %r13,%rdi
test   %rax,%rax
je     1180 <main+0x40>
mov    %rbx,%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcmp@plt>
lea    0xea2(%rip),%rdi
test   %rax,%rax
je     1180 <main+0x40>
mov    %rbx,%rdi
lea    0xe3a(%rip),%rsi
call   1040 <strcmp@plt>
lea    0xe74(%rip),%rdi
test   %rax,%rax
je     1180 <main+0x40>
mov    %rbx,%rdi
lea    0xe25(%rip),%rsi
call   1040 <strcmp@plt>
lea    0xe45(%rip),%rdi
test   %rax,%rax
je     1180 <main+0x40>
mov    %rbx,%rdi
lea    0xe0d(%rip),%rsi
call   1040 <strcmp@plt>
lea    0xe15(%rip),%rdi
test   %rax,%rax
je     1180 <main+0x40>
mov    %rbx,%rdi
lea    0xdf2(%rip),%rsi
call   1040 <strcmp@plt>
lea    0xdeb(%rip),%rdi
test   %rax,%rax
jne    1180 <main+0x40>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [19 x i8] c"This is help cmd!\0A\00"
@.str.3 = [7 x i8] c"others\00"
@.str.4 = [21 x i8] c"This is others cmd!\0A\00"
@.str.5 = [6 x i8] c"hello\00"
@.str.6 = [20 x i8] c"This is hello cmd!\0A\00"
@.str.7 = [6 x i8] c"greet\00"
@.str.8 = [20 x i8] c"This is greet cmd!\0A\00"
@.str.9 = [7 x i8] c"square\00"
@.str.10 = [21 x i8] c"This is square cmd!\0A\00"
@.str.11 = [4 x i8] c"div\00"
@.str.12 = [18 x i8] c"This is div cmd!\0A\00"
@.str.13 = [5 x i8] c"quit\00"
@.str.14 = [12 x i8] c"wrong cmd!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %0, %55
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %55
11: ; preds = %3
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %54
17: ; preds = %11
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %53
23: ; preds = %17
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %52
29: ; preds = %23
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %51
35: ; preds = %29
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %50
41: ; preds = %35
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %41
%48 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
br label %49
49: ; preds = %47
br label %50
50: ; preds = %49, %39
br label %51
51: ; preds = %50, %33
br label %52
52: ; preds = %51, %27
br label %53
53: ; preds = %52, %21
br label %54
54: ; preds = %53, %15
br label %55
55: ; preds = %54, %9
br label %3
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"help\00"
@.str.3 = [7 x i8] c"others\00"
@.str.5 = [6 x i8] c"hello\00"
@.str.7 = [6 x i8] c"greet\00"
@.str.9 = [7 x i8] c"square\00"
@.str.11 = [4 x i8] c"div\00"
@.str.13 = [5 x i8] c"quit\00"
@str = [11 x i8] c"wrong cmd!\00"
@str.15 = [17 x i8] c"This is div cmd!\00"
@str.16 = [20 x i8] c"This is square cmd!\00"
@str.17 = [19 x i8] c"This is greet cmd!\00"
@str.18 = [19 x i8] c"This is hello cmd!\00"
@str.19 = [20 x i8] c"This is others cmd!\00"
@str.20 = [18 x i8] c"This is help cmd!\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %27, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %3
%8 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %27, label %10
10: ; preds = %7
%11 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %10
%14 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %27, label %16
16: ; preds = %13
%17 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %22, %19, %16, %13, %10, %7, %3
%28 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.20, i64 0, i64 0), %3 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.19, i64 0, i64 0), %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.18, i64 0, i64 0), %10 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.17, i64 0, i64 0), %13 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.16, i64 0, i64 0), %16 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.15, i64 0, i64 0), %19 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0), %22 ]
%29 = call i32 @puts(i8* dereferenceable(1) %28)
br label %3
}