#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*/ EXIT_FAILURE;
int /*<<< orphan*/ editor_init();
int /*<<< orphan*/ editor_open(char *);
int editor_process_keypress();
int /*<<< orphan*/ editor_refresh_screen();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: openemacs <filename>\n");
    exit(EXIT_FAILURE);
  }
  editor_init();
  editor_open(argv[1]);
  editor_refresh_screen();
  while (true) {
    bool refresh_needed = editor_process_keypress();
    if (refresh_needed) {
      editor_refresh_screen();
    }
  }
}


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)
cmpl   $0x2,-0x8(%rbp)
je     11a3 <main+0x43>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1030 <editor_init@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <editor_open@plt>
mov    $0x0,%al
call   1040 <editor_refresh_screen@plt>
mov    $0x0,%al
call   1060 <editor_process_keypress@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11d9 <main+0x79>
mov    $0x0,%al
call   1040 <editor_refresh_screen@plt>
jmp    11be <main+0x5e>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    119d <main+0x3d>
mov    %rsi,%rbx
xor    %eax,%eax
call   1030 <editor_init@plt>
mov    0x8(%rbx),%rdi
call   1050 <editor_open@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <editor_refresh_screen@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <editor_process_keypress@plt>
test   %eax,%eax
je     1190 <main+0x30>
jmp    1180 <main+0x20>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: openemacs <filename>\0A\00"
@EXIT_FAILURE = global i32 0
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 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = call i32 (...) @editor_init()
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @editor_open(i8* %18)
%20 = call i32 (...) @editor_refresh_screen()
br label %21
21: ; preds = %14, %27
%22 = call i32 (...) @editor_process_keypress()
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (...) @editor_refresh_screen()
br label %27
27: ; preds = %25, %21
br label %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: openemacs <filename>\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = tail call i32 (...) @editor_init()
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @editor_open(i8* %12)
br label %14
14: ; preds = %16, %9
%15 = tail call i32 (...) @editor_refresh_screen()
br label %16
16: ; preds = %14, %16
%17 = tail call i32 (...) @editor_process_keypress()
%18 = icmp eq i32 %17, 0
br i1 %18, label %16, label %14
}