#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ init_daemon();
int /*<<< orphan*/ keymacs_on_bind_key();
int /*<<< orphan*/ log_error(char *);
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ trap_finalize();
int /*<<< orphan*/ xkey_initialize();
int /*<<< orphan*/ xkey_loop();
int main(int argc, char **argv) {
  if (argc == 2) {
    if (strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "--daemon") == 0) {
      init_daemon();
    } else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
      print_help();
      return EXIT_SUCCESS;
    } else {
      log_error("main: Unknown argument");
      printf("\n");
      print_help();
      return EXIT_FAILURE;
    }
  } else if (argc > 2) {
    log_error("main: Too many arguments");
    printf("\n");
    print_help();
    return EXIT_FAILURE;
  }
  xkey_initialize();
  keymacs_on_bind_key();
  trap_finalize();
  xkey_loop();
  return EXIT_FAILURE;
}


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)
jne    1281 <main+0xf1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe41(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     11ec <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe26(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11f8 <main+0x68>
mov    $0x0,%al
call   1030 <init_daemon@plt>
jmp    127c <main+0xec>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe05(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1234 <main+0xa4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdea(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    124c <main+0xbc>
mov    $0x0,%al
call   10b0 <print_help@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12e8 <main+0x158>
lea    0xdc3(%rip),%rdi
call   1050 <log_error@plt>
lea    0xdce(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   10b0 <print_help@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12e8 <main+0x158>
jmp    12c0 <main+0x130>
cmpl   $0x2,-0x8(%rbp)
jle    12bb <main+0x12b>
lea    0xd9d(%rip),%rdi
call   1050 <log_error@plt>
lea    0xd8f(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   10b0 <print_help@plt>
mov    0x2d2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12e8 <main+0x158>
jmp    12c0 <main+0x130>
mov    $0x0,%al
call   10a0 <xkey_initialize@plt>
mov    $0x0,%al
call   1080 <keymacs_on_bind_key@plt>
mov    $0x0,%al
call   1040 <trap_finalize@plt>
mov    $0x0,%al
call   1090 <xkey_loop@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    11f6 <main+0x66>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1217 <main+0x87>
mov    0x8(%rbx),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1217 <main+0x87>
mov    0x8(%rbx),%rdi
lea    0xe3e(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1245 <main+0xb5>
mov    0x8(%rbx),%rdi
lea    0xe2c(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1245 <main+0xb5>
lea    0xe22(%rip),%rdi
jmp    11ff <main+0x6f>
jle    121e <main+0x8e>
lea    0xe2e(%rip),%rdi
call   1060 <log_error@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   10b0 <print_help@plt>
jmp    123a <main+0xaa>
xor    %eax,%eax
call   1030 <init_daemon@plt>
xor    %eax,%eax
call   10a0 <xkey_initialize@plt>
xor    %eax,%eax
call   1080 <keymacs_on_bind_key@plt>
xor    %eax,%eax
call   1050 <trap_finalize@plt>
xor    %eax,%eax
call   1090 <xkey_loop@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
xor    %eax,%eax
call   10b0 <print_help@plt>
mov    0x2d85(%rip),%rax
jmp    1241 <main+0xb1>

LLVM IR (-O0):
@.str = [3 x i8] c"-d\00"
@.str.1 = [9 x i8] c"--daemon\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [7 x i8] c"--help\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [23 x i8] c"main: Unknown argument\00"
@.str.5 = [2 x i8] c"\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [25 x i8] c"main: Too many arguments\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 eq i32 %6, 2
br i1 %7, label %8, label %43
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14, %8
%21 = call i32 (...) @init_daemon()
br label %42
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28, %22
%35 = call i32 (...) @print_help()
%36 = load i32, i32* @EXIT_SUCCESS
store i32 %36, i32* %3
br label %58
37: ; preds = %28
%38 = call i32 @log_error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%39 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%40 = call i32 (...) @print_help()
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %3
br label %58
42: ; preds = %20
br label %52
43: ; preds = %2
%44 = load i32, i32* %4
%45 = icmp sgt i32 %44, 2
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = call i32 @log_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%48 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%49 = call i32 (...) @print_help()
%50 = load i32, i32* @EXIT_FAILURE
store i32 %50, i32* %3
br label %58
51: ; preds = %43
br label %52
52: ; preds = %51, %42
%53 = call i32 (...) @xkey_initialize()
%54 = call i32 (...) @keymacs_on_bind_key()
%55 = call i32 (...) @trap_finalize()
%56 = call i32 (...) @xkey_loop()
%57 = load i32, i32* @EXIT_FAILURE
store i32 %57, i32* %3
br label %58
58: ; preds = %52, %46, %37, %34
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@.str = [3 x i8] c"-d\00"
@.str.1 = [9 x i8] c"--daemon\00"
@.str.2 = [3 x i8] c"-h\00"
@.str.3 = [7 x i8] c"--help\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [23 x i8] c"main: Unknown argument\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [25 x i8] c"main: Too many arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %29
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = load i8*, i8** %5
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9, %4
%14 = tail call i32 (...) @init_daemon()
br label %35
15: ; preds = %9
%16 = load i8*, i8** %5
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19, %15
%24 = tail call i32 (...) @print_help()
br label %40
25: ; preds = %19
%26 = tail call i32 @log_error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%27 = tail call i32 @putchar(i32 10)
%28 = tail call i32 (...) @print_help()
br label %40
29: ; preds = %2
%30 = icmp sgt i32 %0, 2
br i1 %30, label %31, label %35
31: ; preds = %29
%32 = tail call i32 @log_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%33 = tail call i32 @putchar(i32 10)
%34 = tail call i32 (...) @print_help()
br label %40
35: ; preds = %29, %13
%36 = tail call i32 (...) @xkey_initialize()
%37 = tail call i32 (...) @keymacs_on_bind_key()
%38 = tail call i32 (...) @trap_finalize()
%39 = tail call i32 (...) @xkey_loop()
br label %40
40: ; preds = %35, %31, %25, %23
%41 = phi i32* [ @EXIT_FAILURE, %35 ], [ @EXIT_SUCCESS, %23 ], [ @EXIT_FAILURE, %25 ], [ @EXIT_FAILURE, %31 ]
%42 = load i32, i32* %41
ret i32 %42
}