#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*/ editor_init();
int /*<<< orphan*/ editor_open(char *);
int /*<<< orphan*/ editor_process_key();
int /*<<< orphan*/ editor_refresh_screen();
int /*<<< orphan*/ editor_set_status_message(char *);
int /*<<< orphan*/ enable_raw_mode();
int /*<<< orphan*/ safe_exit(int /*<<< orphan*/, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  enable_raw_mode();
  editor_init();
  if (argc >= 2) {
    editor_open(argv[1]);
  }
  editor_set_status_message("HELP: ^O = save | ^X = quit | ^W = Search");
  while (1) {
    editor_refresh_screen();
    editor_process_key();
  }
  safe_exit(0, NULL);
  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)
mov    $0x0,%al
call   1030 <enable_raw_mode@plt>
mov    $0x0,%al
call   1040 <editor_init@plt>
cmpl   $0x2,-0x8(%rbp)
jl     119b <main+0x3b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <editor_open@plt>
lea    0xe5e(%rip),%rdi
call   1080 <editor_set_status_message@plt>
mov    $0x0,%al
call   1050 <editor_refresh_screen@plt>
mov    $0x0,%al
call   1070 <editor_process_key@plt>
jmp    11a7 <main+0x47>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <enable_raw_mode@plt>
xor    %eax,%eax
call   1040 <editor_init@plt>
cmp    $0x2,%ebp
jl     1184 <main+0x24>
mov    0x8(%rbx),%rdi
call   1060 <editor_open@plt>
lea    0xe75(%rip),%rdi
call   1080 <editor_set_status_message@plt>
xor    %eax,%eax
call   1050 <editor_refresh_screen@plt>
xor    %eax,%eax
call   1070 <editor_process_key@plt>
jmp    1190 <main+0x30>

LLVM IR (-O0):
@.str = [42 x i8] c"HELP: ^O = save | ^X = quit | ^W = 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 = call i32 (...) @enable_raw_mode()
%7 = call i32 (...) @editor_init()
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @editor_open(i8* %13)
br label %15
15: ; preds = %10, %2
%16 = call i32 @editor_set_status_message(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %17
%18 = call i32 (...) @editor_refresh_screen()
%19 = call i32 (...) @editor_process_key()
br label %17
}

LLVM IR (-O2):
@.str = [42 x i8] c"HELP: ^O = save | ^X = quit | ^W = Search\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @enable_raw_mode()
%4 = tail call i32 (...) @editor_init()
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @editor_open(i8* %8)
br label %10
10: ; preds = %6, %2
%11 = tail call i32 @editor_set_status_message(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %12
%13 = tail call i32 (...) @editor_refresh_screen()
%14 = tail call i32 (...) @editor_process_key()
br label %12
}