// File: /workspace/github_cpp_makefile_star2_O3/wwdatabase[P]database/./rcdmana/rm.h
// Function: RecordManager::openFile(char const*, RM_FileHandle&)
RC RecordManager::openFile(const char *fileName, RM_FileHandle &fileHandle) {
    fileHandle.fileName = fileName;
    if (!pfm->openFile(fileName, fileHandle.fileID)){
        cout << "error open file : " << fileName << endl;
        return 103;
    }
    cout << endl;
    cout << ">>> open file " << fileName << " sucessfully." << endl;
    fileHandle.bufType = bpm->getPage(fileHandle.fileID, 
                                        fileHandle.pageID,
                                        fileHandle.index);
    BufType b = fileHandle.bufType;
    fileHandle.init();
    cout << "******file " << fileName << " info******" << endl;
    int offset = 0;
    cout << "* record size : " << b[offset] << "\n" ;
    fileHandle.recordSize = b[offset ++ ];
    fileHandle.attrNum = b[offset ++];
    fileHandle.priKeyNum = b[offset ++];
    for (int i = 0; i < fileHandle.attrNum; ++i) {
        fileHandle.attrType.push_back(b[offset ++]);
        fileHandle.attrLength.push_back(b[offset ++]);
        fileHandle.isNull.push_back(b[offset ++]);
    }
    cout << "* record number in each page : " << b[offset] << "\n" ;
    fileHandle.recordNumForEachPage = b[offset ++];
    cout << "* tags map size in each page : " << b[offset] << "\n" ;
    fileHandle.tagSize = b[offset ++];
    cout << "* record number for total pages : " << b[offset] << "\n";
    fileHandle.recordNumForAllPages = b[offset ++];
    cout << "* bitmap size : " << b[offset]*8 << "\n" ;
    fileHandle.bitmapSize = b[offset ++];
    fileHandle.bitmap = b + offset;
    
    cout << "* bitmap : " ;
    unsigned int bitmap;
    for (int i = 0; i < fileHandle.bitmapSize; ++i) {
        bitmap = b[offset+i];
        for (int j = 0; j < 8; ++j) {
            cout << (bitmap & (1 << j));
        }
    }
    cout << endl;
    cout << "******end file info************" << endl;
    
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq %rsi, (%rdx)
movq (%rdi), %rdi
addq $0x8, %rdx
callq 0x4762
testb %al, %al
je 0x31c6
movq 0x5e6e(%rip), %r15      # 0x8fd8
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
leaq 0x2fa8(%rip), %rsi      # 0x6140
movl $0xe, %edx
movq %r15, %rdi
callq 0x2170
testq %r12, %r12
je 0x3209
movq %r12, %rdi
callq 0x2070
movq 0x5e1f(%rip), %rdi      # 0x8fd8
movq %r12, %rsi
movq %rax, %rdx
callq 0x2170
jmp 0x3221
movq 0x5e0b(%rip), %rbx      # 0x8fd8
leaq 0x2eed(%rip), %rsi      # 0x60c1
movl $0x12, %edx
movq %rbx, %rdi
callq 0x2170
testq %r12, %r12
je 0x32c7
movq %r12, %rdi
callq 0x2070
movq 0x5ddf(%rip), %rdi      # 0x8fd8
movq %r12, %rsi
movq %rax, %rdx
callq 0x2170
jmp 0x32de
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x21e0
leaq 0x3012(%rip), %rsi      # 0x623a
movl $0xd, %edx
movq %r15, %rdi
callq 0x2170
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movq 0x8(%r14), %rdi
movl 0x8(%rbx), %esi
movl 0x78(%rbx), %edx
leaq 0x88(%rbx), %rcx
callq 0x4478
movq %rax, %r14
movq %rax, 0x80(%rbx)
movl $0x0, 0xc(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
movq $0x0, 0x70(%rbx)
leaq 0x2eb6(%rip), %rsi      # 0x614f
movl $0xb, %edx
movq %r15, %rdi
callq 0x2170
testq %r12, %r12
je 0x330f
movq %r12, %rdi
callq 0x2070
movq 0x5d1e(%rip), %rdi      # 0x8fd8
movq %r12, %rsi
movq %rax, %rdx
callq 0x2170
jmp 0x3327
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movl $0x67, %eax
jmp 0x3638
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x21e0
leaq 0x2e2d(%rip), %rsi      # 0x615b
movl $0xb, %edx
movq %r15, %rdi
callq 0x2170
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
leaq 0x2dfe(%rip), %rsi      # 0x6167
movl $0x10, %edx
movq %r15, %rdi
callq 0x2170
movl (%r14), %esi
movq %r15, %rdi
callq 0x20b0
leaq 0x2df0(%rip), %rsi      # 0x6178
movl $0x1, %edx
movq %rax, %rdi
callq 0x2170
movl (%r14), %eax
movl %eax, 0xc(%rbx)
movl 0x4(%r14), %eax
movl %eax, 0x10(%rbx)
movl 0x8(%r14), %ecx
movl %ecx, 0x14(%rbx)
testl %eax, %eax
jle 0x3460
leaq 0x18(%rbx), %rax
movq %rax, -0x30(%rbp)
leaq 0x30(%rbx), %rax
movq %rax, -0x48(%rbp)
leaq 0x48(%rbx), %r13
xorl %r12d, %r12d
movl $0x3, %r15d
movl (%r14,%r15,4), %eax
movl %eax, -0x3c(%rbp)
movq 0x20(%rbx), %rsi
cmpq 0x28(%rbx), %rsi
je 0x33eb
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x20(%rbx)
jmp 0x33f8
movq -0x30(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
callq 0x523c
movl 0x4(%r14,%r15,4), %eax
movl %eax, -0x38(%rbp)
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x3416
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rbx)
jmp 0x3423
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x523c
movl 0x8(%r14,%r15,4), %eax
movl %eax, -0x34(%rbp)
movq 0x50(%rbx), %rsi
cmpq 0x58(%rbx), %rsi
je 0x3441
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x50(%rbx)
jmp 0x344d
movq %r13, %rdi
leaq -0x34(%rbp), %rdx
callq 0x523c
incl %r12d
addq $0x3, %r15
cmpl 0x10(%rbx), %r12d
jl 0x33ce
jmp 0x3466
movl $0x3, %r15d
movq 0x5b6b(%rip), %r12      # 0x8fd8
leaq 0x2d06(%rip), %rsi      # 0x617a
movl $0x1f, %edx
movq %r12, %rdi
callq 0x2170
movl %r15d, %r13d
movl (%r14,%r13,4), %esi
movq %r12, %rdi
callq 0x20b0
leaq 0x2ce1(%rip), %r15      # 0x6178
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movl (%r14,%r13,4), %eax
movl %eax, 0x64(%rbx)
leaq 0x2ce5(%rip), %rsi      # 0x619a
movl $0x1f, %edx
movq %r12, %rdi
callq 0x2170
movl 0x4(%r14,%r13,4), %esi
movq %r12, %rdi
callq 0x20b0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movl 0x4(%r14,%r13,4), %eax
movl %eax, 0x60(%rbx)
leaq 0x2ccc(%rip), %rsi      # 0x61ba
movl $0x22, %edx
movq %r12, %rdi
callq 0x2170
movl 0x8(%r14,%r13,4), %esi
movq %r12, %rdi
callq 0x20b0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movl 0x8(%r14,%r13,4), %eax
movl %eax, 0x68(%rbx)
leaq 0x2cb6(%rip), %rsi      # 0x61dd
movl $0x10, %edx
movq %r12, %rdi
callq 0x2170
movl 0xc(%r14,%r13,4), %esi
shll $0x3, %esi
movq %r12, %rdi
callq 0x20b0
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movl 0xc(%r14,%r13,4), %eax
movl %eax, 0x6c(%rbx)
leaq (%r14,%r13,4), %rax
addq $0x10, %rax
movq %rax, 0x70(%rbx)
leaq 0x2c7f(%rip), %rsi      # 0x61ee
movl $0xb, %edx
movq %r12, %rdi
callq 0x2170
cmpl $0x0, 0x6c(%rbx)
jle 0x35cd
addq $0x4, %r13
leaq (%r14,%r13,4), %rax
movq %rax, -0x30(%rbp)
xorl %r13d, %r13d
movq 0x5a40(%rip), %r14      # 0x8fd8
movq -0x30(%rbp), %rax
movl (%rax,%r13,4), %r15d
xorl %r12d, %r12d
movl $0x1, %esi
movl %r12d, %ecx
shll %cl, %esi
andl %r15d, %esi
movq %r14, %rdi
callq 0x20b0
incl %r12d
cmpl $0x8, %r12d
jne 0x35a3
incq %r13
movslq 0x6c(%rbx), %rax
cmpq %rax, %r13
jl 0x3598
movq 0x5a04(%rip), %rbx      # 0x8fd8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
leaq 0x2bf8(%rip), %rsi      # 0x61fa
movl $0x1f, %edx
movq %rbx, %rdi
callq 0x2170
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop