int main() {
  char cmd[128];
  int i;
  while (1) {
    scanf("%s", cmd);
    if (strcmp(cmd, "help") == 0) {
      printf("This is help cmd!\n");
    } else if (strcmp(cmd, "hello") == 0) {
      printf("This is hello!\n");
    } else if (cmd[1] <= 65) {
      add(cmd[1]);
      printf("%s", cmd[128]);
    } else if (strcmp(cmd, "hello world!") == 0) {
      for (i = 0; i <= 5; i++)
        cmd[i] = 'x';
      printf("%s", cmd[128]);
    } else if (strcmp(cmd, "quit") == 0) {
      exit(0);
    } else {
      printf("Wrong cmd!\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11a6 <main+0x56>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bc <main+0x16c>
lea    -0x90(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11d5 <main+0x85>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b7 <main+0x167>
movsbl -0x8f(%rbp),%eax
cmp    $0x41,%eax
jg     120a <main+0xba>
movsbl -0x8f(%rbp),%edi
mov    $0x0,%al
call   1030 <add@plt>
movsbl -0x10(%rbp),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b2 <main+0x162>
lea    -0x90(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1277 <main+0x127>
movl   $0x0,-0x94(%rbp)
cmpl   $0x5,-0x94(%rbp)
jg     1260 <main+0x110>
movslq -0x94(%rbp),%rax
movb   $0x78,-0x90(%rbp,%rax,1)
78
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1230 <main+0xe0>
movsbl -0x10(%rbp),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ad <main+0x15d>
lea    -0x90(%rbp),%rdi
lea    0xdb9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    129a <main+0x14a>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ad <main+0x15d>
jmp    12b2 <main+0x162>
jmp    12b7 <main+0x167>
jmp    12bc <main+0x16c>
jmp    1162 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
lea    0xe98(%rip),%rbx
mov    %rsp,%r14
mov    $0x706c6568,%ebp
lea    0xec3(%rip),%r15
mov    $0x6c6c6568,%r13d
lea    0xea7(%rip),%r12
jmp    1198 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    (%rsp),%eax
xor    %ebp,%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     1190 <main+0x40>
mov    (%rsp),%eax
xor    %r13d,%eax
movzwl 0x4(%rsp),%ecx
xor    $0x6f,%ecx
or     %eax,%ecx
je     11e0 <main+0x90>
movsbl 0x1(%rsp),%edi
cmp    $0x41,%edi
jg     11ea <main+0x9a>
xor    %eax,%eax
call   1030 <add@plt>
jmp    1244 <main+0xf4>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <puts@plt>
jmp    1198 <main+0x48>
mov    (%rsp),%rax
movabs $0x6f77206f6c6c6568,%rcx
20 77 6f
xor    %rcx,%rax
mov    0x5(%rsp),%rcx
movabs $0x21646c726f7720,%rdx
xor    %rdx,%rcx
or     %rax,%rcx
je     1236 <main+0xe6>
mov    (%rsp),%eax
mov    $0x74697571,%ecx
xor    %ecx,%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     125b <main+0x10b>
lea    0xdf4(%rip),%rdi
call   1040 <puts@plt>
jmp    1198 <main+0x48>
movw   $0x7878,0x4(%rsp)
movl   $0x78787878,(%rsp)
movsbl 0x80(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1198 <main+0x48>
xor    %edi,%edi
call   1070 <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 = [6 x i8] c"hello\00"
@.str.4 = [16 x i8] c"This is hello!\0A\00"
@.str.5 = [13 x i8] c"hello world!\00"
@.str.6 = [5 x i8] c"quit\00"
@.str.7 = [12 x i8] c"Wrong cmd!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %0, %63
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%8 = call i32 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %63
12: ; preds = %4
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %62
18: ; preds = %12
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp sle i32 %21, 65
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 (i32, ...) bitcast (i32 (...)* @add to i32 (i32, ...)*)(i32 %26)
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 128
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %61
32: ; preds = %18
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %52
36: ; preds = %32
store i32 0, i32* %3
br label %37
37: ; preds = %44, %36
%38 = load i32, i32* %3
%39 = icmp sle i32 %38, 5
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %42
store i8 120, i8* %43
br label %44
44: ; preds = %40
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %37
47: ; preds = %37
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 128
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %50)
br label %60
52: ; preds = %32
%53 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%54 = call i32 @strcmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
unreachable
57: ; preds = %52
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %59
59: ; preds = %57
br label %60
60: ; preds = %59, %47
br label %61
61: ; preds = %60, %23
br label %62
62: ; preds = %61, %16
br label %63
63: ; preds = %62, %10
br label %4
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"help\00"
@.str.3 = [6 x i8] c"hello\00"
@.str.5 = [13 x i8] c"hello world!\00"
@.str.6 = [5 x i8] c"quit\00"
@str = [11 x i8] c"Wrong cmd!\00"
@str.8 = [15 x i8] c"This is hello!\00"
@str.9 = [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
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 1
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 128
br label %6
6: ; preds = %17, %0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = call i32 @bcmp(i8* dereferenceable(5) %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0))
br label %17
12: ; preds = %6
%13 = call i32 @bcmp(i8* dereferenceable(6) %3, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 6)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0))
br label %17
17: ; preds = %15, %30, %38, %21, %10
br label %6
18: ; preds = %12
%19 = load i8, i8* %4
%20 = icmp slt i8 %19, 66
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = sext i8 %19 to i32
%23 = call i32 (i32, ...) bitcast (i32 (...)* @add to i32 (i32, ...)*)(i32 %22)
%24 = load i8, i8* %5
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %17
27: ; preds = %18
%28 = call i32 @bcmp(i8* dereferenceable(13) %3, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i64 13)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i8, i8* %5
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %17
34: ; preds = %27
%35 = call i32 @bcmp(i8* dereferenceable(5) %3, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64 5)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %34
unreachable
38: ; preds = %34
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %17
}