// File: /workspace/github_cpp_makefile_star2_O3/ljl0222[P]SecondFileSystem/FileManager.cpp
// Function: FileManager::Ls()
void FileManager::Ls() 
{
    User& u = globalUser;
    BufferManager& bufferManager = globalBufferManager;

    Inode* pINode = u.u_cdir;
    Buf* pBuffer = NULL;
    u.u_IOParam.m_Offset = 0;
    u.u_IOParam.m_Count = pINode->i_size / sizeof(DirectoryEntry);

    int lsCnt = 0;

    while (u.u_IOParam.m_Count) 
    {
        if (0 == u.u_IOParam.m_Offset % Inode::BLOCK_SIZE) 
        {
            if (pBuffer) 
            {
                bufferManager.Brelse(pBuffer);
            }
            int phyBlkno = pINode->Bmap(u.u_IOParam.m_Offset / Inode::BLOCK_SIZE);
            pBuffer = bufferManager.Bread(phyBlkno);
        }
        memcpy(&u.u_dent, pBuffer->b_addr + (u.u_IOParam.m_Offset % Inode::BLOCK_SIZE), sizeof(u.u_dent));
        u.u_IOParam.m_Offset += sizeof(DirectoryEntry);
        u.u_IOParam.m_Count--;

        if (0 == u.u_dent.m_ino)
            continue;
        u.ls += u.u_dent.name;
        u.ls += " ";
        lsCnt++;
        if (lsCnt % 7 == 0)
            u.ls += "\n";
    }

    if (pBuffer) 
    {
        bufferManager.Brelse(pBuffer);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x18fc4(%rip), %r15     # 0x1dbd8
movq 0x1058(%r15), %rbx
movl $0x0, 0x13f8(%r15)
movl 0x1c(%rbx), %eax
sarl $0x5, %eax
movl %eax, 0x13fc(%r15)
xorl %r13d, %r13d
leaq 0x8623(%rip), %r14      # 0xd260
leaq 0x1408(%r15), %rcx
movq %rcx, -0x48(%rbp)
leaq 0x106c(%r15), %rcx
movq %rcx, -0x40(%rbp)
movl $0x1408, %ecx           # imm = 0x1408
addq 0x8371(%rip), %rcx      # 0xcfd0
movq %rcx, -0x30(%rbp)
xorl %r12d, %r12d
testl %eax, %eax
je 0x4d70
movl 0x13f8(%r15), %ecx
testl $0x1ff, %ecx            # imm = 0x1FF
jne 0x4cc5
testq %r12, %r12
je 0x4c94
movq %r14, %rdi
movq %r12, %rsi
callq 0x3a58
movl 0x13f8(%r15), %ecx
leal 0x1ff(%rcx), %esi
testl %ecx, %ecx
cmovnsl %ecx, %esi
sarl $0x9, %esi
movq %rbx, %rdi
callq 0x5684
movq %r14, %rdi
movl %eax, %esi
callq 0x3aa4
movq %rax, %r12
movl 0x13f8(%r15), %ecx
movl 0x13fc(%r15), %eax
movq 0x20(%r12), %rdx
leal 0x1ff(%rcx), %esi
testl %ecx, %ecx
cmovnsl %ecx, %esi
andl $0xfffffe00, %esi       # imm = 0xFFFFFE00
movl %ecx, %edi
subl %esi, %edi
movslq %edi, %rsi
movups (%rdx,%rsi), %xmm0
movups 0x10(%rdx,%rsi), %xmm1
movups %xmm0, 0x1068(%r15)
movups %xmm1, 0x1078(%r15)
addl $0x20, %ecx
movl %ecx, 0x13f8(%r15)
decl %eax
movl %eax, 0x13fc(%r15)
cmpl $0x0, 0x1068(%r15)
je 0x4c66
movq %r13, -0x38(%rbp)
movq -0x48(%rbp), %r13
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x3410
movq %r13, %rdi
movq -0x38(%rbp), %r13
leaq 0x43fa(%rip), %rsi      # 0x9138
callq 0x3410
incl %r13d
imull $0xb6db6db7, %r13d, %eax # imm = 0xB6DB6DB7
cmpl $0x24924924, %eax       # imm = 0x24924924
ja 0x4d64
movq -0x30(%rbp), %rdi
leaq 0x4369(%rip), %rsi      # 0x90c8
callq 0x3410
movl 0x13fc(%r15), %eax
jmp 0x4c66
testq %r12, %r12
je 0x4d92
leaq 0x84e4(%rip), %rdi      # 0xd260
movq %r12, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a58
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop