#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_ntfs_br(FILE *fp) {
  unsigned char aucRef[] = {0x55, 0xAA};
  unsigned char aucMagic[] = {'N', 'T', 'F', 'S', ' ', ' ', ' ', ' '};
  if (!contains_data(fp, 0x1FE, aucRef, sizeof(aucRef)))
    return 0;
  if (!contains_data(fp, 0x03, aucMagic, sizeof(aucMagic)))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<is_ntfs_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)
mov    -0x10(%rbp),%rdi
lea    -0x12(%rbp),%rdx
mov    $0x1fe,%esi
mov    $0x2,%ecx
call   1030 <contains_data@plt>
cmp    $0x0,%eax
jne    115e <is_ntfs_br+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    1191 <is_ntfs_br+0x81>
mov    -0x10(%rbp),%rdi
lea    -0x1a(%rbp),%rdx
mov    $0x3,%esi
mov    $0x8,%ecx
call   1030 <contains_data@plt>
cmp    $0x0,%eax
jne    118a <is_ntfs_br+0x7a>
movl   $0x0,-0x4(%rbp)
jmp    1191 <is_ntfs_br+0x81>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_ntfs_br>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movw   $0xaa55,0x6(%rsp)
movabs $0x202020205346544e,%rax
20 20 20
mov    %rax,0x8(%rsp)
lea    0x6(%rsp),%rdx
mov    $0x1fe,%esi
mov    $0x2,%ecx
call   1030 <contains_data@plt>
test   %eax,%eax
je     1168 <is_ntfs_br+0x58>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x8,%ecx
call   1030 <contains_data@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
setne  %al
jmp    116a <is_ntfs_br+0x5a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.is_ntfs_br.aucRef = [2 x i8] c"U\AA"
@__const.is_ntfs_br.aucMagic = [8 x i8] c"NTFS "
define i32 @is_ntfs_br(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [2 x i8]
%5 = alloca [8 x i8]
store i32* %0, i32** %3
%6 = bitcast [2 x i8]* %4 to i8*
%7 = bitcast [8 x i8]* %5 to i8*
%8 = load i32*, i32** %3
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%10 = call i32 @contains_data(i32* %8, i32 510, i8* %9, i32 2)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %1
store i32 0, i32* %2
br label %20
13: ; preds = %1
%14 = load i32*, i32** %3
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%16 = call i32 @contains_data(i32* %14, i32 3, i8* %15, i32 8)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %13
store i32 0, i32* %2
br label %20
19: ; preds = %13
store i32 1, i32* %2
br label %20
20: ; preds = %19, %18, %12
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
define i32 @is_ntfs_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 2314885531676595278, 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 %12, label %8
8: ; preds = %1
%9 = call i32 @contains_data(i32* %0, i32 3, i8* %5, i32 8)
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %8, %1
%13 = phi i32 [ 0, %1 ], [ %11, %8 ]
ret i32 %13
}