#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 cli_main(int, char **);
int curses_main(int, char **);
int gui_main(int, char **);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    usage(argv[0]);
  }
  if (strcmp(argv[1], "gui") == 0) {
    return gui_main(argc - 1, argv + 1);
  } else if (strcmp(argv[1], "cli") == 0) {
    return cli_main(argc - 1, argv + 1);
  } else if (strcmp(argv[1], "curses") == 0) {
    return curses_main(argc - 1, argv + 1);
  }
  usage(argv[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)
jge    117c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe75(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b5 <main+0x65>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1040 <gui_main@plt>
mov    %eax,-0x4(%rbp)
jmp    123d <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ee <main+0x9e>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1070 <cli_main@plt>
mov    %eax,-0x4(%rbp)
jmp    123d <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1227 <main+0xd7>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1060 <curses_main@plt>
mov    %eax,-0x4(%rbp)
jmp    123d <main+0xed>
jmp    122c <main+0xdc>
jmp    1231 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
cmp    $0x1,%edi
jg     1167 <main+0x17>
mov    (%r14),%rdi
call   1050 <usage@plt>
lea    0x8(%r14),%r15
mov    0x8(%r14),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b8 <main+0x68>
mov    (%r15),%rdi
lea    0xe7a(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ca <main+0x7a>
mov    (%r15),%rdi
lea    0xe6a(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11dc <main+0x8c>
mov    (%r14),%rdi
call   1050 <usage@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
add    $0xffffffff,%ebx
mov    %ebx,%edi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <gui_main@plt>
add    $0xffffffff,%ebx
mov    %ebx,%edi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <cli_main@plt>
add    $0xffffffff,%ebx
mov    %ebx,%edi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <curses_main@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"gui\00"
@.str.1 = [4 x i8] c"cli\00"
@.str.2 = [7 x i8] c"curses\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 slt i32 %6, 2
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @usage(i8* %11)
br label %13
13: ; preds = %8, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = call i32 @gui_main(i32 %21, i8** %23)
store i32 %24, i32* %3
br label %56
25: ; preds = %13
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = call i32 @cli_main(i32 %33, i8** %35)
store i32 %36, i32* %3
br label %56
37: ; preds = %25
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %49
43: ; preds = %37
%44 = load i32, i32* %4
%45 = sub nsw i32 %44, 1
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = call i32 @curses_main(i32 %45, i8** %47)
store i32 %48, i32* %3
br label %56
49: ; preds = %37
br label %50
50: ; preds = %49
br label %51
51: ; preds = %50
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 0
%54 = load i8*, i8** %53
%55 = call i32 @usage(i8* %54)
br label %56
56: ; preds = %51, %43, %31, %19
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [4 x i8] c"gui\00"
@.str.1 = [4 x i8] c"cli\00"
@.str.2 = [7 x i8] c"curses\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = add nsw i32 %0, -1
%14 = tail call i32 @gui_main(i32 %13, i8** %8)
br label %32
15: ; preds = %7
%16 = load i8*, i8** %8
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = add nsw i32 %0, -1
%21 = tail call i32 @cli_main(i32 %20, i8** %8)
br label %32
22: ; preds = %15
%23 = load i8*, i8** %8
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = add nsw i32 %0, -1
%28 = tail call i32 @curses_main(i32 %27, i8** %8)
br label %32
29: ; preds = %22
%30 = load i8*, i8** %1
%31 = tail call i32 @usage(i8* %30)
br label %32
32: ; preds = %29, %26, %19, %12
%33 = phi i32 [ %14, %12 ], [ %21, %19 ], [ %28, %26 ], [ 0, %29 ]
ret i32 %33
}