#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ iolib_open();
int lua_dofile(char *);
scalar_t__ lua_dostring(char *);
int /*<<< orphan*/ manual_input();
int /*<<< orphan*/ mathlib_open();
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strchr(char *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlib_open();
int main(int argc, char *argv[]) {
  int i;
  int result = 0;
  iolib_open();
  strlib_open();
  mathlib_open();
  if (argc < 2)
    manual_input();
  else
    for (i = 1; i < argc; i++) {
      if (strcmp(argv[i], "-") == 0)
        manual_input();
      else if (strcmp(argv[i], "-v") == 0)
        printf("%s  %s\n(written by %s)\n\n", "Lua 2.5.1",
               "Copyright (C) 1994-1996 TeCGraf",
               "W. Celes, R. Ierusalimschy & L. H. de Figueiredo");
      else if ((strcmp(argv[i], "-e") == 0 && i++) || strchr(argv[i], '=')) {
        if (lua_dostring(argv[i]) != 0) {
          fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
          return 1;
        }
      } else {
        result = lua_dofile(argv[i]);
        if (result) {
          if (result == 2) {
            fprintf(stderr, "lua: cannot execute file `%s' - ", argv[i]);
            perror(NULL);
          }
          return 1;
        }
      }
    }
  return result;
}


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)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   10b0 <iolib_open@plt>
mov    $0x0,%al
call   1040 <strlib_open@plt>
mov    $0x0,%al
call   1070 <mathlib_open@plt>
cmpl   $0x2,-0x8(%rbp)
jge    11f8 <main+0x48>
mov    $0x0,%al
call   10d0 <manual_input@plt>
jmp    13a9 <main+0x1f9>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13a4 <main+0x1f4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xde2(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1239 <main+0x89>
mov    $0x0,%al
call   10d0 <manual_input@plt>
jmp    1391 <main+0x1e1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdb6(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1281 <main+0xd1>
lea    0xda3(%rip),%rdi
lea    0xdb5(%rip),%rsi
lea    0xdb8(%rip),%rdx
lea    0xdd1(%rip),%rcx
call   1060 <printf@plt>
jmp    138c <main+0x1dc>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xde5(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12b7 <main+0x107>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jne    12d7 <main+0x127>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     1324 <main+0x174>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <lua_dostring@plt>
cmp    $0x0,%rax
je     131f <main+0x16f>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd6e(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13af <main+0x1ff>
jmp    1387 <main+0x1d7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1090 <lua_dofile@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1382 <main+0x1d2>
cmpl   $0x2,-0x18(%rbp)
jne    1376 <main+0x1c6>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd36(%rip),%rsi
call   10a0 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13af <main+0x1ff>
jmp    1387 <main+0x1d7>
jmp    138c <main+0x1dc>
jmp    1391 <main+0x1e1>
jmp    1396 <main+0x1e6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ff <main+0x4f>
jmp    13a9 <main+0x1f9>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
xor    %r14d,%r14d
xor    %eax,%eax
call   10b0 <iolib_open@plt>
xor    %eax,%eax
call   1040 <strlib_open@plt>
xor    %eax,%eax
call   1070 <mathlib_open@plt>
cmp    $0x2,%r15d
jge    11eb <main+0x3b>
xor    %eax,%eax
call   10d0 <manual_input@plt>
jmp    12ff <main+0x14f>
mov    $0x1,%r13d
lea    0xe08(%rip),%r14
jmp    1214 <main+0x64>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10d0 <manual_input@plt>
add    $0x1,%r13d
cmp    %r15d,%r13d
jge    12ce <main+0x11e>
movslq %r13d,%rbp
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1200 <main+0x50>
mov    (%rbx,%rbp,8),%rdi
lea    0xdcf(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1280 <main+0xd0>
mov    (%rbx,%rbp,8),%rdi
lea    0xe31(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12a6 <main+0xf6>
movslq %r13d,%r12
mov    (%rbx,%r12,8),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    12b2 <main+0x102>
mov    (%rbx,%r12,8),%rdi
call   1090 <lua_dofile@plt>
test   %eax,%eax
je     1207 <main+0x57>
jmp    12f4 <main+0x144>
nopw   0x0(%rax,%rax,1)
lea    0xd7e(%rip),%rdi
lea    0xd90(%rip),%rsi
lea    0xd93(%rip),%rdx
lea    0xdac(%rip),%rcx
call   1060 <printf@plt>
jmp    1207 <main+0x57>
test   %r13d,%r13d
je     12c6 <main+0x116>
add    $0x1,%r13d
movslq %r13d,%r12
mov    (%rbx,%r12,8),%rdi
call   1030 <lua_dostring@plt>
test   %rax,%rax
je     1207 <main+0x57>
jmp    12d3 <main+0x123>
mov    $0x1,%r13d
jmp    1252 <main+0xa2>
xor    %r14d,%r14d
jmp    12ff <main+0x14f>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r12,8),%rdx
lea    0xd95(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%r14d
jmp    12ff <main+0x14f>
mov    $0x1,%r14d
cmp    $0x2,%eax
je     1311 <main+0x161>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cc8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r12,8),%rdx
lea    0xd79(%rip),%rsi
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   10c0 <perror@plt>
jmp    12ff <main+0x14f>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [3 x i8] c"-v\00"
@.str.2 = [25 x i8] c"%s %s\0A(written by %s)\0A\0A\00"
@.str.3 = [10 x i8] c"Lua 2.5.1\00"
@.str.4 = [32 x i8] c"Copyright (C) 1994-1996 TeCGraf\00"
@.str.5 = [49 x i8] c"W. Celes, R. Ierusalimschy & L. H. de Figueiredo\00"
@.str.6 = [3 x i8] c"-e\00"
@stderr = global i32 0
@.str.7 = [34 x i8] c"lua: error running argument `%s'\0A\00"
@.str.8 = [33 x i8] c"lua: cannot execute file `%s' - \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = call i32 (...) @iolib_open()
%9 = call i32 (...) @strlib_open()
%10 = call i32 (...) @mathlib_open()
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @manual_input()
br label %107
15: ; preds = %2
store i32 1, i32* %6
br label %16
16: ; preds = %103, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %106
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = call i32 (...) @manual_input()
br label %102
30: ; preds = %20
%31 = load i8**, i8*** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %30
%39 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %101
40: ; preds = %30
%41 = load i8**, i8*** %5
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %40
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
%51 = icmp ne i32 %49, 0
br i1 %51, label %60, label %52
52: ; preds = %48, %40
%53 = load i8**, i8*** %5
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = call i64 @strchr(i8* %57, i8 signext 61)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %77
60: ; preds = %52, %48
%61 = load i8**, i8*** %5
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i64 @lua_dostring(i8* %65)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %76
68: ; preds = %60
%69 = load i32, i32* @stderr
%70 = load i8**, i8*** %5
%71 = load i32, i32* %6
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %74)
store i32 1, i32* %3
br label %109
76: ; preds = %60
br label %100
77: ; preds = %52
%78 = load i8**, i8*** %5
%79 = load i32, i32* %6
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8*, i8** %78, i64 %80
%82 = load i8*, i8** %81
%83 = call i32 @lua_dofile(i8* %82)
store i32 %83, i32* %7
%84 = load i32, i32* %7
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %99
86: ; preds = %77
%87 = load i32, i32* %7
%88 = icmp eq i32 %87, 2
br i1 %88, label %89, label %98
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = load i8**, i8*** %5
%92 = load i32, i32* %6
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8*, i8** %91, i64 %93
%95 = load i8*, i8** %94
%96 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %95)
%97 = call i32 @perror(i32* null)
br label %98
98: ; preds = %89, %86
store i32 1, i32* %3
br label %109
99: ; preds = %77
br label %100
100: ; preds = %99, %76
br label %101
101: ; preds = %100, %38
br label %102
102: ; preds = %101, %28
br label %103
103: ; preds = %102
%104 = load i32, i32* %6
%105 = add nsw i32 %104, 1
store i32 %105, i32* %6
br label %16
106: ; preds = %16
br label %107
107: ; preds = %106, %13
%108 = load i32, i32* %7
store i32 %108, i32* %3
br label %109
109: ; preds = %107, %98, %68
%110 = load i32, i32* %3
ret i32 %110
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [3 x i8] c"-v\00"
@.str.2 = [25 x i8] c"%s %s\0A(written by %s)\0A\0A\00"
@.str.3 = [10 x i8] c"Lua 2.5.1\00"
@.str.4 = [32 x i8] c"Copyright (C) 1994-1996 TeCGraf\00"
@.str.5 = [49 x i8] c"W. Celes, R. Ierusalimschy & L. H. de Figueiredo\00"
@.str.6 = [3 x i8] c"-e\00"
@stderr = global i32 0
@.str.7 = [34 x i8] c"lua: error running argument `%s'\0A\00"
@.str.8 = [33 x i8] c"lua: cannot execute file `%s' - \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @iolib_open()
%4 = tail call i32 (...) @strlib_open()
%5 = tail call i32 (...) @mathlib_open()
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (...) @manual_input()
br label %64
9: ; preds = %2, %60
%10 = phi i32 [ %62, %60 ], [ 1, %2 ]
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = tail call i32 (...) @manual_input()
br label %60
18: ; preds = %9
%19 = load i8*, i8** %12
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %60
24: ; preds = %18
%25 = load i8*, i8** %12
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = add nsw i32 %10, 1
%30 = icmp eq i32 %10, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = sext i32 %29 to i64
br label %40
33: ; preds = %28, %24
%34 = phi i32 [ %10, %24 ], [ 1, %28 ]
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i64 @strchr(i8* %37, i8 signext 61)
%39 = icmp eq i64 %38, 0
br i1 %39, label %52, label %40
40: ; preds = %31, %33
%41 = phi i64 [ %32, %31 ], [ %35, %33 ]
%42 = phi i32 [ %29, %31 ], [ %34, %33 ]
%43 = getelementptr inbounds i8*, i8** %1, i64 %41
%44 = load i8*, i8** %43
%45 = tail call i64 @lua_dostring(i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %60, label %47
47: ; preds = %40
%48 = getelementptr inbounds i8*, i8** %1, i64 %41
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %48
%51 = tail call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %50)
br label %64
52: ; preds = %33
%53 = load i8*, i8** %36
%54 = tail call i32 @lua_dofile(i8* %53)
switch i32 %54, label %64 [
i32 0, label %60
i32 2, label %55
]
55: ; preds = %52
%56 = load i32, i32* @stderr
%57 = load i8*, i8** %36
%58 = tail call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %57)
%59 = tail call i32 @perror(i32* null)
br label %64
60: ; preds = %52, %16, %40, %22
%61 = phi i32 [ %10, %16 ], [ %10, %22 ], [ %42, %40 ], [ %34, %52 ]
%62 = add nsw i32 %61, 1
%63 = icmp slt i32 %62, %0
br i1 %63, label %9, label %64
64: ; preds = %52, %60, %7, %55, %47
%65 = phi i32 [ 1, %47 ], [ 1, %55 ], [ 0, %7 ], [ 1, %52 ], [ 0, %60 ]
ret i32 %65
}