#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 BUFSIZ;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, char *, int);
void instructions() {
  register int fd, r;
  char buf[BUFSIZ];
  if ((fd = open("/games/lib/backrules", 0)) < 0) {
    fprintf(stderr, "back: cannot open %s\n", "/games/lib/backrules");
    return;
  }
  while ((r = read(fd, buf, BUFSIZ)) > 0)
    write(1, buf, r);
}


x86 assembly (clang, -O0):
<instructions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
lea    0xe85(%rip),%rdi
xor    %esi,%esi
call   1060 <open@plt>
mov    %eax,-0x4(%rbp)
cmp    $0x0,%eax
jge    11b6 <instructions+0x76>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
lea    0xe5b(%rip),%rdx
call   1050 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    11f9 <instructions+0xb9>
jmp    11bb <instructions+0x7b>
mov    -0x28(%rbp),%rsi
mov    -0x4(%rbp),%edi
mov    0x2e0f(%rip),%rax
mov    (%rax),%edx
call   1040 <read@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11f2 <instructions+0xb2>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
jmp    11bb <instructions+0x7b>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<instructions>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e87(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe94(%rip),%rdi
xor    %esi,%esi
call   1060 <open@plt>
test   %eax,%eax
js     11ae <instructions+0x6e>
mov    %eax,%r14d
nopw   0x0(%rax,%rax,1)
mov    (%r15),%edx
mov    %r14d,%edi
mov    %rbx,%rsi
call   1040 <read@plt>
test   %eax,%eax
jle    11a3 <instructions+0x63>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    1180 <instructions+0x40>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
lea    0xe3b(%rip),%rdx
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [21 x i8] c"/games/lib/backrules\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"back: cannot open %s\0A\00"
define void @instructions() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i8, i64 %7
store i64 %7, i64* %4
%10 = call i32 @open(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %10, i32* %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %25
15: ; preds = %0
br label %16
16: ; preds = %21, %15
%17 = load i32, i32* %1
%18 = load i32, i32* @BUFSIZ
%19 = call i32 @read(i32 %17, i8* %9, i32 %18)
store i32 %19, i32* %2
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* %2
%23 = call i32 @write(i32 1, i8* %9, i32 %22)
br label %16
24: ; preds = %16
store i32 0, i32* %5
br label %25
25: ; preds = %24, %12
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
switch i32 %27, label %29 [
i32 0, label %28
i32 1, label %28
]
28: ; preds = %25, %25
ret void
29: ; preds = %25
unreachable
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [21 x i8] c"/games/lib/backrules\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"back: cannot open %s\0A\00"
define void @instructions() {
%1 = load i32, i32* @BUFSIZ
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = tail call i32 @open(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = load i32, i32* @BUFSIZ
%8 = call i32 @read(i32 %4, i8* %3, i32 %7)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %13, label %19
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %19
13: ; preds = %6, %13
%14 = phi i32 [ %17, %13 ], [ %8, %6 ]
%15 = call i32 @write(i32 1, i8* %3, i32 %14)
%16 = load i32, i32* @BUFSIZ
%17 = call i32 @read(i32 %4, i8* %3, i32 %16)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %13, label %19
19: ; preds = %13, %6, %10
ret void
}