// File: zeeev[P]DASVC/bamtools/src/api/internal/index/BamStandardIndex_p.cpp
// Function: BamTools::Internal::BamStandardIndex::CheckMagicNumber()
void BamStandardIndex::CheckMagicNumber(void) {

    // check 'magic number' to see if file is BAI index
    char magic[4];
    const int64_t numBytesRead = m_resources.Device->Read(magic, sizeof(magic));
    if ( numBytesRead != 4 )
        throw BamException("BamStandardIndex::CheckMagicNumber", "could not read BAI magic number");

    // compare to expected value
    if ( strncmp(magic, BamStandardIndex::BAI_MAGIC, 4) != 0 )
        throw BamException("BamStandardIndex::CheckMagicNumber", "invalid BAI magic number");
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
movq 0x58(%rax), %rdi
leaq 0xec(%rsp), %rsi
movq (%rdi), %rax
movl $0x4, %edx
callq *0x28(%rax)
movq %rax, 0xe0(%rsp)
cmpq $0x4, 0xe0(%rsp)
je 0xb1cbe
movb $0x1, 0x86(%rsp)
movl $0x28, %edi
callq 0x737c0
movq %rax, 0x20(%rsp)
leaq 0xbf(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x7b5f0
movq 0x28(%rsp), %rdx
leaq 0x39593(%rip), %rsi     # 0xeb13d
leaq 0xc0(%rsp), %rdi
callq 0x78e70
jmp 0xb1bb9
leaq 0x87(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x7b5f0
movq 0x18(%rsp), %rdx
leaq 0x39589(%rip), %rsi     # 0xeb160
leaq 0x88(%rsp), %rdi
callq 0x78e70
jmp 0xb1be6
movq 0x20(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x79cd0
jmp 0xb1c02
movq 0x20(%rsp), %rdi
movb $0x0, 0x86(%rsp)
movq 0x602fa(%rip), %rsi     # 0x111f10
movq 0x60343(%rip), %rdx     # 0x111f60
callq 0x7b010
jmp 0xb1e1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
jmp 0xb1c96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
jmp 0xb1c78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0xb1c76
jmp 0xb1c78
leaq 0x87(%rsp), %rdi
callq 0x76f80
leaq 0xc0(%rsp), %rdi
callq 0x7cce8
jmp 0xb1c94
jmp 0xb1c96
leaq 0xbf(%rsp), %rdi
callq 0x76f80
testb $0x1, 0x86(%rsp)
jne 0xb1caf
jmp 0xb1cb9
movq 0x20(%rsp), %rdi
callq 0x74e00
jmp 0xb1e05
leaq 0xec(%rsp), %rdi
leaq 0x3940b(%rip), %rsi     # 0xeb0d8
movl $0x4, %edx
callq 0x735f0
cmpl $0x0, %eax
je 0xb1dfd
movb $0x1, 0x36(%rsp)
movl $0x28, %edi
callq 0x737c0
movq %rax, 0x8(%rsp)
leaq 0x5f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x3942e(%rip), %rsi     # 0xeb13d
leaq 0x60(%rsp), %rdi
callq 0x78e70
jmp 0xb1d1b
leaq 0x37(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x7b5f0
movq (%rsp), %rdx
leaq 0x3944c(%rip), %rsi     # 0xeb180
leaq 0x38(%rsp), %rdi
callq 0x78e70
jmp 0xb1d40
movq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x79cd0
jmp 0xb1d56
movq 0x8(%rsp), %rdi
movb $0x0, 0x36(%rsp)
movq 0x601a9(%rip), %rsi     # 0x111f10
movq 0x601f2(%rip), %rdx     # 0x111f60
callq 0x7b010
jmp 0xb1e1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
jmp 0xb1dde
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
jmp 0xb1dc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xb1dc4
jmp 0xb1dc6
leaq 0x37(%rsp), %rdi
callq 0x76f80
leaq 0x60(%rsp), %rdi
callq 0x7cce8
jmp 0xb1ddc
jmp 0xb1dde
leaq 0x5f(%rsp), %rdi
callq 0x76f80
testb $0x1, 0x36(%rsp)
jne 0xb1df1
jmp 0xb1dfb
movq 0x8(%rsp), %rdi
callq 0x74e00
jmp 0xb1e05
addq $0xf8, %rsp
retq
movq 0xb0(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw (%rax,%rax)