#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*/ gets(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int test08_1_main(int argc, char *argv[]) {
  char buf[32];
  puts("test08_1 started.\n");
  while (1) {
    puts("> ");
    gets(buf);
    if (!strncmp(buf, "echo", 4)) {
      puts(buf + 4);
      puts("\n");
    } else if (!strcmp(buf, "exit")) {
      break;
    } else {
      puts("unknown.\n");
    }
  }
  puts("test08_1 exit.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test08_1_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
lea    -0x30(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x30(%rbp),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ac <test08_1_main+0x6c>
lea    -0x30(%rbp),%rdi
add    $0x4,%rdi
call   1040 <puts@plt>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
jmp    11db <test08_1_main+0x9b>
lea    -0x30(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ca <test08_1_main+0x8a>
jmp    11e0 <test08_1_main+0xa0>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
jmp    11db <test08_1_main+0x9b>
jmp    115b <test08_1_main+0x1b>
lea    0xe43(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test08_1_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebb(%rip),%rdi
call   1040 <puts@plt>
lea    0xec2(%rip),%r15
mov    %rsp,%rbx
lea    0xebb(%rip),%r12
lea    0xeaf(%rip),%r13
mov    $0x74697865,%ebp
lea    0xeb2(%rip),%r14
jmp    1182 <test08_1_main+0x52>
lea    0x4(%rsp),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1170 <test08_1_main+0x40>
mov    (%rsp),%eax
xor    %ebp,%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
mov    %r14,%rdi
je     11be <test08_1_main+0x8e>
call   1040 <puts@plt>
jmp    1182 <test08_1_main+0x52>
lea    0xe65(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"test08_1 started.\0A\00"
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [5 x i8] c"echo\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [5 x i8] c"exit\00"
@.str.5 = [10 x i8] c"unknown.\0A\00"
@.str.6 = [16 x i8] c"test08_1 exit.\0A\00"
define i32 @test08_1_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [32 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %2, %27
%8 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%12 = call i32 @strncmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%13 = icmp ne i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %7
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds i8, i8* %15, i64 4
%17 = call i32 @puts(i8* %16)
%18 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %27
19: ; preds = %7
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19
br label %28
24: ; preds = %19
%25 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %24
br label %27
27: ; preds = %26, %14
br label %7
28: ; preds = %23
%29 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"test08_1 started.\0A\00"
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [5 x i8] c"echo\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [5 x i8] c"exit\00"
@.str.5 = [10 x i8] c"unknown.\0A\00"
@.str.6 = [16 x i8] c"test08_1 exit.\0A\00"
define i32 @test08_1_main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 4
br label %7
7: ; preds = %17, %2
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @gets(i8* %4)
%10 = call i32 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 @puts(i8* %6)
br label %17
14: ; preds = %7
%15 = call i32 @bcmp(i8* dereferenceable(5) %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 5)
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14, %12
%18 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %12 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %14 ]
%19 = call i32 @puts(i8* dereferenceable(1) %18)
br label %7
20: ; preds = %14
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}