#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 */
scalar_t__ malloc(int);
char **parseopts(int, char **, int *);
int /*<<< orphan*/ print_version_info(char *);
int prompt();
int script(int, char **);
int /*<<< orphan*/ setup_error_handling();
int main(int argc, char **argv) {
  setup_error_handling();
  if (argc > 1) {
    int *script_argc = (int *)malloc(sizeof(int));
    char **script_and_args = parseopts(argc, argv, script_argc);
    if (*(script_argc)) {
      return script(*(script_argc), script_and_args);
    }
    return 0;
  } else {
    print_version_info(argv[0]);
    return prompt();
  }
}


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)
mov    $0x0,%al
call   1040 <setup_error_handling@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11d9 <main+0x79>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <parseopts@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     11cd <main+0x6d>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
call   1060 <script@plt>
mov    %eax,-0x4(%rbp)
jmp    11ef <main+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    11ef <main+0x8f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <print_version_info@plt>
mov    $0x0,%al
call   1030 <prompt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <setup_error_handling@plt>
cmp    $0x2,%ebp
jl     11a1 <main+0x41>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1070 <parseopts@plt>
mov    (%rbx),%edi
test   %edi,%edi
je     11b4 <main+0x54>
mov    %rax,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <script@plt>
mov    (%r14),%rdi
call   1080 <print_version_info@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <prompt@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @setup_error_handling()
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %27
11: ; preds = %2
%12 = call i64 @malloc(i32 4)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %6
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = load i32*, i32** %6
%17 = call i8** @parseopts(i32 %14, i8** %15, i32* %16)
store i8** %17, i8*** %7
%18 = load i32*, i32** %6
%19 = load i32, i32* %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %11
%22 = load i32*, i32** %6
%23 = load i32, i32* %22
%24 = load i8**, i8*** %7
%25 = call i32 @script(i32 %23, i8** %24)
store i32 %25, i32* %3
br label %33
26: ; preds = %11
store i32 0, i32* %3
br label %33
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @print_version_info(i8* %30)
%32 = call i32 (...) @prompt()
store i32 %32, i32* %3
br label %33
33: ; preds = %27, %26, %21
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 (...) @setup_error_handling()
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i64 @malloc(i32 4)
%7 = inttoptr i64 %6 to i32*
%8 = tail call i8** @parseopts(i32 %0, i8** %1, i32* %7)
%9 = load i32, i32* %7
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %5
%12 = tail call i32 @script(i32 %9, i8** %8)
br label %17
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = tail call i32 @print_version_info(i8* %14)
%16 = tail call i32 (...) @prompt()
br label %17
17: ; preds = %11, %5, %13
%18 = phi i32 [ %16, %13 ], [ %12, %11 ], [ 0, %5 ]
ret i32 %18
}