#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(size_t *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
void seekToBNKData(FILE *fp) {
  size_t offset;
  fseek(fp, 0x10, SEEK_SET);
  fread(&offset, sizeof(int), 1, fp);
  fseek(fp, offset, SEEK_SET);
  printf("DEBUG: reading from offset %x\n", ftell(fp));
}


x86 assembly (clang, -O0):
<seekToBNKData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e57(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,%esi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seekToBNKData>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e92(%rip),%r14
mov    (%r14),%edx
mov    $0x10,%esi
call   1060 <fseek@plt>
mov    %rsp,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    (%rsp),%rsi
mov    (%r14),%edx
mov    %rbx,%rdi
call   1060 <fseek@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
lea    0xe72(%rip),%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [31 x i8] c"DEBUG: reading from offset %x\0A\00"
define void @seekToBNKData(i32* %0) {
%2 = alloca i32*
%3 = alloca i64
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32, i32* @SEEK_SET
%6 = call i32 @fseek(i32* %4, i64 16, i32 %5)
%7 = load i32*, i32** %2
%8 = call i32 @fread(i64* %3, i32 4, i32 1, i32* %7)
%9 = load i32*, i32** %2
%10 = load i64, i64* %3
%11 = load i32, i32* @SEEK_SET
%12 = call i32 @fseek(i32* %9, i64 %10, i32 %11)
%13 = load i32*, i32** %2
%14 = call i32 @ftell(i32* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %14)
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [31 x i8] c"DEBUG: reading from offset %x\0A\00"
define void @seekToBNKData(i32* nocapture %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %0, i64 16, i32 %4)
%6 = call i32 @fread(i64* %2, i32 4, i32 1, i32* %0)
%7 = load i64, i64* %2
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %0, i64 %7, i32 %8)
%10 = tail call i32 @ftell(i32* %0)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %10)
ret void
}