#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
int main(void) {
  char buf[1024] = {};
  while (1) {
    memset(buf, 0x00, sizeof(buf));
    printf("NB > ");
    fflush(stdout);
    fgets(buf, 1024, stdin);
    system(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   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e38(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1060 <fgets@plt>
lea    -0x410(%rbp),%rdi
call   1030 <system@plt>
jmp    1175 <main+0x25>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe89(%rip),%r14
mov    0x2e5a(%rip),%r15
mov    0x2e63(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    (%r15),%edi
call   1070 <fflush@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
jmp    1190 <main+0x40>

LLVM IR (-O0):
@.str = [6 x i8] c"NB > \00"
@stdout = global i32 0
@stdin = global i32 0
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, %4
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 1024)
%7 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdout
%9 = call i32 @fflush(i32 %8)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 1024, i32 %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%14 = call i32 @system(i8* %13)
br label %4
}

LLVM IR (-O2):
@.str = [6 x i8] c"NB > \00"
@stdout = global i32 0
@stdin = global i32 0
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %3, %0
%4 = call i32 @memset(i8* %2, i32 0, i32 1024)
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = call i32 @fflush(i32 %6)
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %2, i32 1024, i32 %8)
%10 = call i32 @system(i8* %2)
br label %3
}