#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*/ editorOpen(char *);
int /*<<< orphan*/ editorProcessKeypress();
int /*<<< orphan*/ editorRefreshScreen();
int /*<<< orphan*/ editorSetStatusMessage(char *);
int /*<<< orphan*/ enableRawMode();
int handleArgs(int, char **);
int /*<<< orphan*/ initEditor();
int main(int argc, char *argv[]) {
  initEditor();
  int arg_response = handleArgs(argc, argv);
  if (arg_response > 0)
    editorOpen(argv[argc - 1]);
  else if (arg_response == -1)
    return 0;
  enableRawMode();
  editorSetStatusMessage(
      " Ctrl-Q to quit | Ctrl-S to save | (tte -h | --help for more info)");
  while (1) {
    editorRefreshScreen();
    editorProcessKeypress();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <initEditor@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <handleArgs@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11c1 <main+0x51>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <editorOpen@plt>
jmp    11d8 <main+0x68>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11d3 <main+0x63>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    11d8 <main+0x68>
mov    $0x0,%al
call   1030 <enableRawMode@plt>
lea    0xe1a(%rip),%rdi
call   1080 <editorSetStatusMessage@plt>
mov    $0x0,%al
call   1050 <editorRefreshScreen@plt>
mov    $0x0,%al
call   1070 <editorProcessKeypress@plt>
jmp    11eb <main+0x7b>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1090 <initEditor@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <handleArgs@plt>
test   %eax,%eax
jle    119c <main+0x2c>
movslq %ebp,%rax
mov    -0x8(%rbx,%rax,8),%rdi
call   1040 <editorOpen@plt>
jmp    11a1 <main+0x31>
cmp    $0xffffffff,%eax
je     11d0 <main+0x60>
xor    %eax,%eax
call   1030 <enableRawMode@plt>
lea    0xe51(%rip),%rdi
call   1080 <editorSetStatusMessage@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <editorRefreshScreen@plt>
xor    %eax,%eax
call   1070 <editorProcessKeypress@plt>
jmp    11c0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c" Ctrl-Q to quit | Ctrl-S to save | (tte -h | --help for more info)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @initEditor()
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @handleArgs(i32 %8, i8** %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = load i32, i32* %4
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %14, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @editorOpen(i8* %19)
br label %26
21: ; preds = %2
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %21
ret i32 0
25: ; preds = %21
br label %26
26: ; preds = %25, %13
%27 = call i32 (...) @enableRawMode()
%28 = call i32 @editorSetStatusMessage(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %26, %29
%30 = call i32 (...) @editorRefreshScreen()
%31 = call i32 (...) @editorProcessKeypress()
br label %29
}

LLVM IR (-O2):
@.str = [67 x i8] c" Ctrl-Q to quit | Ctrl-S to save | (tte -h | --help for more info)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 (...) @initEditor()
%4 = tail call i32 @handleArgs(i32 %0, i8** %1)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = add nsw i32 %0, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i32 @editorOpen(i8* %10)
br label %15
12: ; preds = %2
%13 = icmp eq i32 %4, -1
br i1 %13, label %14, label %15
14: ; preds = %12
ret i32 0
15: ; preds = %12, %6
%16 = tail call i32 (...) @enableRawMode()
%17 = tail call i32 @editorSetStatusMessage(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %18, %15
%19 = tail call i32 (...) @editorRefreshScreen()
%20 = tail call i32 (...) @editorProcessKeypress()
br label %18
}