#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(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int gpOverdump(FILE *f, size_t fsize) {
  unsigned char fbuf[0x100];
  unsigned char cmpBuf[8] = {0xB9, 0x91, 0xFB, 0xC2, 0xD5, 0xB9, 0x02, 0x44};
  fseek(f, 0x15000000, SEEK_SET);
  if (fsize == 0x15000010) {
    fread(fbuf, 1, 0x10, f);
    if ((memcmp(fbuf, cmpBuf, 8) != 0) || (memcmp(fbuf + 8, cmpBuf, 8) != 0))
      return 0;
  } else if (fsize == 0x18000000) {
    while (ftell(f) < 0x18000000) {
      fread(fbuf, 1, 0x100, f);
      size_t i;
      for (i = 0; i < 0x100; i += 8) {
        if (memcmp(fbuf + i, cmpBuf, 8) != 0)
          return 0;
      }
    }
  } else
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<gpOverdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0xea6(%rip),%rax
mov    %rax,-0x128(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
mov    $0x15000000,%esi
call   1060 <fseek@plt>
cmpq   $0x15000010,-0x18(%rbp)
15
jne    11f9 <gpOverdump+0xb9>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
lea    -0x120(%rbp),%rdi
lea    -0x128(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    11e8 <gpOverdump+0xa8>
lea    -0x120(%rbp),%rdi
add    $0x8,%rdi
lea    -0x128(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11f4 <gpOverdump+0xb4>
movl   $0x0,-0x4(%rbp)
jmp    12c9 <gpOverdump+0x189>
jmp    12c2 <gpOverdump+0x182>
cmpq   $0x18000000,-0x18(%rbp)
jne    12b1 <gpOverdump+0x171>
jmp    120c <gpOverdump+0xcc>
mov    -0x10(%rbp),%rdi
call   1050 <ftell@plt>
cmp    $0x18000000,%eax
jge    12ac <gpOverdump+0x16c>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x100,%edx
call   1030 <fread@plt>
movq   $0x0,-0x130(%rbp)
cmpq   $0x100,-0x130(%rbp)
jae    12a7 <gpOverdump+0x167>
lea    -0x120(%rbp),%rdi
add    -0x130(%rbp),%rdi
lea    -0x128(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     128b <gpOverdump+0x14b>
movl   $0x0,-0x4(%rbp)
jmp    12c9 <gpOverdump+0x189>
jmp    1290 <gpOverdump+0x150>
mov    -0x130(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x130(%rbp)
jmp    1245 <gpOverdump+0x105>
jmp    120c <gpOverdump+0xcc>
jmp    12bd <gpOverdump+0x17d>
movl   $0x0,-0x4(%rbp)
jmp    12c9 <gpOverdump+0x189>
jmp    12c2 <gpOverdump+0x182>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpOverdump>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %rsi,%rbp
mov    %rdi,%r12
movabs $0x4402b9d5c2fb91b9,%rax
b9 02 44
mov    %rax,0x8(%rsp)
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
mov    $0x15000000,%esi
call   1060 <fseek@plt>
xor    %r15d,%r15d
cmp    $0x15000010,%rbp
je     1208 <gpOverdump+0xc8>
cmp    $0x18000000,%rbp
jne    1258 <gpOverdump+0x118>
mov    %r12,%rdi
call   1050 <ftell@plt>
cmp    $0x17ffffff,%eax
jg     1252 <gpOverdump+0x112>
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%rbp
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x100,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
mov    $0xfffffffffffffff8,%rbx
nopl   (%rax)
lea    (%rsp,%rbx,1),%rdi
add    $0x18,%rdi
mov    %rbp,%rsi
mov    $0x8,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1258 <gpOverdump+0x118>
add    $0x8,%rbx
cmp    $0xf7,%rbx
jbe    11d0 <gpOverdump+0x90>
mov    %r12,%rdi
call   1050 <ftell@plt>
cmp    $0x17ffffff,%eax
jle    11b1 <gpOverdump+0x71>
jmp    1252 <gpOverdump+0x112>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x8,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1258 <gpOverdump+0x118>
lea    0x18(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1258 <gpOverdump+0x118>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.gpOverdump.cmpBuf = [8 x i8] c"\B9\91\FB\C2\D5\B9\02D"
@SEEK_SET = global i32 0
define i32 @gpOverdump(i32* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i64
%6 = alloca [256 x i8]
%7 = alloca [8 x i8]
%8 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
%9 = bitcast [8 x i8]* %7 to i8*
%10 = load i32*, i32** %4
%11 = load i32, i32* @SEEK_SET
%12 = call i32 @fseek(i32* %10, i32 352321536, i32 %11)
%13 = load i64, i64* %5
%14 = icmp eq i64 %13, 352321552
br i1 %14, label %15, label %31
15: ; preds = %2
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%17 = load i32*, i32** %4
%18 = call i32 @fread(i8* %16, i32 1, i32 16, i32* %17)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%21 = call i64 @memcmp(i8* %19, i8* %20, i32 8)
%22 = icmp ne i64 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %15
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%25 = getelementptr inbounds i8, i8* %24, i64 8
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%27 = call i64 @memcmp(i8* %25, i8* %26, i32 8)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %23, %15
store i32 0, i32* %3
br label %63
30: ; preds = %23
br label %62
31: ; preds = %2
%32 = load i64, i64* %5
%33 = icmp eq i64 %32, 402653184
br i1 %33, label %34, label %60
34: ; preds = %31
br label %35
35: ; preds = %58, %34
%36 = load i32*, i32** %4
%37 = call i32 @ftell(i32* %36)
%38 = icmp slt i32 %37, 402653184
br i1 %38, label %39, label %59
39: ; preds = %35
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%41 = load i32*, i32** %4
%42 = call i32 @fread(i8* %40, i32 1, i32 256, i32* %41)
store i64 0, i64* %8
br label %43
43: ; preds = %55, %39
%44 = load i64, i64* %8
%45 = icmp ult i64 %44, 256
br i1 %45, label %46, label %58
46: ; preds = %43
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%48 = load i64, i64* %8
%49 = getelementptr inbounds i8, i8* %47, i64 %48
%50 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%51 = call i64 @memcmp(i8* %49, i8* %50, i32 8)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %46
store i32 0, i32* %3
br label %63
54: ; preds = %46
br label %55
55: ; preds = %54
%56 = load i64, i64* %8
%57 = add i64 %56, 8
store i64 %57, i64* %8
br label %43
58: ; preds = %43
br label %35
59: ; preds = %35
br label %61
60: ; preds = %31
store i32 0, i32* %3
br label %63
61: ; preds = %59
br label %62
62: ; preds = %61, %30
store i32 1, i32* %3
br label %63
63: ; preds = %62, %60, %53, %29
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @gpOverdump(i32* nocapture %0, i64 %1) {
%3 = alloca [256 x i8]
%4 = alloca i64
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast i64* %4 to i8*
store i64 4900683672282960313, i64* %4
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %0, i32 352321536, i32 %7)
switch i64 %1, label %34 [
i64 352321552, label %12
i64 402653184, label %9
]
9: ; preds = %2
%10 = call i32 @ftell(i32* %0)
%11 = icmp slt i32 %10, 402653184
br i1 %11, label %23, label %33
12: ; preds = %2
%13 = call i32 @fread(i8* %5, i32 1, i32 16, i32* %0)
%14 = call i64 @memcmp(i8* %5, i8* %6, i32 8)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %12
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 8
%18 = call i64 @memcmp(i8* %17, i8* %6, i32 8)
%19 = icmp eq i64 %18, 0
br i1 %19, label %33, label %34
20: ; preds = %25
%21 = call i32 @ftell(i32* %0)
%22 = icmp slt i32 %21, 402653184
br i1 %22, label %23, label %33
23: ; preds = %9, %20
%24 = call i32 @fread(i8* %5, i32 1, i32 256, i32* %0)
br label %28
25: ; preds = %28
%26 = add nuw nsw i64 %29, 8
%27 = icmp ult i64 %29, 248
br i1 %27, label %28, label %20
28: ; preds = %23, %25
%29 = phi i64 [ 0, %23 ], [ %26, %25 ]
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %29
%31 = call i64 @memcmp(i8* %30, i8* %6, i32 8)
%32 = icmp eq i64 %31, 0
br i1 %32, label %25, label %34
33: ; preds = %20, %9, %16
br label %34
34: ; preds = %28, %2, %12, %16, %33
%35 = phi i32 [ 1, %33 ], [ 0, %16 ], [ 0, %12 ], [ 0, %2 ], [ 0, %28 ]
ret i32 %35
}