// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movq %rdi, %r14
movq %rsi, (%rdx)
movq (%rdi), %rdi
addq $0x8, %rdx
callq 0x3e32
testb %al, %al
je 0x2f9c
movq 0x517e(%rip), %r12      # 0x7fd8
movq %r12, %rdi
callq 0x20b0
leaq 0x22d7(%rip), %rsi      # 0x5140
movq %r12, %rdi
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
leaq 0x23b7(%rip), %rsi      # 0x523a
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq 0x8(%r14), %rdi
movl 0x8(%rbx), %esi
movl 0x78(%rbx), %edx
leaq 0x88(%rbx), %rcx
callq 0x3b76
movq %rax, %r14
movq %rax, 0x80(%rbx)
andl $0x0, 0xc(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
andq $0x0, 0x70(%rbx)
leaq 0x2285(%rip), %rsi      # 0x514f
movq %r12, %rdi
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
leaq 0x2277(%rip), %rsi      # 0x515b
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20b0
leaq 0x226c(%rip), %rsi      # 0x5167
movq %r12, %rdi
callq 0x2170
movl (%r14), %esi
movq %rax, %rdi
callq 0x20e0
leaq 0x2263(%rip), %rsi      # 0x5178
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)
leaq 0x18(%rbx), %rcx
movq %rcx, -0x30(%rbp)
leaq 0x30(%rbx), %r12
movq %rbx, -0x38(%rbp)
leaq 0x48(%rbx), %r13
xorl %r15d, %r15d
pushq $0x3
popq %rbx
cmpl %eax, %r15d
jge 0x2fca
movl (%r14,%rbx,4), %eax
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x4c98
movl 0x4(%r14,%rbx,4), %eax
movl %eax, -0x40(%rbp)
movq %r12, %rdi
leaq -0x40(%rbp), %rsi
callq 0x4c98
movl 0x8(%r14,%rbx,4), %eax
addq $0x3, %rbx
movl %eax, -0x3c(%rbp)
movq %r13, %rdi
leaq -0x3c(%rbp), %rsi
callq 0x4c98
incl %r15d
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
jmp 0x2f4b
movq 0x5035(%rip), %rdi      # 0x7fd8
leaq 0x2117(%rip), %rsi      # 0x50c1
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
movq %rax, %rdi
callq 0x20b0
pushq $0x67
popq %rax
jmp 0x3138
movq 0x5007(%rip), %r15      # 0x7fd8
leaq 0x21a2(%rip), %rsi      # 0x517a
movq %r15, %rdi
callq 0x2170
movl %ebx, %r13d
movl (%r14,%r13,4), %esi
movq %rax, %rdi
callq 0x20e0
leaq 0x2182(%rip), %rsi      # 0x5178
movq %rax, %rdi
callq 0x2170
movl (%r14,%r13,4), %eax
movq -0x38(%rbp), %r12
movl %eax, 0x64(%r12)
leaq 0x2188(%rip), %rsi      # 0x519a
movq %r15, %rdi
callq 0x2170
movl 0x4(%r14,%r13,4), %esi
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
leaq 0x2147(%rip), %rsi      # 0x5178
callq 0x2170
movl 0x4(%r14,%r13,4), %eax
movl %eax, 0x60(%r12)
leaq 0x2173(%rip), %rsi      # 0x51ba
movq %r15, %rdi
callq 0x2170
movl 0x8(%r14,%r13,4), %esi
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
leaq 0x2112(%rip), %rsi      # 0x5178
callq 0x2170
movl 0x8(%r14,%r13,4), %eax
movl %eax, 0x68(%r12)
leaq 0x2161(%rip), %rsi      # 0x51dd
movq %r15, %rdi
callq 0x2170
movl 0xc(%r14,%r13,4), %esi
shll $0x3, %esi
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
leaq 0x20da(%rip), %rsi      # 0x5178
callq 0x2170
addl $0x4, %ebx
movl 0xc(%r14,%r13,4), %eax
movl %eax, 0x6c(%r12)
leaq (%r14,%rbx,4), %rax
movq %r12, %rbx
movq %rax, -0x30(%rbp)
movq %rax, 0x70(%r12)
leaq 0x2127(%rip), %rsi      # 0x51ee
movq %r15, %rdi
callq 0x2170
xorl %r12d, %r12d
pushq $0x1
popq %r13
movslq 0x6c(%rbx), %rax
cmpq %rax, %r12
jge 0x3110
movq -0x30(%rbp), %rax
movl (%rax,%r12,4), %ebx
xorl %r14d, %r14d
cmpl $0x8, %r14d
je 0x3107
movl %r13d, %esi
movl %r14d, %ecx
shll %cl, %esi
andl %ebx, %esi
movq %r15, %rdi
callq 0x20e0
incl %r14d
jmp 0x30ea
incq %r12
movq -0x38(%rbp), %rbx
jmp 0x30d6
movq 0x4ec1(%rip), %rbx      # 0x7fd8
movq %rbx, %rdi
callq 0x20b0
leaq 0x20d4(%rip), %rsi      # 0x51fa
movq %rbx, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20b0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop