#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*/ printf(char *, ...);
void emit(const char *fn, int n) {
  static int oneshot = 0;
  if (!oneshot) {
    printf(" int error;\n");
    oneshot++;
  }
  printf(" error = luaL_loadbuffer(L,(const char*)B%d,sizeof(B%d),\"%s\") || "
         "lua_pcall(L, 0, 0, 0);\n",
         n, n, fn);
  printf(" if (error) { fprintf(stderr, \"error: Lua script failed: %%s\", "
         "lua_tostring(L, -1)); lua_pop(L, 1); }\n");
}


x86 assembly (clang, -O0):
<emit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,0x2f06(%rip)
jne    1149 <emit+0x39>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2eec(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ee3(%rip)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rcx
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
cmpl   $0x0,0x2f05(%rip)
jne    1144 <emit+0x24>
lea    0xf88(%rip),%rdi
call   1030 <puts@plt>
addl   $0x1,0x2ef0(%rip)
lea    0xeb5(%rip),%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef9(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@emit.oneshot = internal global i32 0
@.str = [13 x i8] c" int error;\0A\00"
@.str.1 = [89 x i8] c" error = luaL_loadbuffer(L,(const char*)B%d,sizeof(B%d),\22%s\22) || lua_pcall(L, 0, 0, 0);\0A\00"
@.str.2 = [103 x i8] c" if (error) { fprintf(stderr, \22error: Lua script failed: %%s\22, lua_tostring(L, -1)); lua_pop(L, 1); }\0A\00"
define void @emit(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* @emit.oneshot
%6 = icmp ne i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @emit.oneshot
%10 = add nsw i32 %9, 1
store i32 %10, i32* @emit.oneshot
br label %11
11: ; preds = %7, %2
%12 = load i32, i32* %4
%13 = load i32, i32* %4
%14 = load i8*, i8** %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13, i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@emit.oneshot = internal unnamed_addr global i32 0
@.str.1 = [89 x i8] c" error = luaL_loadbuffer(L,(const char*)B%d,sizeof(B%d),\22%s\22) || lua_pcall(L, 0, 0, 0);\0A\00"
@.str.2 = [103 x i8] c" if (error) { fprintf(stderr, \22error: Lua script failed: %%s\22, lua_tostring(L, -1)); lua_pop(L, 1); }\0A\00"
@str = [12 x i8] c" int error;\00"
define void @emit(i8* %0, i32 %1) {
%3 = load i32, i32* @emit.oneshot
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* @emit.oneshot
%8 = add nsw i32 %7, 1
store i32 %8, i32* @emit.oneshot
br label %9
9: ; preds = %5, %2
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([89 x i8], [89 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %1, i8* %0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([103 x i8], [103 x i8]* @.str.2, i64 0, i64 0))
ret void
}