#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 */
char *getline_complete(char *);
int /*<<< orphan*/ print_history();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setup();
int sscanf(char *, char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main() {
  setup();
  while (1) {
    char command[20];
    char *line = getline_complete("example:> ");
    if (!line)
      break;
    printf("Input string: \"%s\"\n", line);
    if (1 == sscanf(line, "%20s", command)) {
      if (!strncmp(command, "history", 20)) {
        print_history();
      } else if (!strncmp(command, "help", 20)) {
        puts("Read the source to know what to do. Type \""
             "exit\" to end this program");
      } else if (!strncmp(command, "exit", 20)) {
        break;
      } else {
        command[20 - 1] = 0;
        printf("%s is not recognized as an internal "
               "command.\n",
               command);
      }
    }
  }
  puts("Bye.");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <setup@plt>
lea    0xe73(%rip),%rdi
call   1080 <getline_complete@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a6 <main+0x36>
jmp    127d <main+0x10d>
mov    -0x28(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xe5a(%rip),%rsi
call   1060 <sscanf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    1278 <main+0x108>
lea    -0x20(%rbp),%rdi
lea    0xe40(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1203 <main+0x93>
mov    $0x0,%al
call   1070 <print_history@plt>
jmp    1273 <main+0x103>
lea    -0x20(%rbp),%rdi
lea    0xe1e(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1232 <main+0xc2>
lea    0xe09(%rip),%rdi
call   1040 <puts@plt>
jmp    126e <main+0xfe>
lea    -0x20(%rbp),%rdi
lea    0xe38(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1255 <main+0xe5>
jmp    127d <main+0x10d>
movb   $0x0,-0xd(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe16(%rip),%rdi
call   1050 <printf@plt>
jmp    126e <main+0xfe>
jmp    1273 <main+0x103>
jmp    1278 <main+0x108>
jmp    1186 <main+0x16>
lea    0xe24(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1090 <setup@plt>
lea    0xe74(%rip),%rdi
call   1080 <getline_complete@plt>
test   %rax,%rax
je     1270 <main+0x100>
mov    %rax,%r13
lea    0xe67(%rip),%r14
lea    0xe74(%rip),%r15
mov    %rsp,%rbx
lea    0xe6f(%rip),%r12
lea    0xe44(%rip),%rbp
jmp    11e4 <main+0x74>
xor    %eax,%eax
call   1070 <print_history@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
call   1080 <getline_complete@plt>
mov    %rax,%r13
test   %rax,%rax
je     1270 <main+0x100>
mov    %r14,%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11d0 <main+0x60>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11be <main+0x4e>
mov    %rbx,%rdi
lea    0xe0c(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     125f <main+0xef>
mov    %rbx,%rdi
lea    0xe3d(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1270 <main+0x100>
movb   $0x0,0x13(%rsp)
lea    0xe28(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
jmp    11d0 <main+0x60>
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
jmp    11d0 <main+0x60>
lea    0xe31(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"example:> \00"
@.str.1 = [20 x i8] c"Input string: \22%s\22\0A\00"
@.str.2 = [5 x i8] c"%20s\00"
@.str.3 = [8 x i8] c"history\00"
@.str.4 = [5 x i8] c"help\00"
@.str.5 = [68 x i8] c"Read the source to know what to do. Type \22exit\22 to end this program\00"
@.str.6 = [5 x i8] c"exit\00"
@.str.7 = [46 x i8] c"%s is not recognized as an internal command.\0A\00"
@.str.8 = [5 x i8] c"Bye.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 (...) @setup()
br label %5
5: ; preds = %0, %41
%6 = call i8* @getline_complete(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %5
br label %42
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %3
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%15 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = icmp eq i32 1, %15
br i1 %16, label %17, label %41
17: ; preds = %10
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%19 = call i32 @strncmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 20)
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 (...) @print_history()
br label %40
23: ; preds = %17
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%25 = call i32 @strncmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 20)
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = call i32 @puts(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0))
br label %39
29: ; preds = %23
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%31 = call i32 @strncmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 20)
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %29
br label %42
34: ; preds = %29
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 19
store i8 0, i8* %35
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%37 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %34
br label %39
39: ; preds = %38, %27
br label %40
40: ; preds = %39, %21
br label %41
41: ; preds = %40, %10
br label %5
42: ; preds = %33, %9
%43 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"example:> \00"
@.str.1 = [20 x i8] c"Input string: \22%s\22\0A\00"
@.str.2 = [5 x i8] c"%20s\00"
@.str.3 = [8 x i8] c"history\00"
@.str.4 = [5 x i8] c"help\00"
@.str.5 = [68 x i8] c"Read the source to know what to do. Type \22exit\22 to end this program\00"
@.str.6 = [5 x i8] c"exit\00"
@.str.7 = [46 x i8] c"%s is not recognized as an internal command.\0A\00"
@.str.8 = [5 x i8] c"Bye.\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = tail call i32 (...) @setup()
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = call i8* @getline_complete(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %31, label %6
6: ; preds = %0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 19
br label %8
8: ; preds = %6, %28
%9 = phi i8* [ %4, %6 ], [ %29, %28 ]
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %28
13: ; preds = %8
%14 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 20)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (...) @print_history()
br label %28
18: ; preds = %13
%19 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 20)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0))
br label %28
23: ; preds = %18
%24 = call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 20)
%25 = icmp eq i32 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %23
store i8 0, i8* %7
%27 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* %3)
br label %28
28: ; preds = %8, %21, %26, %16
%29 = call i8* @getline_complete(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %8
31: ; preds = %23, %28, %0
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}