#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 */
int /*<<< orphan*/ SEEK_SET;
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int NESGetRomControlBytes(char *buf, FILE *ifile) {
  if (!buf || !ifile)
    return 0;
  if (fseek(ifile, 6, SEEK_SET) != 0) {
    return 0;
  }
  if (fread(buf, 2, 1, ifile) != 1) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<NESGetRomControlBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <NESGetRomControlBytes+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <NESGetRomControlBytes+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <NESGetRomControlBytes+0x92>
mov    -0x18(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
mov    $0x6,%esi
call   1040 <fseek@plt>
cmp    $0x0,%rax
je     117f <NESGetRomControlBytes+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <NESGetRomControlBytes+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     11ab <NESGetRomControlBytes+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <NESGetRomControlBytes+0x92>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NESGetRomControlBytes>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %rdi,%rdi
je     1171 <NESGetRomControlBytes+0x51>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1171 <NESGetRomControlBytes+0x51>
mov    %rdi,%rbp
mov    0x2ea2(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <fseek@plt>
test   %rax,%rax
jne    1171 <NESGetRomControlBytes+0x51>
mov    %rbp,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
xor    %r14d,%r14d
cmp    $0x1,%eax
sete   %r14b
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @NESGetRomControlBytes(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %8, %2
store i32 0, i32* %3
br label %25
12: ; preds = %8
%13 = load i32*, i32** %5
%14 = load i32, i32* @SEEK_SET
%15 = call i64 @fseek(i32* %13, i32 6, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 0, i32* %3
br label %25
18: ; preds = %12
%19 = load i8*, i8** %4
%20 = load i32*, i32** %5
%21 = call i32 @fread(i8* %19, i32 2, i32 1, i32* %20)
%22 = icmp ne i32 %21, 1
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 0, i32* %3
br label %25
24: ; preds = %18
store i32 1, i32* %3
br label %25
25: ; preds = %24, %23, %17, %11
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @NESGetRomControlBytes(i8* %0, i32* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i32* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = load i32, i32* @SEEK_SET
%8 = tail call i64 @fseek(i32* %1, i32 6, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i32 @fread(i8* %0, i32 2, i32 1, i32* %1)
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %10, %6, %2
%15 = phi i32 [ 0, %2 ], [ 0, %6 ], [ %13, %10 ]
ret i32 %15
}