#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *getfile(char *);
char *luaL_opt_string(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ pushresult(int);
void io_write(void) {
  FILE *f = getfile("_OUTPUT");
  int arg = 1;
  int status = 1;
  char *s;
  while ((s = luaL_opt_string(arg++, NULL)) != NULL)
    status = status && (fputs(s, f) != EOF);
  pushresult(status);
}


x86 assembly (clang, -O0):
<io_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
call   1060 <getfile@plt>
mov    %rax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%esi
call   1050 <luaL_opt_string@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11c4 <io_write+0x84>
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     11b4 <io_write+0x74>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <fputs@plt>
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <io_write+0x26>
mov    -0x10(%rbp),%edi
call   1030 <pushresult@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_write>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xeb1(%rip),%rdi
call   1060 <getfile@plt>
mov    %rax,%r14
mov    $0x1,%ebp
mov    $0x1,%edi
xor    %esi,%esi
call   1050 <luaL_opt_string@plt>
test   %rax,%rax
je     11b1 <io_write+0x71>
mov    $0x1,%ebp
mov    $0x2,%ebx
mov    0x2e6a(%rip),%r15
jmp    11a9 <io_write+0x69>
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <fputs@plt>
cmp    (%r15),%rax
setne  %al
movzbl %al,%ebp
lea    0x1(%rbx),%r12d
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <luaL_opt_string@plt>
mov    %r12d,%ebx
test   %rax,%rax
je     11b1 <io_write+0x71>
test   %ebp,%ebp
jne    1180 <io_write+0x40>
xor    %eax,%eax
jmp    1191 <io_write+0x51>
mov    %ebp,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <pushresult@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"_OUTPUT\00"
@EOF = global i64 0
define void @io_write() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = call i32* @getfile(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32* %5, i32** %1
store i32 1, i32* %2
store i32 1, i32* %3
br label %6
6: ; preds = %20, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 1
store i32 %8, i32* %2
%9 = call i8* @luaL_opt_string(i32 %7, i32* null)
store i8* %9, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i8*, i8** %4
%16 = load i32*, i32** %1
%17 = call i64 @fputs(i8* %15, i32* %16)
%18 = load i64, i64* @EOF
%19 = icmp ne i64 %17, %18
br label %20
20: ; preds = %14, %11
%21 = phi i1 [ false, %11 ], [ %19, %14 ]
%22 = zext i1 %21 to i32
store i32 %22, i32* %3
br label %6
23: ; preds = %6
%24 = load i32, i32* %3
%25 = call i32 @pushresult(i32 %24)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"_OUTPUT\00"
@EOF = global i64 0
define void @io_write() {
%1 = tail call i32* @getfile(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @luaL_opt_string(i32 1, i32* null)
%3 = icmp eq i8* %2, null
br i1 %3, label %19, label %4
4: ; preds = %0, %13
%5 = phi i8* [ %17, %13 ], [ %2, %0 ]
%6 = phi i32 [ %16, %13 ], [ 2, %0 ]
%7 = phi i32 [ %15, %13 ], [ 1, %0 ]
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = tail call i64 @fputs(i8* %5, i32* %1)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br label %13
13: ; preds = %9, %4
%14 = phi i1 [ false, %4 ], [ %12, %9 ]
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %6, 1
%17 = tail call i8* @luaL_opt_string(i32 %6, i32* null)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %4
19: ; preds = %13, %0
%20 = phi i32 [ 1, %0 ], [ %15, %13 ]
%21 = tail call i32 @pushresult(i32 %20)
ret void
}