#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ my_system(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  char buf[1024] = {};
  while (1) {
    printf("> ");
    fflush(stdout);
    fgets(buf, 1024, stdin);
    if (memcmp(buf, "exit", 4) == 0)
      exit(0);
    my_system(buf);
    memset(buf, 0x00, sizeof(buf));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e2b(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1060 <fgets@plt>
lea    -0x410(%rbp),%rdi
lea    0xe2c(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11f2 <main+0x82>
xor    %edi,%edi
call   1090 <exit@plt>
lea    -0x410(%rbp),%rdi
call   1080 <my_system@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
jmp    1195 <main+0x25>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e33(%rip),%r12
mov    (%r12),%edi
call   1070 <fflush@plt>
mov    0x2e33(%rip),%r13
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
lea    0xe36(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     123e <main+0xce>
mov    %rsp,%rbx
lea    0xe17(%rip),%r14
lea    0xe13(%rip),%r15
mov    %rbx,%rdi
call   1080 <my_system@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12),%edi
call   1070 <fflush@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11f0 <main+0x80>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [5 x i8] c"exit\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
store i32 0, i32* %1
%3 = bitcast [1024 x i8]* %2 to i8*
br label %4
4: ; preds = %0, %16
%5 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = call i32 @fflush(i32 %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 1024, i32 %9)
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%12 = call i64 @memcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %4
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%18 = call i32 @my_system(i8* %17)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i32 0, i32 1024)
br label %4
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [5 x i8] c"exit\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = call i32 @fflush(i32 %4)
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %2, i32 1024, i32 %6)
%8 = call i64 @memcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %12, %0
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %0, %12
%13 = call i32 @my_system(i8* %2)
%14 = call i32 @memset(i8* %2, i32 0, i32 1024)
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @stdout
%17 = call i32 @fflush(i32 %16)
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %2, i32 1024, i32 %18)
%20 = call i64 @memcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %10, label %12
}