#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 EXIT_SUCCESS;
int /*<<< orphan*/ execute_line(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int run_in_interactive_mode() {
  char cmd_text[512];
  while (1) {
    fprintf(stdout, "shell-prompt> ");
    if (!fgets(cmd_text, 512, stdin)) {
      fprintf(stdout, "\n");
      return EXIT_SUCCESS;
    }
    execute_line(cmd_text);
  }
  return 0;
}


x86 assembly (clang, -O0):
<run_in_interactive_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x200(%rbp),%rdi
mov    0x2e8a(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    119a <run_in_interactive_mode+0x6a>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
add    $0x200,%rsp
pop    %rbp
ret
lea    -0x200(%rbp),%rdi
call   1030 <execute_line@plt>
jmp    113b <run_in_interactive_mode+0xb>

x86 assembly (clang, -O2):
<run_in_interactive_mode>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    0x2e93(%rip),%r15
mov    (%r15),%edi
lea    0xeb1(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e8d(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rdi
mov    $0x200,%esi
call   1040 <fgets@plt>
test   %eax,%eax
je     11a8 <run_in_interactive_mode+0x78>
mov    %rsp,%rbx
lea    0xe86(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <execute_line@plt>
mov    (%r15),%edi
mov    %r14,%rsi
call   1050 <fprintf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1040 <fgets@plt>
test   %eax,%eax
jne    1180 <run_in_interactive_mode+0x50>
mov    (%r15),%edi
lea    0xe5d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [15 x i8] c"shell-prompt> \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @run_in_interactive_mode() {
%1 = alloca [512 x i8]
br label %2
2: ; preds = %0, %13
%3 = load i32, i32* @stdout
%4 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 512, i32 %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i32, i32* @stdout
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_SUCCESS
ret i32 %12
13: ; preds = %2
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%15 = call i32 @execute_line(i8* %14)
br label %2
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [15 x i8] c"shell-prompt> \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @run_in_interactive_mode() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdout
%4 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %2, i32 512, i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %12, %0
%9 = load i32, i32* @stdout
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @EXIT_SUCCESS
ret i32 %11
12: ; preds = %0, %12
%13 = call i32 @execute_line(i8* %2)
%14 = load i32, i32* @stdout
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %2, i32 512, i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %8, label %12
}