#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 /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int getXrefLocation(int /*<<< orphan*/ *);
scalar_t__ strtol(char *, char **, int);
int checkXrefTable(FILE *file) {
  int location = getXrefLocation(file);
  if (location == 0)
    return 0;
  fseek(file, (location + 7), SEEK_SET);
  char result[2];
  fread(result, 2, 1, file);
  return (int)strtol(result, (char **)NULL, 10);
}


x86 assembly (clang, -O0):
<checkXrefTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getXrefLocation@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    116e <checkXrefTable+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <checkXrefTable+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x7,%esi
mov    0x2e61(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
lea    -0x16(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
lea    -0x16(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkXrefTable>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <getXrefLocation@plt>
test   %eax,%eax
je     1191 <checkXrefTable+0x51>
add    $0x7,%eax
mov    0x2e86(%rip),%rcx
mov    (%rcx),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <fseek@plt>
lea    0x6(%rsp),%r14
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
jmp    1193 <checkXrefTable+0x53>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @checkXrefTable(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [2 x i8]
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @getXrefLocation(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %23
11: ; preds = %1
%12 = load i32*, i32** %3
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 7
%15 = load i32, i32* @SEEK_SET
%16 = call i32 @fseek(i32* %12, i32 %14, i32 %15)
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%18 = load i32*, i32** %3
%19 = call i32 @fread(i8* %17, i32 2, i32 1, i32* %18)
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%21 = call i64 @strtol(i8* %20, i8** null, i32 10)
%22 = trunc i64 %21 to i32
store i32 %22, i32* %2
br label %23
23: ; preds = %11, %10
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @checkXrefTable(i32* %0) {
%2 = alloca [2 x i8]
%3 = tail call i32 @getXrefLocation(i32* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = add nsw i32 %3, 7
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %0, i32 %6, i32 %7)
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%10 = call i32 @fread(i8* %9, i32 2, i32 1, i32* %0)
%11 = call i64 @strtol(i8* nocapture %9, i8** null, i32 10)
%12 = trunc i64 %11 to i32
br label %13
13: ; preds = %1, %5
%14 = phi i32 [ %12, %5 ], [ 0, %1 ]
ret i32 %14
}