#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 */
typedef int /*<<< orphan*/ template;
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
struct obj {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ basename(char const *);
struct obj *desc_parse(char *);
int /*<<< orphan*/ desc_print_error_report();
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int getopt_long(int, char **, char *, struct option const *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ lua_codegen(char *, char const *, struct obj *);
#define no_argument 129
int /*<<< orphan*/ obj_free(struct obj *);
char *optarg;
int optind;
char *read_input_file(char const *);
#define required_argument 128
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char const *);
char *strerror(int /*<<< orphan*/);
char *strip_extension(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int r = 1;
  int c;
  int is_source = 0;
  int is_header = 0;
  const char *name = NULL;
  const char *template_path = "./templates";
  static const struct option options[] = {
      {"header", no_argument, 0, 'H'},
      {"help", no_argument, 0, 'h'},
      {"name", required_argument, 0, 'n'},
      {"source", no_argument, 0, 's'},
      {"template-path", required_argument, 0, 't'},
      {0, 0, 0, 0}};
  while (1) {
    c = getopt_long(argc, argv, "Hhn:st:", options, NULL);
    if (c == -1)
      break;
    switch (c) {
    case 'H':
      is_header = 1;
      break;
    case 's':
      is_source = 1;
      break;
    case 'h':
      usage();
      return 0;
    case 'n':
      name = optarg;
      break;
    case 't':
      template_path = optarg;
      break;
    default:
      usage();
      return 1;
    }
  }
  if (is_header && is_source) {
    fprintf(stderr, "Can't output source and header at the same time.\n");
    usage();
    return 1;
  }
  if (!is_header && !is_source) {
    fprintf(stderr,
            "Please specify either source or header output: -s or -H.\n");
    usage();
    return 1;
  }
  if (argc - optind < 1) {
    fprintf(stderr, "Too few arguments!\n");
    return 1;
  }
  const char *input_path = argv[optind];
  if (strcmp("-", input_path) == 0)
    input_path = "/dev/stdin";
  char *input = read_input_file(input_path);
  if (!input) {
    fprintf(stderr, "Failed to read input file '%s': %s\n", input_path,
            strerror(errno));
    return 1;
  }
  if (!name)
    name = strip_extension(basename(input_path));
  struct obj *obj = desc_parse(input);
  if (!obj) {
    desc_print_error_report();
    goto failure;
  }
  char template[256];
  snprintf(template, sizeof(template), "%s/%s", template_path,
           is_header ? "c_header.lua" : "c_source.lua");
  template[sizeof(template) - 1] = '\0';
  lua_codegen(template, name, obj);
  obj_free(obj);
  r = 0;
failure:
  free(input);
  return r;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xeb7(%rip),%rdx
lea    0x2b3a(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1060 <getopt_long@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1252 <main+0x72>
jmp    12ea <main+0x10a>
mov    -0x18(%rbp),%eax
add    $0xffffffb8,%eax
mov    %eax,%ecx
mov    %rcx,-0x158(%rbp)
sub    $0x2c,%eax
ja     12d2 <main+0xf2>
mov    -0x158(%rbp),%rax
lea    0xd88(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x20(%rbp)
jmp    12e5 <main+0x105>
movl   $0x1,-0x1c(%rbp)
jmp    12e5 <main+0x105>
mov    $0x0,%al
call   10e0 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    14f1 <main+0x311>
mov    0x2d45(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    12e5 <main+0x105>
mov    0x2d32(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    12e5 <main+0x105>
mov    $0x0,%al
call   10e0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f1 <main+0x311>
jmp    1221 <main+0x41>
cmpl   $0x0,-0x20(%rbp)
je     1328 <main+0x148>
cmpl   $0x0,-0x1c(%rbp)
je     1328 <main+0x148>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
lea    0xde0(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   10e0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f1 <main+0x311>
cmpl   $0x0,-0x20(%rbp)
jne    1366 <main+0x186>
cmpl   $0x0,-0x1c(%rbp)
jne    1366 <main+0x186>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x0,%al
call   10e0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f1 <main+0x311>
mov    -0x8(%rbp),%eax
mov    0x2c70(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x1,%eax
jge    139e <main+0x1be>
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f1 <main+0x311>
mov    -0x10(%rbp),%rax
mov    0x2c37(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xdaf(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    13d9 <main+0x1f9>
lea    0xd9b(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10d0 <read_input_file@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1443 <main+0x263>
mov    0x2bd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x164(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x160(%rbp)
mov    0x2bb6(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x164(%rbp),%edi
mov    -0x160(%rbp),%rdx
mov    %rax,%rcx
lea    0xd4b(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f1 <main+0x311>
cmpq   $0x0,-0x28(%rbp)
jne    1462 <main+0x282>
mov    -0x38(%rbp),%rdi
call   10b0 <basename@plt>
mov    %eax,%edi
call   10c0 <strip_extension@plt>
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <desc_parse@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1486 <main+0x2a6>
mov    $0x0,%al
call   1070 <desc_print_error_report@plt>
jmp    14e2 <main+0x302>
lea    -0x150(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%edx
lea    0xd17(%rip),%r8
lea    0xd03(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%r8
mov    $0x100,%esi
lea    0xcea(%rip),%rdx
call   1080 <snprintf@plt>
movb   $0x0,-0x51(%rbp)
lea    -0x150(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x48(%rbp),%rdx
call   10f0 <lua_codegen@plt>
mov    -0x48(%rbp),%rdi
call   1050 <obj_free@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe03(%rip),%r15
xor    %eax,%eax
mov    %rax,0x18(%rsp)
lea    0xe27(%rip),%r12
lea    0x2b5e(%rip),%r13
mov    0x2ddf(%rip),%r14
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
jmp    1233 <main+0x53>
nopw   0x0(%rax,%rax,1)
mov    (%r14),%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
call   1060 <getopt_long@plt>
cmp    $0x74,%eax
je     1230 <main+0x50>
cmp    $0x67,%eax
jle    1264 <main+0x84>
cmp    $0x73,%eax
je     127c <main+0x9c>
cmp    $0x6e,%eax
jne    1285 <main+0xa5>
mov    (%r14),%rax
mov    %rax,0x10(%rsp)
jmp    1233 <main+0x53>
cmp    $0xffffffff,%eax
je     129c <main+0xbc>
cmp    $0x48,%eax
jne    13c0 <main+0x1e0>
movl   $0x1,0xc(%rsp)
jmp    1233 <main+0x53>
mov    $0x1,%al
mov    %rax,0x18(%rsp)
jmp    1233 <main+0x53>
cmp    $0x68,%eax
jne    13c0 <main+0x1e0>
xor    %ebp,%ebp
xor    %eax,%eax
call   10e0 <usage@plt>
jmp    13cc <main+0x1ec>
mov    0xc(%rsp),%r12d
test   %r12d,%r12d
sete   %al
mov    0x18(%rsp),%rdx
mov    %edx,%ecx
not    %cl
or     %al,%cl
test   $0x1,%cl
jne    12cc <main+0xec>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xd73(%rip),%rsi
jmp    13b9 <main+0x1d9>
test   %r12d,%r12d
setne  %al
or     %dl,%al
test   $0x1,%al
je     13a9 <main+0x1c9>
mov    0x2cfd(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    13e0 <main+0x200>
mov    (%rbx,%rax,8),%rbx
lea    0xdc1(%rip),%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
lea    0xdb1(%rip),%rbp
cmovne %rbx,%rbp
mov    %rbp,%rdi
call   10d0 <read_input_file@plt>
test   %rax,%rax
je     13f9 <main+0x219>
mov    %rax,%rbx
mov    0x10(%rsp),%r14
test   %r14,%r14
jne    133f <main+0x15f>
mov    %rbp,%rdi
call   10b0 <basename@plt>
mov    %eax,%edi
call   10c0 <strip_extension@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <desc_parse@plt>
test   %rax,%rax
je     1428 <main+0x248>
mov    %rax,%rbp
test   %r12d,%r12d
lea    0xd94(%rip),%rax
lea    0xd9a(%rip),%r8
cmovne %rax,%r8
lea    0xd7c(%rip),%rdx
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r15,%rcx
call   1080 <snprintf@plt>
movb   $0x0,0x11f(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   10f0 <lua_codegen@plt>
mov    %rbp,%rdi
call   1050 <obj_free@plt>
xor    %ebp,%ebp
jmp    1434 <main+0x254>
mov    0x2c20(%rip),%rax
mov    (%rax),%edi
lea    0xcb3(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %eax,%eax
call   10e0 <usage@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
lea    0xcb6(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13c7 <main+0x1e7>
mov    0x2bd0(%rip),%rax
mov    (%rax),%ebx
mov    0x2bbf(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xcb0(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13c7 <main+0x1e7>
xor    %eax,%eax
call   1070 <desc_print_error_report@plt>
mov    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    13cc <main+0x1ec>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
%struct.obj = type { i32 }
@.str = [12 x i8] c"./templates\00"
@main.options = internal constant [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8 -127, i32 0, i32 72 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32 0, i32 116 }, %struct.option zeroinitializer]
@.str.1 = [7 x i8] c"header\00"
@.str.2 = [5 x i8] c"help\00"
@.str.3 = [5 x i8] c"name\00"
@.str.4 = [7 x i8] c"source\00"
@.str.5 = [14 x i8] c"template-path\00"
@.str.6 = [8 x i8] c"Hhn:st:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.7 = [50 x i8] c"Can't output source and header at the same time.\0A\00"
@.str.8 = [58 x i8] c"Please specify either source or header output: -s or -H.\0A\00"
@optind = global i32 0
@.str.9 = [20 x i8] c"Too few arguments!\0A\00"
@.str.10 = [2 x i8] c"-\00"
@.str.11 = [11 x i8] c"/dev/stdin\00"
@.str.12 = [36 x i8] c"Failed to read input file '%s': %s\0A\00"
@errno = global i32 0
@.str.13 = [6 x i8] c"%s/%s\00"
@.str.14 = [13 x i8] c"c_header.lua\00"
@.str.15 = [13 x i8] c"c_source.lua\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca %struct.obj*
%15 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 0, i32* %8
store i32 0, i32* %9
store i8* null, i8** %10
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %11
br label %16
16: ; preds = %2, %35
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt_long(i32 %17, i8** %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %23
22: ; preds = %16
br label %36
23: ; preds = %16
%24 = load i32, i32* %7
switch i32 %24, label %33 [
i32 72, label %25
i32 115, label %26
i32 104, label %27
i32 110, label %29
i32 116, label %31
]
25: ; preds = %23
store i32 1, i32* %9
br label %35
26: ; preds = %23
store i32 1, i32* %8
br label %35
27: ; preds = %23
%28 = call i32 (...) @usage()
store i32 0, i32* %3
br label %118
29: ; preds = %23
%30 = load i8*, i8** @optarg
store i8* %30, i8** %10
br label %35
31: ; preds = %23
%32 = load i8*, i8** @optarg
store i8* %32, i8** %11
br label %35
33: ; preds = %23
%34 = call i32 (...) @usage()
store i32 1, i32* %3
br label %118
35: ; preds = %31, %29, %26, %25
br label %16
36: ; preds = %22
%37 = load i32, i32* %9
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %36
%40 = load i32, i32* %8
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
%45 = call i32 (...) @usage()
store i32 1, i32* %3
br label %118
46: ; preds = %39, %36
%47 = load i32, i32* %9
%48 = icmp ne i32 %47, 0
br i1 %48, label %56, label %49
49: ; preds = %46
%50 = load i32, i32* %8
%51 = icmp ne i32 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%55 = call i32 (...) @usage()
store i32 1, i32* %3
br label %118
56: ; preds = %49, %46
%57 = load i32, i32* %4
%58 = load i32, i32* @optind
%59 = sub nsw i32 %57, %58
%60 = icmp slt i32 %59, 1
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %118
64: ; preds = %56
%65 = load i8**, i8*** %5
%66 = load i32, i32* @optind
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
store i8* %69, i8** %12
%70 = load i8*, i8** %12
%71 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %64
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8** %12
br label %74
74: ; preds = %73, %64
%75 = load i8*, i8** %12
%76 = call i8* @read_input_file(i8* %75)
store i8* %76, i8** %13
%77 = load i8*, i8** %13
%78 = icmp ne i8* %77, null
br i1 %78, label %85, label %79
79: ; preds = %74
%80 = load i32, i32* @stderr
%81 = load i8*, i8** %12
%82 = load i32, i32* @errno
%83 = call i8* @strerror(i32 %82)
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i8* %81, i8* %83)
store i32 1, i32* %3
br label %118
85: ; preds = %74
%86 = load i8*, i8** %10
%87 = icmp ne i8* %86, null
br i1 %87, label %92, label %88
88: ; preds = %85
%89 = load i8*, i8** %12
%90 = call i32 @basename(i8* %89)
%91 = call i8* @strip_extension(i32 %90)
store i8* %91, i8** %10
br label %92
92: ; preds = %88, %85
%93 = load i8*, i8** %13
%94 = call %struct.obj* @desc_parse(i8* %93)
store %struct.obj* %94, %struct.obj** %14
%95 = load %struct.obj*, %struct.obj** %14
%96 = icmp ne %struct.obj* %95, null
br i1 %96, label %99, label %97
97: ; preds = %92
%98 = call i32 (...) @desc_print_error_report()
br label %114
99: ; preds = %92
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%101 = load i8*, i8** %11
%102 = load i32, i32* %9
%103 = icmp ne i32 %102, 0
%104 = zext i1 %103 to i64
%105 = select i1 %103, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0)
%106 = call i32 @snprintf(i8* %100, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* %101, i8* %105)
%107 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 255
store i8 0, i8* %107
%108 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%109 = load i8*, i8** %10
%110 = load %struct.obj*, %struct.obj** %14
%111 = call i32 @lua_codegen(i8* %108, i8* %109, %struct.obj* %110)
%112 = load %struct.obj*, %struct.obj** %14
%113 = call i32 @obj_free(%struct.obj* %112)
store i32 0, i32* %6
br label %114
114: ; preds = %99, %97
%115 = load i8*, i8** %13
%116 = call i32 @free(i8* %115)
%117 = load i32, i32* %6
store i32 %117, i32* %3
br label %118
118: ; preds = %114, %79, %61, %52, %42, %33, %27
%119 = load i32, i32* %3
ret i32 %119
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
%struct.obj = type { i32 }
@.str = [12 x i8] c"./templates\00"
@main.options = internal constant [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8 -127, i32 0, i32 72 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 110 }, %struct.option { i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32 0, i32 115 }, %struct.option { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32 0, i32 116 }, %struct.option zeroinitializer]
@.str.1 = [7 x i8] c"header\00"
@.str.2 = [5 x i8] c"help\00"
@.str.3 = [5 x i8] c"name\00"
@.str.4 = [7 x i8] c"source\00"
@.str.5 = [14 x i8] c"template-path\00"
@.str.6 = [8 x i8] c"Hhn:st:\00"
@optarg = global i8* null
@stderr = global i32 0
@.str.7 = [50 x i8] c"Can't output source and header at the same time.\0A\00"
@.str.8 = [58 x i8] c"Please specify either source or header output: -s or -H.\0A\00"
@optind = global i32 0
@.str.9 = [20 x i8] c"Too few arguments!\0A\00"
@.str.10 = [2 x i8] c"-\00"
@.str.11 = [11 x i8] c"/dev/stdin\00"
@.str.12 = [36 x i8] c"Failed to read input file '%s': %s\0A\00"
@errno = global i32 0
@.str.13 = [6 x i8] c"%s/%s\00"
@.str.14 = [13 x i8] c"c_header.lua\00"
@.str.15 = [13 x i8] c"c_source.lua\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i8]
br label %4
4: ; preds = %16, %2
%5 = phi i1 [ false, %2 ], [ true, %16 ]
%6 = phi i32 [ 0, %2 ], [ %10, %16 ]
%7 = phi i8* [ null, %2 ], [ %14, %16 ]
%8 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %2 ], [ %17, %16 ]
br label %9
9: ; preds = %16, %4
%10 = phi i32 [ %6, %4 ], [ 1, %16 ]
%11 = phi i8* [ %7, %4 ], [ %14, %16 ]
%12 = phi i8* [ %8, %4 ], [ %17, %16 ]
br label %13
13: ; preds = %9, %21
%14 = phi i8* [ %11, %9 ], [ %22, %21 ]
%15 = phi i8* [ %12, %9 ], [ %17, %21 ]
br label %16
16: ; preds = %13, %23
%17 = phi i8* [ %24, %23 ], [ %15, %13 ]
%18 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
switch i32 %18, label %25 [
i32 -1, label %27
i32 72, label %9
i32 115, label %4
i32 104, label %19
i32 110, label %21
i32 116, label %23
]
19: ; preds = %16
%20 = tail call i32 (...) @usage()
br label %81
21: ; preds = %16
%22 = load i8*, i8** @optarg
br label %13
23: ; preds = %16
%24 = load i8*, i8** @optarg
br label %16
25: ; preds = %16
%26 = tail call i32 (...) @usage()
br label %81
27: ; preds = %16
%28 = icmp ne i32 %10, 0
%29 = and i1 %28, %5
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
%33 = tail call i32 (...) @usage()
br label %81
34: ; preds = %27
%35 = or i1 %28, %5
br i1 %35, label %40, label %36
36: ; preds = %34
%37 = load i32, i32* @stderr
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%39 = tail call i32 (...) @usage()
br label %81
40: ; preds = %34
%41 = load i32, i32* @optind
%42 = icmp slt i32 %41, %0
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %81
46: ; preds = %40
%47 = sext i32 %41 to i64
%48 = getelementptr inbounds i8*, i8** %1, i64 %47
%49 = load i8*, i8** %48
%50 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* %49)
%51 = icmp eq i64 %50, 0
%52 = select i1 %51, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %49
%53 = tail call i8* @read_input_file(i8* %52)
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %60
55: ; preds = %46
%56 = load i32, i32* @stderr
%57 = load i32, i32* @errno
%58 = tail call i8* @strerror(i32 %57)
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i8* %52, i8* %58)
br label %81
60: ; preds = %46
%61 = icmp eq i8* %14, null
br i1 %61, label %62, label %65
62: ; preds = %60
%63 = tail call i32 @basename(i8* %52)
%64 = tail call i8* @strip_extension(i32 %63)
br label %65
65: ; preds = %62, %60
%66 = phi i8* [ %14, %60 ], [ %64, %62 ]
%67 = tail call %struct.obj* @desc_parse(i8* %53)
%68 = icmp eq %struct.obj* %67, null
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = tail call i32 (...) @desc_print_error_report()
br label %78
71: ; preds = %65
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%73 = select i1 %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.15, i64 0, i64 0)
%74 = call i32 @snprintf(i8* %72, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* %17, i8* %73)
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 255
store i8 0, i8* %75
%76 = call i32 @lua_codegen(i8* %72, i8* %66, %struct.obj* %67)
%77 = call i32 @obj_free(%struct.obj* %67)
br label %78
78: ; preds = %71, %69
%79 = phi i32 [ 0, %71 ], [ 1, %69 ]
%80 = call i32 @free(i8* %53)
br label %81
81: ; preds = %55, %78, %43, %36, %30, %25, %19
%82 = phi i32 [ 1, %30 ], [ 1, %43 ], [ 1, %36 ], [ 1, %25 ], [ 0, %19 ], [ %79, %78 ], [ 1, %55 ]
ret i32 %82
}