#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*/ aucRef;
typedef int /*<<< orphan*/ aucMagic;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ contains_data(int /*<<< orphan*/ *, int, unsigned char *,
                                 int);
int is_fat_32_br(FILE *fp) {
  unsigned char aucRef[] = {0x55, 0xAA};
  unsigned char aucMagic[] = {'M', 'S', 'W', 'I', 'N', '4', '.', '1'};
  int i;
  for (i = 0; i < 3; i++)
    if (!contains_data(fp, 0x1FE + i * 0x200, aucRef, sizeof(aucRef)))
      return 0;
  if (!contains_data(fp, 0x03, aucMagic, sizeof(aucMagic)))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<is_fat_32_br>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xedd(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    0xed4(%rip),%rax
mov    %rax,-0x1a(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    1189 <is_fat_32_br+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
shl    $0x9,%esi
add    $0x1fe,%esi
lea    -0x12(%rbp),%rdx
mov    $0x2,%ecx
call   1030 <contains_data@plt>
cmp    $0x0,%eax
jne    1176 <is_fat_32_br+0x66>
movl   $0x0,-0x4(%rbp)
jmp    11bc <is_fat_32_br+0xac>
jmp    117b <is_fat_32_br+0x6b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1139 <is_fat_32_br+0x29>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rdx
mov    $0x3,%esi
mov    $0x8,%ecx
call   1030 <contains_data@plt>
cmp    $0x0,%eax
jne    11b5 <is_fat_32_br+0xa5>
movl   $0x0,-0x4(%rbp)
jmp    11bc <is_fat_32_br+0xac>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_fat_32_br>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movw   $0xaa55,0xe(%rsp)
movabs $0x312e344e4957534d,%rax
34 2e 31
mov    %rax,0x10(%rsp)
lea    0xe(%rsp),%rdx
mov    $0x1fe,%esi
mov    $0x2,%ecx
call   1030 <contains_data@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     119e <is_fat_32_br+0x8e>
lea    0xe(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x3fe,%esi
mov    $0x2,%ecx
call   1030 <contains_data@plt>
test   %eax,%eax
je     119e <is_fat_32_br+0x8e>
lea    0xe(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x5fe,%esi
mov    $0x2,%ecx
call   1030 <contains_data@plt>
test   %eax,%eax
je     119e <is_fat_32_br+0x8e>
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x8,%ecx
call   1030 <contains_data@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.is_fat_32_br.aucRef = [2 x i8] c"U\AA"
@__const.is_fat_32_br.aucMagic = [8 x i8] c"MSWIN4.1"
define i32 @is_fat_32_br(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [2 x i8]
%5 = alloca [8 x i8]
%6 = alloca i32
store i32* %0, i32** %3
%7 = bitcast [2 x i8]* %4 to i8*
%8 = bitcast [8 x i8]* %5 to i8*
store i32 0, i32* %6
br label %9
9: ; preds = %22, %1
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i32*, i32** %3
%14 = load i32, i32* %6
%15 = mul nsw i32 %14, 512
%16 = add nsw i32 510, %15
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%18 = call i32 @contains_data(i32* %13, i32 %16, i8* %17, i32 2)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %12
store i32 0, i32* %2
br label %32
21: ; preds = %12
br label %22
22: ; preds = %21
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %9
25: ; preds = %9
%26 = load i32*, i32** %3
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%28 = call i32 @contains_data(i32* %26, i32 3, i8* %27, i32 8)
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %25
store i32 0, i32* %2
br label %32
31: ; preds = %25
store i32 1, i32* %2
br label %32
32: ; preds = %31, %30, %20
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @is_fat_32_br(i32* %0) {
%2 = alloca i16
%3 = alloca i64
%4 = bitcast i16* %2 to i8*
store i16 -21931, i16* %2
%5 = bitcast i64* %3 to i8*
store i64 3543827467629712205, i64* %3
%6 = call i32 @contains_data(i32* %0, i32 510, i8* %4, i32 2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %18, label %8
8: ; preds = %1
%9 = call i32 @contains_data(i32* %0, i32 1022, i8* %4, i32 2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = call i32 @contains_data(i32* %0, i32 1534, i8* %4, i32 2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = call i32 @contains_data(i32* %0, i32 3, i8* %5, i32 8)
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %1, %8, %11, %14
%19 = phi i32 [ %17, %14 ], [ 0, %11 ], [ 0, %8 ], [ 0, %1 ]
ret i32 %19
}