// File: /workspace/github_cpp_makefile_star2_O1/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 0x485c
testb %al, %al
je 0x3264
movq 0x5dd0(%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 0x2f0a(%rip), %rsi      # 0x6140
movl $0xe, %edx
movq %r15, %rdi
callq 0x2170
testq %r12, %r12
je 0x32a7
movq %r12, %rdi
callq 0x2070
movq 0x5d81(%rip), %rdi      # 0x8fd8
movq %r12, %rsi
movq %rax, %rdx
callq 0x2170
jmp 0x32bf
movq 0x5d6d(%rip), %rbx      # 0x8fd8
leaq 0x2e4f(%rip), %rsi      # 0x60c1
movl $0x12, %edx
movq %rbx, %rdi
callq 0x2170
testq %r12, %r12
je 0x3365
movq %r12, %rdi
callq 0x2070
movq 0x5d41(%rip), %rdi      # 0x8fd8
movq %r12, %rsi
movq %rax, %rdx
callq 0x2170
jmp 0x337c
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x21e0
leaq 0x2f74(%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 0x4570
movq %rax, %r14
movq %rax, 0x80(%rbx)
movl $0x0, 0xc(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
movq $0x0, 0x70(%rbx)
leaq 0x2e18(%rip), %rsi      # 0x614f
movl $0xb, %edx
movq %r15, %rdi
callq 0x2170
testq %r12, %r12
je 0x3386
movq %r12, %rdi
callq 0x2070
movq 0x5c80(%rip), %rdi      # 0x8fd8
movq %r12, %rsi
movq %rax, %rdx
callq 0x2170
jmp 0x339e
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x21e0
movl $0x67, %ebx
jmp 0x3694
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x21e0
leaq 0x2db6(%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 0x2d87(%rip), %rsi      # 0x6167
movl $0x10, %edx
movq %r15, %rdi
callq 0x2170
movl (%r14), %esi
movq %r15, %rdi
callq 0x20b0
leaq 0x2d79(%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 0x34d7
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 0x3462
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x20(%rbx)
jmp 0x346f
movq -0x30(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
callq 0x531a
movl 0x4(%r14,%r15,4), %eax
movl %eax, -0x38(%rbp)
movq 0x38(%rbx), %rsi
cmpq 0x40(%rbx), %rsi
je 0x348d
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rbx)
jmp 0x349a
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x531a
movl 0x8(%r14,%r15,4), %eax
movl %eax, -0x34(%rbp)
movq 0x50(%rbx), %rsi
cmpq 0x58(%rbx), %rsi
je 0x34b8
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x50(%rbx)
jmp 0x34c4
movq %r13, %rdi
leaq -0x34(%rbp), %rdx
callq 0x531a
incl %r12d
addq $0x3, %r15
cmpl 0x10(%rbx), %r12d
jl 0x3445
jmp 0x34dd
movl $0x3, %r15d
movq 0x5af4(%rip), %r13      # 0x8fd8
leaq 0x2c8f(%rip), %rsi      # 0x617a
movl $0x1f, %edx
movq %r13, %rdi
callq 0x2170
movl %r15d, %r12d
movl (%r14,%r12,4), %esi
movq %r13, %rdi
callq 0x20b0
leaq 0x2c6a(%rip), %rsi      # 0x6178
movl $0x1, %edx
movq %rax, %rdi
callq 0x2170
movl (%r14,%r12,4), %eax
movl %eax, 0x64(%rbx)
leaq 0x2c71(%rip), %rsi      # 0x619a
movl $0x1f, %edx
movq %r13, %rdi
callq 0x2170
movl 0x4(%r14,%r12,4), %esi
movq %r13, %rdi
callq 0x20b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2c26(%rip), %rsi      # 0x6178
callq 0x2170
movl 0x4(%r14,%r12,4), %eax
movl %eax, 0x60(%rbx)
leaq 0x2c54(%rip), %rsi      # 0x61ba
movl $0x22, %edx
movq %r13, %rdi
callq 0x2170
movl 0x8(%r14,%r12,4), %esi
movq %r13, %rdi
callq 0x20b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2be9(%rip), %rsi      # 0x6178
callq 0x2170
movl 0x8(%r14,%r12,4), %eax
movl %eax, 0x68(%rbx)
leaq 0x2c3a(%rip), %rsi      # 0x61dd
movl $0x10, %edx
movq %r13, %rdi
callq 0x2170
movl 0xc(%r14,%r12,4), %esi
shll $0x3, %esi
movq %r13, %rdi
callq 0x20b0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2ba9(%rip), %rsi      # 0x6178
callq 0x2170
movl 0xc(%r14,%r12,4), %eax
movl %eax, 0x6c(%rbx)
leaq (%r14,%r12,4), %rax
addq $0x10, %rax
movq %rax, 0x70(%rbx)
leaq 0x2bff(%rip), %rsi      # 0x61ee
movl $0xb, %edx
movq %r13, %rdi
callq 0x2170
cmpl $0x0, 0x6c(%rbx)
jle 0x3650
addl $0x4, %r15d
movl %r15d, %eax
leaq (%r14,%rax,4), %rax
movq %rax, -0x30(%rbp)
xorl %r13d, %r13d
movq 0x59bd(%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 0x3626
incq %r13
movslq 0x6c(%rbx), %rax
cmpq %rax, %r13
jl 0x361b
movq 0x5981(%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 0x2b75(%rip), %rsi      # 0x61fa
movl $0x1f, %edx
movq %rbx, %rdi
callq 0x2170
xorl %ebx, %ebx
movq 0x593d(%rip), %r14      # 0x8fd8
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20c0
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop