#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 /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ editorOpen(char *);
int /*<<< orphan*/ editorProcessKeypress(int /*<<< orphan*/);
int /*<<< orphan*/ editorRefreshScreen();
int /*<<< orphan*/ editorSelectSyntaxHighlight(char *);
int /*<<< orphan*/ editorSetStatusMessage(char *);
int /*<<< orphan*/ enableRawMode(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ initEditor();
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: kilo <filename>\n");
    exit(1);
  }
  initEditor();
  editorSelectSyntaxHighlight(argv[1]);
  editorOpen(argv[1]);
  enableRawMode(STDIN_FILENO);
  editorSetStatusMessage(
      "HELP: Ctrl-X = save | Ctrl-C = quit | Ctrl-S = search");
  while (1) {
    editorRefreshScreen();
    editorProcessKeypress(STDIN_FILENO);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11cf <main+0x3f>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   10b0 <initEditor@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <editorSelectSyntaxHighlight@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <editorOpen@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1030 <enableRawMode@plt>
lea    0xe13(%rip),%rdi
call   1090 <editorSetStatusMessage@plt>
mov    $0x0,%al
call   1060 <editorRefreshScreen@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
call   1080 <editorProcessKeypress@plt>
jmp    120a <main+0x7a>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11e0 <main+0x50>
mov    %rsi,%rbx
xor    %eax,%eax
call   10b0 <initEditor@plt>
mov    0x8(%rbx),%rdi
call   1040 <editorSelectSyntaxHighlight@plt>
mov    0x8(%rbx),%rdi
call   1050 <editorOpen@plt>
mov    0x2e1f(%rip),%rbx
mov    (%rbx),%edi
call   1030 <enableRawMode@plt>
lea    0xe51(%rip),%rdi
call   1090 <editorSetStatusMessage@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <editorRefreshScreen@plt>
mov    (%rbx),%edi
call   1080 <editorProcessKeypress@plt>
jmp    11d0 <main+0x40>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: kilo <filename>\0A\00"
@STDIN_FILENO = global i32 0
@.str.1 = [54 x i8] c"HELP: Ctrl-X = save | Ctrl-C = quit | Ctrl-S = search\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = call i32 (...) @initEditor()
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @editorSelectSyntaxHighlight(i8* %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @editorOpen(i8* %20)
%22 = load i32, i32* @STDIN_FILENO
%23 = call i32 @enableRawMode(i32 %22)
%24 = call i32 @editorSetStatusMessage(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %12, %25
%26 = call i32 (...) @editorRefreshScreen()
%27 = load i32, i32* @STDIN_FILENO
%28 = call i32 @editorProcessKeypress(i32 %27)
br label %25
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: kilo <filename>\0A\00"
@STDIN_FILENO = global i32 0
@.str.1 = [54 x i8] c"HELP: Ctrl-X = save | Ctrl-C = quit | Ctrl-S = search\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i32 (...) @initEditor()
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @editorSelectSyntaxHighlight(i8* %11)
%13 = load i8*, i8** %10
%14 = tail call i32 @editorOpen(i8* %13)
%15 = load i32, i32* @STDIN_FILENO
%16 = tail call i32 @enableRawMode(i32 %15)
%17 = tail call i32 @editorSetStatusMessage(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %8, %18
%19 = tail call i32 (...) @editorRefreshScreen()
%20 = load i32, i32* @STDIN_FILENO
%21 = tail call i32 @editorProcessKeypress(i32 %20)
br label %18
}