// File: /workspace/github_cpp_makefile_star2_O1/jasperandrew[P]cs350-project2/./lab7.h
// Function: readInode(int)
inode readInode(int inode_num)
{
    int inode_block = g_imap.list[inode_num];
    int seg_idx = inode_block/BLOCK_SZ;
    int seg_block = inode_block % BLOCK_SZ;
		inode tmp_inode;

    if(seg_idx == current_segment){
        tmp_inode = wbuffer.getBlock(seg_block-1)->getInode();
    }else{
        string seg_path = "DRIVE/SEGMENT" + to_string(seg_idx+1);
        ifstream segment(seg_path, ios::in | ios::binary);
        segment.seekg(BLOCK_SZ * (seg_block-1));

        char tmp[sizeof(inode)];
        segment.read(tmp, sizeof(inode));
        segment.close();

        memcpy(&tmp_inode, tmp, sizeof(inode));
		}
    return tmp_inode;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x538, %rsp            # imm = 0x538
movq %rdi, %r15
movslq %esi, %rax
leaq 0x16a81b(%rip), %rcx    # 0x16d718
movl (%rcx,%rax,4), %ebx
leal 0x3ff(%rbx), %eax
testl %ebx, %ebx
cmovnsl %ebx, %eax
movl %eax, %r14d
sarl $0xa, %r14d
andl $0xfffffc00, %eax       # imm = 0xFFFFFC00
subl %eax, %ebx
cmpl 0x106324(%rip), %r14d   # 0x109244
jne 0x2f48
movslq %ebx, %rax
leaq 0x1747f4(%rip), %rcx    # 0x177720
movl $0x404, %esi            # imm = 0x404
addq -0x8(%rcx,%rax,8), %rsi
movl $0x304, %edx            # imm = 0x304
movq %r15, %rdi
callq 0x2170
jmp 0x30e0
movq %r15, -0x30(%rbp)
incl %r14d
movl %r14d, %r15d
negl %r15d
cmovsl %r14d, %r15d
movl $0x1, %r12d
cmpl $0xa, %r15d
jb 0x2faf
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0x2fa6
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x2fac
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x2faf
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x2f73
addl $-0x3, %r12d
jmp 0x2faf
addl $-0x2, %r12d
jmp 0x2faf
decl %r12d
shrl $0x1f, %r14d
leal (%r12,%r14), %esi
leaq -0x550(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x560(%rbp), %r13
movq %r13, %rdi
movl $0x2d, %edx
callq 0x2250
addq (%r13), %r14
movq %r14, %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x54a4
leaq 0x3025(%rip), %rcx      # 0x6014
movl $0xd, %r8d
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2230
leaq -0x40(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movq -0x30(%rbp), %r15
je 0x3029
movq %rdx, -0x50(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x40(%rbp)
jmp 0x3030
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x48(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x560(%rbp), %rdi
leaq -0x550(%rbp), %rax
cmpq %rax, %rdi
je 0x305f
callq 0x21b0
leaq -0x258(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movl $0xc, %edx
callq 0x2360
shll $0xa, %ebx
addl $0xfffffc00, %ebx       # imm = 0xFFFFFC00
movslq %ebx, %rsi
leaq -0x258(%rbp), %rdi
xorl %edx, %edx
callq 0x22a0
leaq -0x258(%rbp), %rdi
leaq -0x560(%rbp), %rsi
movl $0x304, %edx            # imm = 0x304
callq 0x2290
leaq -0x258(%rbp), %rdi
callq 0x2060
leaq -0x560(%rbp), %rsi
movl $0x304, %edx            # imm = 0x304
movq %r15, %rdi
callq 0x2170
leaq -0x258(%rbp), %rdi
callq 0x2070
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x30e0
callq 0x21b0
movq %r15, %rax
addq $0x538, %rsp            # imm = 0x538
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3114
movq %rax, %rbx
jmp 0x3123
movq %rax, %rbx
movq -0x560(%rbp), %rdi
leaq -0x550(%rbp), %rax
cmpq %rax, %rdi
jne 0x312c
jmp 0x3131
movq %rax, %rbx
leaq -0x258(%rbp), %rdi
callq 0x2070
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x3131
callq 0x21b0
movq %rbx, %rdi
callq 0x23a0