#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 */
typedef int /*<<< orphan*/ line;

/* Variables and functions */
int execute_string(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int cli_loop() {
  char line[(2048)] = {'\0'};
  int loop_done = 0;
  fwrite("Type '?' for help.\n", sizeof(char), 19, stdout);
  while (loop_done == 0) {
    fwrite("] ", sizeof(char), 2, stdout);
    fgets(line, sizeof(line), stdin);
    line[(2048) - 1] = '\0';
    loop_done = execute_string(line);
  }
  return loop_done;
}


x86 assembly (clang, -O0):
<cli_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
lea    -0x800(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1030 <memset@plt>
movl   $0x0,-0x804(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%ecx
lea    0xe88(%rip),%rdi
mov    $0x1,%esi
mov    $0x13,%edx
call   1060 <fwrite@plt>
cmpl   $0x0,-0x804(%rbp)
jne    11e8 <cli_loop+0xa8>
mov    0x2e3d(%rip),%rax
mov    (%rax),%ecx
lea    0xe70(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1060 <fwrite@plt>
lea    -0x800(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1040 <fgets@plt>
movb   $0x0,-0x1(%rbp)
lea    -0x800(%rbp),%rdi
call   1050 <execute_string@plt>
mov    %eax,-0x804(%rbp)
jmp    1187 <cli_loop+0x47>
mov    -0x804(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cli_loop>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsp,%rbx
mov    $0x800,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    0x2e71(%rip),%r15
mov    (%r15),%ecx
lea    0xe8f(%rip),%rdi
mov    $0x1,%esi
mov    $0x13,%edx
call   1060 <fwrite@plt>
lea    0xe8d(%rip),%r14
mov    0x2e5a(%rip),%r12
xchg   %ax,%ax
mov    (%r15),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1060 <fwrite@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x800,%esi
call   1040 <fgets@plt>
movb   $0x0,0x7ff(%rsp)
mov    %rbx,%rdi
call   1050 <execute_string@plt>
test   %eax,%eax
je     1190 <cli_loop+0x50>
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Type '?' for help.\0A\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"] \00"
@stdin = global i32 0
define i32 @cli_loop() {
%1 = alloca [2048 x i8]
%2 = alloca i32
%3 = bitcast [2048 x i8]* %1 to i8*
store i32 0, i32* %2
%4 = load i32, i32* @stdout
%5 = call i32 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 1, i32 19, i32 %4)
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* @stdout
%11 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 2, i32 %10)
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 2048, i32 %13)
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 2047
store i8 0, i8* %15
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%17 = call i32 @execute_string(i8* %16)
store i32 %17, i32* %2
br label %6
18: ; preds = %6
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [20 x i8] c"Type '?' for help.\0A\00"
@stdout = global i32 0
@.str.1 = [3 x i8] c"] \00"
@stdin = global i32 0
define i32 @cli_loop() {
%1 = alloca [2048 x i8]
%2 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdout
%4 = tail call i32 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 1, i32 19, i32 %3)
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 2047
br label %6
6: ; preds = %0, %6
%7 = load i32, i32* @stdout
%8 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 2, i32 %7)
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %2, i32 2048, i32 %9)
store i8 0, i8* %5
%11 = call i32 @execute_string(i8* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %6, label %13
13: ; preds = %6
ret i32 %11
}