#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 uint32_t;
struct PhoenixID {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ PhoenixFFVDirectory(unsigned char *, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int PhoenixFFV(unsigned char *BIOSImage, int BIOSLength,
               struct PhoenixID *FFV) {
  uint32_t Offset;
  Offset = (*((uint32_t *)(((char *)FFV) + 0xA))) & (BIOSLength - 1);
  if (!Offset) {
    fprintf(stderr, "BCPFFV module offset is NULL.\n");
    return 0;
  }
  PhoenixFFVDirectory(BIOSImage, BIOSLength, Offset);
  return 1;
}


x86 assembly (clang, -O0):
<PhoenixFFV>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0xa(%rax),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1170 <PhoenixFFV+0x50>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1186 <PhoenixFFV+0x66>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <PhoenixFFVDirectory@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PhoenixFFV>:
push   %rax
mov    %rdx,%rax
lea    -0x1(%rsi),%edx
and    0xa(%rax),%edx
je     1138 <PhoenixFFV+0x18>
call   1030 <PhoenixFFVDirectory@plt>
mov    $0x1,%eax
pop    %rcx
ret
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.PhoenixID = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"BCPFFV module offset is NULL.\0A\00"
define i32 @PhoenixFFV(i8* %0, i32 %1, %struct.PhoenixID* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.PhoenixID*
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store %struct.PhoenixID* %2, %struct.PhoenixID** %7
%9 = load %struct.PhoenixID*, %struct.PhoenixID** %7
%10 = bitcast %struct.PhoenixID* %9 to i8*
%11 = getelementptr inbounds i8, i8* %10, i64 10
%12 = bitcast i8* %11 to i32*
%13 = load i32, i32* %12
%14 = load i32, i32* %6
%15 = sub nsw i32 %14, 1
%16 = and i32 %13, %15
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %3
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %27
22: ; preds = %3
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = load i32, i32* %8
%26 = call i32 @PhoenixFFVDirectory(i8* %23, i32 %24, i32 %25)
store i32 1, i32* %4
br label %27
27: ; preds = %22, %19
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
%struct.PhoenixID = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"BCPFFV module offset is NULL.\0A\00"
define i32 @PhoenixFFV(i8* %0, i32 %1, %struct.PhoenixID* nocapture %2) {
%4 = bitcast %struct.PhoenixID* %2 to i8*
%5 = getelementptr inbounds i8, i8* %4, i64 10
%6 = bitcast i8* %5 to i32*
%7 = load i32, i32* %6
%8 = add nsw i32 %1, -1
%9 = and i32 %7, %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %16
14: ; preds = %3
%15 = tail call i32 @PhoenixFFVDirectory(i8* %0, i32 %1, i32 %9)
br label %16
16: ; preds = %14, %11
%17 = phi i32 [ 1, %14 ], [ 0, %11 ]
ret i32 %17
}