#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__ check_ending(char *, char *);
int /*<<< orphan*/ heuristics(char *);
int /*<<< orphan*/ lua(char *);
char *parse_args(int, char **);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ py(char *);
int main(int argc, char **argv) {
  char *file = parse_args(argc, argv);
  if (check_ending(file, "^.*\\.luac$")) {
    puts("File has 'luac' ending, assuming lua bytecode.\n");
    lua(file);
  } else if (check_ending(file, "^.*\\.pyc$")) {
    puts("File has 'pyc' ending, assuming python bytecode.\n");
    py(file);
  } else {
    heuristics(file);
  }
  return 0;
}


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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <parse_args@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1070 <check_ending@plt>
cmp    $0x0,%rax
je     11ba <main+0x5a>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1050 <lua@plt>
jmp    11fc <main+0x9c>
mov    -0x18(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1070 <check_ending@plt>
cmp    $0x0,%rax
je     11ee <main+0x8e>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1080 <py@plt>
jmp    11f7 <main+0x97>
mov    -0x18(%rbp),%rdi
call   1060 <heuristics@plt>
jmp    11fc <main+0x9c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
call   1040 <parse_args@plt>
mov    %rax,%rbx
lea    0xe90(%rip),%rsi
mov    %rax,%rdi
call   1070 <check_ending@plt>
test   %rax,%rax
je     1193 <main+0x33>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <lua@plt>
jmp    11c5 <main+0x65>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1070 <check_ending@plt>
test   %rax,%rax
je     11bd <main+0x5d>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1080 <py@plt>
jmp    11c5 <main+0x65>
mov    %rbx,%rdi
call   1060 <heuristics@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"^.*\\.luac$\00"
@.str.1 = [48 x i8] c"File has 'luac' ending, assuming lua bytecode.\0A\00"
@.str.2 = [10 x i8] c"^.*\\.pyc$\00"
@.str.3 = [50 x i8] c"File has 'pyc' ending, assuming python bytecode.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i8* @parse_args(i32 %7, i8** %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = call i64 @check_ending(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = call i32 @puts(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8*, i8** %6
%16 = call i32 @lua(i8* %15)
br label %29
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call i64 @check_ending(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%23 = load i8*, i8** %6
%24 = call i32 @py(i8* %23)
br label %28
25: ; preds = %17
%26 = load i8*, i8** %6
%27 = call i32 @heuristics(i8* %26)
br label %28
28: ; preds = %25, %21
br label %29
29: ; preds = %28, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"^.*\\.luac$\00"
@.str.1 = [48 x i8] c"File has 'luac' ending, assuming lua bytecode.\0A\00"
@.str.2 = [10 x i8] c"^.*\\.pyc$\00"
@.str.3 = [50 x i8] c"File has 'pyc' ending, assuming python bytecode.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i8* @parse_args(i32 %0, i8** %1)
%4 = tail call i64 @check_ending(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @lua(i8* %3)
br label %17
9: ; preds = %2
%10 = tail call i64 @check_ending(i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @py(i8* %3)
br label %17
15: ; preds = %9
%16 = tail call i32 @heuristics(i8* %3)
br label %17
17: ; preds = %12, %15, %6
ret i32 0
}