#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fs_init();
char *get_pwd_name();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ process_cmd(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ vfs_init();
int main() {
  char line[64];
  char cmd[64];
  char param[48];
  fs_init();
  vfs_init();
  while (1) {
    printf("[GES %s]$ ", get_pwd_name());
    if (fgets(line, sizeof(line), stdin) == NULL)
      exit(0);
    if (strlen(line) <= 1)
      continue;
    sscanf(line, "%s %48[^\n]", cmd, param);
    process_cmd(cmd, param);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <fs_init@plt>
mov    $0x0,%al
call   1030 <vfs_init@plt>
mov    $0x0,%al
call   1060 <get_pwd_name@plt>
mov    %rax,%rsi
lea    0xe3f(%rip),%rdi
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    0x2e17(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    11ee <main+0x5e>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jg     1205 <main+0x75>
jmp    11b0 <main+0x20>
lea    -0x50(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    -0xc0(%rbp),%rcx
lea    0xded(%rip),%rsi
call   1090 <sscanf@plt>
lea    -0x90(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
call   1080 <process_cmd@plt>
jmp    11b0 <main+0x20>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
xor    %eax,%eax
call   10a0 <fs_init@plt>
xor    %eax,%eax
call   1030 <vfs_init@plt>
xor    %eax,%eax
call   1060 <get_pwd_name@plt>
lea    0xe43(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    0x2e1c(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rdi
mov    $0x40,%esi
call   1070 <fgets@plt>
test   %rax,%rax
jne    11e8 <main+0x58>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    %rsp,%rbx
lea    0xe0e(%rip),%r14
lea    0xe12(%rip),%r15
lea    0x70(%rsp),%r12
lea    0x40(%rsp),%r13
jmp    1237 <main+0xa7>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1060 <get_pwd_name@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     11e1 <main+0x51>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1210 <main+0x80>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1090 <sscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1080 <process_cmd@plt>
jmp    1210 <main+0x80>

LLVM IR (-O0):
@.str = [11 x i8] c"[GES %s]$ \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"%s %48[^\0A]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
%4 = alloca [48 x i8]
store i32 0, i32* %1
%5 = call i32 (...) @fs_init()
%6 = call i32 (...) @vfs_init()
br label %7
7: ; preds = %0, %20, %21
%8 = call i8* (...) @get_pwd_name()
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32* @fgets(i8* %10, i32 64, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %7
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = icmp sle i32 %18, 1
br i1 %19, label %20, label %21
20: ; preds = %16
br label %7
21: ; preds = %16
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%24 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 0
%25 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%27 = getelementptr inbounds [48 x i8], [48 x i8]* %4, i64 0, i64 0
%28 = call i32 @process_cmd(i8* %26, i8* %27)
br label %7
}

LLVM IR (-O2):
@.str = [11 x i8] c"[GES %s]$ \00"
@stdin = global i32 0
@.str.1 = [11 x i8] c"%s %48[^\0A]\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca [64 x i8]
%3 = alloca [48 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [48 x i8], [48 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (...) @fs_init()
%8 = tail call i32 (...) @vfs_init()
%9 = call i8* (...) @get_pwd_name()
%10 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @stdin
%12 = call i32* @fgets(i8* %4, i32 64, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %22, %0
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %0, %22
%17 = call i32 @strlen(i8* %4)
%18 = icmp slt i32 %17, 2
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %6)
%21 = call i32 @process_cmd(i8* %5, i8* %6)
br label %22
22: ; preds = %19, %16
%23 = call i8* (...) @get_pwd_name()
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @stdin
%26 = call i32* @fgets(i8* %4, i32 64, i32 %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %14, label %16
}