#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 int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseeko64(int /*<<< orphan*/ *, int /*<<< orphan*/,
                            int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int PPFVersion(FILE *ppf) {
  unsigned int magic;
  fseeko64(ppf, 0, SEEK_SET);
  fread(&magic, 1, 4, ppf);
  ;
  switch (magic) {
  case '1FPP':
    return (1);
  case '2FPP':
    return (2);
  case '3FPP':
    return (3);
  default:
    printf("Error: patchfile is no ppf patch\n");
    break;
  }
  return (0);
}


x86 assembly (clang, -O0):
<PPFVersion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseeko64@plt>
mov    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x31465050,%eax
je     11a3 <PPFVersion+0x73>
jmp    117d <PPFVersion+0x4d>
mov    -0x18(%rbp),%eax
sub    $0x32465050,%eax
je     11af <PPFVersion+0x7f>
jmp    1190 <PPFVersion+0x60>
mov    -0x18(%rbp),%eax
sub    $0x33465050,%eax
je     11bb <PPFVersion+0x8b>
jmp    11c7 <PPFVersion+0x97>
movl   $0x1,-0x4(%rbp)
jmp    11da <PPFVersion+0xaa>
movl   $0x2,-0x4(%rbp)
jmp    11da <PPFVersion+0xaa>
movl   $0x3,-0x4(%rbp)
jmp    11da <PPFVersion+0xaa>
lea    0xe32(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PPFVersion>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2ea3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseeko64@plt>
lea    0x4(%rsp),%rdi
mov    $0x1,%ebp
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    0x4(%rsp),%eax
cmp    $0x31465050,%eax
je     1197 <PPFVersion+0x67>
cmp    $0x33465050,%eax
je     1182 <PPFVersion+0x52>
cmp    $0x32465050,%eax
jne    1189 <PPFVersion+0x59>
mov    $0x2,%ebp
jmp    1197 <PPFVersion+0x67>
mov    $0x3,%ebp
jmp    1197 <PPFVersion+0x67>
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [34 x i8] c"Error: patchfile is no ppf patch\0A\00"
define i32 @PPFVersion(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = load i32, i32* @SEEK_SET
%7 = call i32 @fseeko64(i32* %5, i32 0, i32 %6)
%8 = load i32*, i32** %3
%9 = call i32 @fread(i32* %4, i32 1, i32 4, i32* %8)
%10 = load i32, i32* %4
switch i32 %10, label %14 [
i32 826691664, label %11
i32 843468880, label %12
i32 860246096, label %13
]
11: ; preds = %1
store i32 1, i32* %2
br label %17
12: ; preds = %1
store i32 2, i32* %2
br label %17
13: ; preds = %1
store i32 3, i32* %2
br label %17
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14
store i32 0, i32* %2
br label %17
17: ; preds = %16, %13, %12, %11
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@str = [33 x i8] c"Error: patchfile is no ppf patch\00"
define i32 @PPFVersion(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseeko64(i32* %0, i32 0, i32 %4)
%6 = call i32 @fread(i32* %2, i32 1, i32 4, i32* %0)
%7 = load i32, i32* %2
switch i32 %7, label %10 [
i32 826691664, label %12
i32 843468880, label %8
i32 860246096, label %9
]
8: ; preds = %1
br label %12
9: ; preds = %1
br label %12
10: ; preds = %1
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %1, %10, %9, %8
%13 = phi i32 [ 0, %10 ], [ 3, %9 ], [ 2, %8 ], [ 1, %1 ]
ret i32 %13
}