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

/* Variables and functions */
int /*<<< orphan*/ bye();
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ handle_command(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usage();
int main() {
  char cmdbuf[128];
  setbuf(stdout, NULL);
  printf("Welcome to the Matrix!"
         "\n");
  usage();
  while (1) {
    printf("Enter command"
           ": ");
    if (fgets(cmdbuf, sizeof(cmdbuf), stdin) == NULL) {
      bye();
    }
    handle_command(cmdbuf);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <setbuf@plt>
lea    0xe75(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <usage@plt>
lea    0xe7a(%rip),%rdi
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11ce <main+0x6e>
mov    $0x0,%al
call   1070 <bye@plt>
lea    -0x90(%rbp),%rdi
call   1030 <handle_command@plt>
jmp    1197 <main+0x37>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <usage@plt>
lea    0xe5a(%rip),%r14
mov    0x2e3b(%rip),%r15
mov    %rsp,%rbx
jmp    11c8 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1040 <handle_command@plt>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1070 <fgets@plt>
test   %rax,%rax
jne    11c0 <main+0x50>
xor    %eax,%eax
call   1080 <bye@plt>
jmp    11c0 <main+0x50>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [24 x i8] c"Welcome to the Matrix!\0A\00"
@.str.1 = [16 x i8] c"Enter command: \00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
%3 = load i32, i32* @stdout
%4 = call i32 @setbuf(i32 %3, i32* null)
%5 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @usage()
br label %7
7: ; preds = %0, %15
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %9, i32 128, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 (...) @bye()
br label %15
15: ; preds = %13, %7
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%17 = call i32 @handle_command(i8* %16)
br label %7
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.1 = [16 x i8] c"Enter command: \00"
@stdin = global i32 0
@str = [23 x i8] c"Welcome to the Matrix!\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdout
%4 = tail call i32 @setbuf(i32 %3, i32* null)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (...) @usage()
br label %7
7: ; preds = %14, %0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @stdin
%10 = call i32* @fgets(i8* %2, i32 128, i32 %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 (...) @bye()
br label %14
14: ; preds = %12, %7
%15 = call i32 @handle_command(i8* %2)
br label %7
}