#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int my_main(char *, char *);
char *optarg;
int optind;
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char *file_output = NULL;
  int c = 0;
  while ((c = getopt(argc, argv, "o:")) != -1) {
    switch (c) {
    case 'o':
      file_output = optarg;
      break;
    }
  }
  if (optind < argc) {
    return my_main(argv[optind], file_output == NULL ? "a.s" : file_output);
  } else {
    fprintf(stderr, "You need to provide a source file to compile\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe8d(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11a8 <main+0x68>
mov    -0x1c(%rbp),%eax
sub    $0x6f,%eax
jne    11a3 <main+0x63>
jmp    1195 <main+0x55>
mov    0x2e5c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1165 <main+0x25>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    1206 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x2e1b(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11eb <main+0xab>
lea    0xe21(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11f3 <main+0xb3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <my_main@plt>
add    $0x30,%rsp
pop    %rbp
ret
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r15d,%r15d
lea    0xea9(%rip),%r14
mov    0x2e9a(%rip),%r12
xchg   %ax,%ax
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
je     117d <main+0x3d>
cmp    $0x6f,%eax
jne    1160 <main+0x20>
mov    (%r12),%r15
jmp    1160 <main+0x20>
mov    0x2e5c(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    11aa <main+0x6a>
mov    (%rbx,%rax,8),%rdi
test   %r15,%r15
lea    0xe6a(%rip),%rsi
cmovne %r15,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <my_main@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"o:\00"
@optarg = global i8* null
@optind = global i32 0
@.str.1 = [4 x i8] c"a.s\00"
@stderr = global i32 0
@.str.2 = [46 x i8] c"You need to provide a source file to compile\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 i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %17, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %7
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* %7
switch i32 %14, label %17 [
i32 111, label %15
]
15: ; preds = %13
%16 = load i8*, i8** @optarg
store i8* %16, i8** %6
br label %17
17: ; preds = %13, %15
br label %8
18: ; preds = %8
%19 = load i32, i32* @optind
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* @optind
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = load i8*, i8** %6
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %31
30: ; preds = %22
br label %33
31: ; preds = %22
%32 = load i8*, i8** %6
br label %33
33: ; preds = %31, %30
%34 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %30 ], [ %32, %31 ]
%35 = call i32 @my_main(i8* %27, i8* %34)
ret i32 %35
36: ; preds = %18
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"o:\00"
@optarg = global i8* null
@optind = global i32 0
@.str.1 = [4 x i8] c"a.s\00"
@stderr = global i32 0
@.str.2 = [46 x i8] c"You need to provide a source file to compile\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %7, %2
%4 = phi i8* [ %8, %7 ], [ null, %2 ]
br label %5
5: ; preds = %3, %5
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %5 [
i32 -1, label %9
i32 111, label %7
]
7: ; preds = %5
%8 = load i8*, i8** @optarg
br label %3
9: ; preds = %5
%10 = load i32, i32* @optind
%11 = icmp slt i32 %10, %0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = icmp eq i8* %4, null
%17 = select i1 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4
%18 = tail call i32 @my_main(i8* %15, i8* %17)
ret i32 %18
19: ; preds = %9
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
}