#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__ gets(char *);
int /*<<< orphan*/ iolib_open();
int /*<<< orphan*/ lua_dofile(char *);
int /*<<< orphan*/ lua_dostring(char *);
int /*<<< orphan*/ mathlib_open();
int /*<<< orphan*/ strlib_open();
int main(int argc, char *argv[]) {
  int i;
  iolib_open();
  strlib_open();
  mathlib_open();
  if (argc < 2) {
    char buffer[2048];
    while (gets(buffer) != 0)
      lua_dostring(buffer);
  } else
    for (i = 1; i < argc; i++)
      lua_dofile(argv[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <iolib_open@plt>
mov    $0x0,%al
call   1040 <strlib_open@plt>
mov    $0x0,%al
call   1050 <mathlib_open@plt>
cmpl   $0x2,-0x8(%rbp)
jge    11c9 <main+0x69>
jmp    119d <main+0x3d>
lea    -0x820(%rbp),%rdi
call   1070 <gets@plt>
cmp    $0x0,%rax
je     11c4 <main+0x64>
lea    -0x820(%rbp),%rdi
call   1030 <lua_dostring@plt>
jmp    119d <main+0x3d>
jmp    1200 <main+0xa0>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fb <main+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <lua_dofile@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d0 <main+0x70>
jmp    1200 <main+0xa0>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1080 <iolib_open@plt>
xor    %eax,%eax
call   1040 <strlib_open@plt>
xor    %eax,%eax
call   1050 <mathlib_open@plt>
cmp    $0x2,%ebp
jge    11b7 <main+0x57>
mov    %rsp,%rdi
call   1070 <gets@plt>
test   %rax,%rax
je     11d2 <main+0x72>
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <lua_dostring@plt>
mov    %rbx,%rdi
call   1070 <gets@plt>
test   %rax,%rax
jne    11a0 <main+0x40>
jmp    11d2 <main+0x72>
mov    %ebp,%ebp
mov    $0x1,%ebx
xchg   %ax,%ax
mov    (%r14,%rbx,8),%rdi
call   1060 <lua_dofile@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11c0 <main+0x60>
xor    %eax,%eax
add    $0x800,%rsp
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 [2048 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%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 %22
13: ; preds = %2
br label %14
14: ; preds = %18, %13
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%16 = call i64 @gets(i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%20 = call i32 @lua_dostring(i8* %19)
br label %14
21: ; preds = %14
br label %38
22: ; preds = %2
store i32 1, i32* %6
br label %23
23: ; preds = %34, %22
%24 = load i32, i32* %6
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = load i8**, i8*** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @lua_dofile(i8* %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %23
37: ; preds = %23
br label %38
38: ; preds = %37, %21
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2048 x i8]
%4 = tail call i32 (...) @iolib_open()
%5 = tail call i32 (...) @strlib_open()
%6 = tail call i32 (...) @mathlib_open()
%7 = icmp slt i32 %0, 2
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = zext i32 %0 to i64
br label %19
10: ; preds = %2
%11 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%12 = call i64 @gets(i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10, %14
%15 = call i32 @lua_dostring(i8* %11)
%16 = call i64 @gets(i8* %11)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %14
18: ; preds = %14, %10
br label %26
19: ; preds = %8, %19
%20 = phi i64 [ 1, %8 ], [ %24, %19 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 @lua_dofile(i8* %22)
%24 = add nuw nsw i64 %20, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %26, label %19
26: ; preds = %19, %18
ret i32 0
}