#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 dostring(char const *, char *);
int file_input(char const *);
char *getenv(char *);
int handle_luainit(void) {
  const char *init = getenv("LUA_INIT");
  if (init == NULL)
    return 0;
  else if (init[0] == '@')
    return file_input(init + 1);
  else
    return dostring(init, "=LUA_INIT");
}


x86 assembly (clang, -O0):
<handle_luainit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115f <handle_luainit+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1197 <handle_luainit+0x67>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    1184 <handle_luainit+0x54>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1050 <file_input@plt>
mov    %eax,-0x4(%rbp)
jmp    1197 <handle_luainit+0x67>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1040 <dostring@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_luainit>:
push   %rax
lea    0xec9(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1154 <handle_luainit+0x24>
cmpb   $0x40,(%rax)
jne    1158 <handle_luainit+0x28>
add    $0x1,%rax
mov    %rax,%rdi
pop    %rax
jmp    1050 <file_input@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xea1(%rip),%rsi
mov    %rax,%rdi
pop    %rax
jmp    1040 <dostring@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"LUA_INIT\00"
@.str.1 = [10 x i8] c"=LUA_INIT\00"
define i32 @handle_luainit() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 0, i32* %1
br label %20
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 64
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = call i32 @file_input(i8* %15)
store i32 %16, i32* %1
br label %20
17: ; preds = %7
%18 = load i8*, i8** %2
%19 = call i32 @dostring(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 %19, i32* %1
br label %20
20: ; preds = %17, %13, %6
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [9 x i8] c"LUA_INIT\00"
@.str.1 = [10 x i8] c"=LUA_INIT\00"
define i32 @handle_luainit() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %11, label %3
3: ; preds = %0
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 64
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = tail call i32 @file_input(i8* %7)
br label %11
9: ; preds = %3
%10 = tail call i32 @dostring(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %0, %9, %6
%12 = phi i32 [ %8, %6 ], [ %10, %9 ], [ 0, %0 ]
ret i32 %12
}