// File: NishadSaraf[P]Championship-Simulator/src/cache.cc
// Function: CACHE::handle_fill()
void CACHE::handle_fill()
{
    // handle fill
    uint32_t fill_cpu = (MSHR.next_fill_index == MSHR_SIZE) ? NUM_CPUS : MSHR.entry[MSHR.next_fill_index].cpu;
    if (fill_cpu == NUM_CPUS)
        return;

    if (MSHR.next_fill_cycle <= current_core_cycle[fill_cpu]) {

#ifdef SANITY_CHECK
        if (MSHR.next_fill_index >= MSHR.SIZE)
            assert(0);
#endif

        uint32_t mshr_index = MSHR.next_fill_index;

        // find victim
        uint32_t set = get_set(MSHR.entry[mshr_index].address), way;
        if (cache_type == IS_LLC) {
            way = llc_find_victim(fill_cpu, MSHR.entry[mshr_index].instr_id, set, block[set], MSHR.entry[mshr_index].ip, MSHR.entry[mshr_index].full_addr, MSHR.entry[mshr_index].type);
        }
        else
            way = find_victim(fill_cpu, MSHR.entry[mshr_index].instr_id, set, block[set], MSHR.entry[mshr_index].ip, MSHR.entry[mshr_index].full_addr, MSHR.entry[mshr_index].type);

#ifdef LLC_BYPASS
        if ((cache_type == IS_LLC) && (way == LLC_WAY)) { // this is a bypass that does not fill the LLC

            // update replacement policy
            if (cache_type == IS_LLC) {
                llc_update_replacement_state(fill_cpu, set, way, MSHR.entry[mshr_index].full_addr, MSHR.entry[mshr_index].ip, 0, MSHR.entry[mshr_index].type, 0);

            }
            else
                update_replacement_state(fill_cpu, set, way, MSHR.entry[mshr_index].full_addr, MSHR.entry[mshr_index].ip, 0, MSHR.entry[mshr_index].type, 0);

            // COLLECT STATS
            sim_miss[fill_cpu][MSHR.entry[mshr_index].type]++;
            sim_access[fill_cpu][MSHR.entry[mshr_index].type]++;

            // check fill level
            if (MSHR.entry[mshr_index].fill_level < fill_level) {

                if (MSHR.entry[mshr_index].instruction) 
                    upper_level_icache[fill_cpu]->return_data(&MSHR.entry[mshr_index]);
                else // data
                    upper_level_dcache[fill_cpu]->return_data(&MSHR.entry[mshr_index]);
            }

            MSHR.remove_queue(&MSHR.entry[mshr_index]);
            MSHR.num_returned--;

            update_fill_cycle();

            return; // return here, no need to process further in this function
        }
#endif

        uint8_t  do_fill = 1;

        // is this dirty?
        if (block[set][way].dirty) {

            // check if the lower level WQ has enough room to keep this writeback request
            if (lower_level) {
                if (lower_level->get_occupancy(2) == lower_level->get_size(2)) {

                    // lower level WQ is full, cannot replace this victim
                    do_fill = 0;
                    lower_level->increment_WQ_FULL();
                    STALL[MSHR.entry[mshr_index].type]++;

                    DP ( if (warmup_complete[fill_cpu]) {
                    cout << "[" << NAME << "] " << __func__ << "do_fill: " << +do_fill;
                    cout << " lower level wq is full!" << " fill_addr: " << hex << MSHR.entry[mshr_index].address;
                    cout << " victim_addr: " << block[set][way].tag << dec << endl; });
                }
                else {
                    PACKET writeback_packet;

                    writeback_packet.fill_level = fill_level << 1;
                    writeback_packet.cpu = fill_cpu;
                    writeback_packet.address = block[set][way].address;
                    writeback_packet.full_addr = block[set][way].full_addr;
                    writeback_packet.data = block[set][way].data;
                    writeback_packet.instr_id = MSHR.entry[mshr_index].instr_id;
                    writeback_packet.ip = 0; // writeback does not have ip
                    writeback_packet.type = WRITEBACK;
                    writeback_packet.event_cycle = current_core_cycle[fill_cpu];

                    lower_level->add_wq(&writeback_packet);
                }
            }
#ifdef SANITY_CHECK
            else {
                // sanity check
                if (cache_type != IS_STLB)
                    assert(0);
            }
#endif
        }

        if (do_fill) {
            // update prefetcher
            if (cache_type == IS_L1D)
                l1d_prefetcher_cache_fill(MSHR.entry[mshr_index].full_addr, set, way, (MSHR.entry[mshr_index].type == PREFETCH) ? 1 : 0, block[set][way].full_addr);
            if  (cache_type == IS_L2C)
                l2c_prefetcher_cache_fill(MSHR.entry[mshr_index].full_addr, set, way, (MSHR.entry[mshr_index].type == PREFETCH) ? 1 : 0, block[set][way].full_addr);

            // update replacement policy
            if (cache_type == IS_LLC) {
                llc_update_replacement_state(fill_cpu, set, way, MSHR.entry[mshr_index].full_addr, MSHR.entry[mshr_index].ip, block[set][way].full_addr, MSHR.entry[mshr_index].type, 0);

            }
            else
                update_replacement_state(fill_cpu, set, way, MSHR.entry[mshr_index].full_addr, MSHR.entry[mshr_index].ip, block[set][way].full_addr, MSHR.entry[mshr_index].type, 0);

            // COLLECT STATS
            sim_miss[fill_cpu][MSHR.entry[mshr_index].type]++;
            sim_access[fill_cpu][MSHR.entry[mshr_index].type]++;

            fill_cache(set, way, &MSHR.entry[mshr_index]);

            // RFO marks cache line dirty
            if (cache_type == IS_L1D) {
                if (MSHR.entry[mshr_index].type == RFO)
                    block[set][way].dirty = 1;
            }

            // check fill level
            if (MSHR.entry[mshr_index].fill_level < fill_level) {

                if (MSHR.entry[mshr_index].instruction) 
                    upper_level_icache[fill_cpu]->return_data(&MSHR.entry[mshr_index]);
                else // data
                    upper_level_dcache[fill_cpu]->return_data(&MSHR.entry[mshr_index]);
            }

            // update processed packets
            if (cache_type == IS_ITLB) { 
                MSHR.entry[mshr_index].instruction_pa = block[set][way].data;
                if (PROCESSED.occupancy < PROCESSED.SIZE)
                    PROCESSED.add_queue(&MSHR.entry[mshr_index]);
            }
            else if (cache_type == IS_DTLB) {
                MSHR.entry[mshr_index].data_pa = block[set][way].data;
                if (PROCESSED.occupancy < PROCESSED.SIZE)
                    PROCESSED.add_queue(&MSHR.entry[mshr_index]);
            }
            else if (cache_type == IS_L1I) {
                if (PROCESSED.occupancy < PROCESSED.SIZE)
                    PROCESSED.add_queue(&MSHR.entry[mshr_index]);
            }
            //else if (cache_type == IS_L1D) {
            else if ((cache_type == IS_L1D) && (MSHR.entry[mshr_index].type != PREFETCH)) {
                if (PROCESSED.occupancy < PROCESSED.SIZE)
                    PROCESSED.add_queue(&MSHR.entry[mshr_index]);
            }

            MSHR.remove_queue(&MSHR.entry[mshr_index]);
            MSHR.num_returned--;

            update_fill_cycle();
        }
    }
}

// Assembly:
subq $0x3c8, %rsp            # imm = 0x3C8
movq %rdi, 0x3c0(%rsp)
movq 0x3c0(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movl 0xc9c4(%rcx), %eax
cmpl 0x7388(%rcx), %eax
jne 0x3b35
movl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x3b5b
movq 0x20(%rsp), %rcx
movq 0xca20(%rcx), %rax
movl 0xc9c4(%rcx), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movl 0x330(%rax), %eax
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x3bc(%rsp)
cmpl $0x1, 0x3bc(%rsp)
jne 0x3b75
jmp 0x49a2
movq 0x20(%rsp), %rax
movq 0xc9d0(%rax), %rax
movl 0x3bc(%rsp), %ecx
movl %ecx, %edx
leaq 0x8c32f(%rip), %rcx     # 0x8fec0
cmpq (%rcx,%rdx,8), %rax
ja 0x49a2
movq 0x20(%rsp), %rcx
movl 0xc9c4(%rcx), %eax
cmpl 0xc9a8(%rcx), %eax
jb 0x3bcd
leaq 0x1f44f(%rip), %rdi     # 0x23004
leaq 0x1f44a(%rip), %rsi     # 0x23006
movl $0x10, %edx
leaq 0x1f44b(%rip), %rcx     # 0x23013
callq 0x3160
movq 0x20(%rsp), %rdi
movl 0xc9c4(%rdi), %eax
movl %eax, 0x3b8(%rsp)
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movq 0x340(%rax), %rsi
callq 0x49b0
movl %eax, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x3b4(%rsp)
movzbl 0x73a4(%rax), %eax
cmpl $0x6, %eax
jne 0x3cdf
movq 0x20(%rsp), %rdi
movl 0x3bc(%rsp), %esi
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movq 0x368(%rax), %rdx
movl 0x3b4(%rsp), %ecx
movq 0x7390(%rdi), %rax
movl 0x3b4(%rsp), %r8d
movq (%rax,%r8,8), %r8
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r9d
imulq $0x380, %r9, %r9        # imm = 0x380
addq %r9, %rax
movq 0x370(%rax), %r9
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r10d
imulq $0x380, %r10, %r10      # imm = 0x380
addq %r10, %rax
movq 0x348(%rax), %r10
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r11d
imulq $0x380, %r11, %r11      # imm = 0x380
addq %r11, %rax
movzbl 0x32f(%rax), %eax
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x226f0
movl %eax, 0x3b0(%rsp)
jmp 0x3d98
movq 0x20(%rsp), %rdi
movl 0x3bc(%rsp), %esi
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movq 0x368(%rax), %rdx
movl 0x3b4(%rsp), %ecx
movq 0x7390(%rdi), %rax
movl 0x3b4(%rsp), %r8d
movq (%rax,%r8,8), %r8
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r9d
imulq $0x380, %r9, %r9        # imm = 0x380
addq %r9, %rax
movq 0x370(%rax), %r9
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r10d
imulq $0x380, %r10, %r10      # imm = 0x380
addq %r10, %rax
movq 0x348(%rax), %r10
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r11d
imulq $0x380, %r11, %r11      # imm = 0x380
addq %r11, %rax
movzbl 0x32f(%rax), %eax
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x22300
movl %eax, 0x3b0(%rsp)
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x6, %eax
jne 0x4085
cmpl $0x10, 0x3b0(%rsp)
jne 0x4085
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x6, %eax
jne 0x3e6e
movq 0x20(%rsp), %rdi
movl 0x3bc(%rsp), %esi
movl 0x3b4(%rsp), %edx
movl 0x3b0(%rsp), %ecx
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r8d
imulq $0x380, %r8, %r8        # imm = 0x380
addq %r8, %rax
movq 0x348(%rax), %r8
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r9d
imulq $0x380, %r9, %r9        # imm = 0x380
addq %r9, %rax
movq 0x370(%rax), %r9
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r10d
imulq $0x380, %r10, %r10      # imm = 0x380
addq %r10, %rax
movzbl 0x32f(%rax), %eax
xorl %r10d, %r10d
xorl %r10d, %r10d
movq $0x0, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x22750
jmp 0x3f07
movq 0x20(%rsp), %rdi
movl 0x3bc(%rsp), %esi
movl 0x3b4(%rsp), %edx
movl 0x3b0(%rsp), %ecx
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r8d
imulq $0x380, %r8, %r8        # imm = 0x380
addq %r8, %rax
movq 0x348(%rax), %r8
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r9d
imulq $0x380, %r9, %r9        # imm = 0x380
addq %r9, %rax
movq 0x370(%rax), %r9
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r10d
imulq $0x380, %r10, %r10      # imm = 0x380
addq %r10, %rax
movzbl 0x32f(%rax), %eax
xorl %r10d, %r10d
xorl %r10d, %r10d
movq $0x0, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x22510
movq 0x20(%rsp), %rcx
movq %rcx, %rax
addq $0x10328, %rax          # imm = 0x10328
movl 0x3bc(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rax
movq 0xca20(%rcx), %rdx
movl 0x3b8(%rsp), %esi
imulq $0x380, %rsi, %rsi      # imm = 0x380
addq %rsi, %rdx
movzbl 0x32f(%rdx), %edx
movq (%rax,%rdx,8), %rsi
addq $0x1, %rsi
movq %rsi, (%rax,%rdx,8)
movq %rcx, %rax
addq $0x102e8, %rax          # imm = 0x102E8
movl 0x3bc(%rsp), %edx
shlq $0x5, %rdx
addq %rdx, %rax
movq 0xca20(%rcx), %rdx
movl 0x3b8(%rsp), %esi
imulq $0x380, %rsi, %rsi      # imm = 0x380
addq %rsi, %rdx
movzbl 0x32f(%rdx), %edx
movq (%rax,%rdx,8), %rsi
addq $0x1, %rsi
movq %rsi, (%rax,%rdx,8)
movq 0xca20(%rcx), %rax
movl 0x3b8(%rsp), %edx
imulq $0x380, %rdx, %rdx      # imm = 0x380
addq %rdx, %rax
movl 0x8(%rax), %eax
cmpl 0x7398(%rcx), %eax
jge 0x403b
movq 0x20(%rsp), %rax
movq 0xca20(%rax), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
cmpb $0x0, (%rax)
je 0x400a
movq 0x20(%rsp), %rax
movl 0x3bc(%rsp), %ecx
movq 0x8(%rax,%rcx,8), %rdi
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x4039
movq 0x20(%rsp), %rax
movl 0x3bc(%rsp), %ecx
movq 0x10(%rax,%rcx,8), %rdi
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x403b
movq 0x20(%rsp), %rax
movq %rax, %rdi
addq $0xc988, %rdi           # imm = 0xC988
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
callq 0x150e0
movq 0x20(%rsp), %rdi
movl 0xc9c0(%rdi), %eax
addl $-0x1, %eax
movl %eax, 0xc9c0(%rdi)
callq 0x4a00
jmp 0x49a2
movq 0x20(%rsp), %rax
movb $0x1, 0x3af(%rsp)
movq 0x7390(%rax), %rax
movl 0x3b4(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x3b0(%rsp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x2(%rax)
je 0x42a1
movq 0x20(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x426d
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
movl $0x2, %esi
callq *0x30(%rax)
movl %eax, %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x18(%rsp)
movq 0x18(%rax), %rdi
movq (%rdi), %rax
movl $0x2, %esi
callq *0x38(%rax)
movl %eax, %ecx
movl 0x18(%rsp), %eax
cmpl %ecx, %eax
jne 0x4158
movq 0x20(%rsp), %rax
movb $0x0, 0x3af(%rsp)
movq 0x18(%rax), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x20(%rsp), %rax
movq 0xca20(%rax), %rcx
movl 0x3b8(%rsp), %edx
imulq $0x380, %rdx, %rdx      # imm = 0x380
addq %rdx, %rcx
movzbl 0x32f(%rcx), %ecx
movq 0x7328(%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, 0x7328(%rax,%rcx,8)
jmp 0x426b
leaq 0x28(%rsp), %rdi
callq 0x9750
movq 0x20(%rsp), %rax
movl 0x7398(%rax), %ecx
shll %ecx
movl %ecx, 0x30(%rsp)
movl 0x3bc(%rsp), %ecx
movl %ecx, 0x358(%rsp)
movq 0x7390(%rax), %rcx
movl 0x3b4(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x3b0(%rsp), %edx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movq %rcx, 0x368(%rsp)
movq 0x7390(%rax), %rcx
movl 0x3b4(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x3b0(%rsp), %edx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
movq 0x20(%rcx), %rcx
movq %rcx, 0x370(%rsp)
movq 0x7390(%rax), %rcx
movl 0x3b4(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movl 0x3b0(%rsp), %edx
imulq $0x50, %rdx, %rdx
addq %rdx, %rcx
movq 0x30(%rcx), %rcx
movq %rcx, 0x388(%rsp)
movq 0xca20(%rax), %rcx
movl 0x3b8(%rsp), %edx
imulq $0x380, %rdx, %rdx      # imm = 0x380
addq %rdx, %rcx
movq 0x368(%rcx), %rcx
movq %rcx, 0x390(%rsp)
movq $0x0, 0x398(%rsp)
movb $0x3, 0x357(%rsp)
movl 0x3bc(%rsp), %ecx
movl %ecx, %edx
leaq 0x8bc70(%rip), %rcx     # 0x8fec0
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x3a0(%rsp)
movq 0x18(%rax), %rdi
movq (%rdi), %rax
leaq 0x28(%rsp), %rsi
callq *0x8(%rax)
jmp 0x429f
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x2, %eax
je 0x429d
leaq 0x1ed7f(%rip), %rdi     # 0x23004
leaq 0x1ed7a(%rip), %rsi     # 0x23006
movl $0x65, %edx
leaq 0x1ed7b(%rip), %rcx     # 0x23013
callq 0x3160
jmp 0x429f
jmp 0x42a1
cmpb $0x0, 0x3af(%rsp)
je 0x49a0
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x4, %eax
jne 0x4356
movq 0x20(%rsp), %rdi
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movq 0x348(%rax), %rsi
movl 0x3b4(%rsp), %edx
movl 0x3b0(%rsp), %ecx
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r8d
imulq $0x380, %r8, %r8        # imm = 0x380
addq %r8, %rax
movzbl 0x32f(%rax), %r9d
xorl %eax, %eax
movl $0x1, %r8d
cmpl $0x2, %r9d
cmovel %r8d, %eax
movq 0x7390(%rdi), %r8
movl 0x3b4(%rsp), %r9d
movq (%r8,%r9,8), %r8
movl 0x3b0(%rsp), %r9d
imulq $0x50, %r9, %r9
addq %r9, %r8
movq 0x20(%r8), %r9
movzbl %al, %r8d
callq 0x229a0
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x5, %eax
jne 0x43fd
movq 0x20(%rsp), %rdi
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movq 0x348(%rax), %rsi
movl 0x3b4(%rsp), %edx
movl 0x3b0(%rsp), %ecx
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r8d
imulq $0x380, %r8, %r8        # imm = 0x380
addq %r8, %rax
movzbl 0x32f(%rax), %r9d
xorl %eax, %eax
movl $0x1, %r8d
cmpl $0x2, %r9d
cmovel %r8d, %eax
movq 0x7390(%rdi), %r8
movl 0x3b4(%rsp), %r9d
movq (%r8,%r9,8), %r8
movl 0x3b0(%rsp), %r9d
imulq $0x50, %r9, %r9
addq %r9, %r8
movq 0x20(%r8), %r9
movzbl %al, %r8d
callq 0x22940
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x6, %eax
jne 0x44cf
movq 0x20(%rsp), %rdi
movl 0x3bc(%rsp), %esi
movl 0x3b4(%rsp), %edx
movl 0x3b0(%rsp), %ecx
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r8d
imulq $0x380, %r8, %r8        # imm = 0x380
addq %r8, %rax
movq 0x348(%rax), %r8
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r9d
imulq $0x380, %r9, %r9        # imm = 0x380
addq %r9, %rax
movq 0x370(%rax), %r9
movq 0x7390(%rdi), %rax
movl 0x3b4(%rsp), %r10d
movq (%rax,%r10,8), %rax
movl 0x3b0(%rsp), %r10d
imulq $0x50, %r10, %r10
addq %r10, %rax
movq 0x20(%rax), %r10
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r11d
imulq $0x380, %r11, %r11      # imm = 0x380
addq %r11, %rax
movzbl 0x32f(%rax), %eax
xorl %r11d, %r11d
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x22750
jmp 0x4587
movq 0x20(%rsp), %rdi
movl 0x3bc(%rsp), %esi
movl 0x3b4(%rsp), %edx
movl 0x3b0(%rsp), %ecx
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r8d
imulq $0x380, %r8, %r8        # imm = 0x380
addq %r8, %rax
movq 0x348(%rax), %r8
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r9d
imulq $0x380, %r9, %r9        # imm = 0x380
addq %r9, %rax
movq 0x370(%rax), %r9
movq 0x7390(%rdi), %rax
movl 0x3b4(%rsp), %r10d
movq (%rax,%r10,8), %rax
movl 0x3b0(%rsp), %r10d
imulq $0x50, %r10, %r10
addq %r10, %rax
movq 0x20(%rax), %r10
movq 0xca20(%rdi), %rax
movl 0x3b8(%rsp), %r11d
imulq $0x380, %r11, %r11      # imm = 0x380
addq %r11, %rax
movzbl 0x32f(%rax), %eax
xorl %r11d, %r11d
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x22510
movq 0x20(%rsp), %rdi
movq %rdi, %rax
addq $0x10328, %rax          # imm = 0x10328
movl 0x3bc(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0xca20(%rdi), %rcx
movl 0x3b8(%rsp), %edx
imulq $0x380, %rdx, %rdx      # imm = 0x380
addq %rdx, %rcx
movzbl 0x32f(%rcx), %ecx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq %rdi, %rax
addq $0x102e8, %rax          # imm = 0x102E8
movl 0x3bc(%rsp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0xca20(%rdi), %rcx
movl 0x3b8(%rsp), %edx
imulq $0x380, %rdx, %rdx      # imm = 0x380
addq %rdx, %rcx
movzbl 0x32f(%rcx), %ecx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x3b4(%rsp), %esi
movl 0x3b0(%rsp), %edx
movq 0xca20(%rdi), %rcx
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rcx
callq 0x4b00
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x4, %eax
jne 0x46a0
movq 0x20(%rsp), %rax
movq 0xca20(%rax), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movzbl 0x32f(%rax), %eax
cmpl $0x1, %eax
jne 0x469e
movq 0x20(%rsp), %rax
movq 0x7390(%rax), %rax
movl 0x3b4(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x3b0(%rsp), %ecx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x1, 0x2(%rax)
jmp 0x46a0
movq 0x20(%rsp), %rcx
movq 0xca20(%rcx), %rax
movl 0x3b8(%rsp), %edx
imulq $0x380, %rdx, %rdx      # imm = 0x380
addq %rdx, %rax
movl 0x8(%rax), %eax
cmpl 0x7398(%rcx), %eax
jge 0x4750
movq 0x20(%rsp), %rax
movq 0xca20(%rax), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
cmpb $0x0, (%rax)
je 0x471f
movq 0x20(%rsp), %rax
movl 0x3bc(%rsp), %ecx
movq 0x8(%rax,%rcx,8), %rdi
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x474e
movq 0x20(%rsp), %rax
movl 0x3bc(%rsp), %ecx
movq 0x10(%rax,%rcx,8), %rdi
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
movq (%rdi), %rax
callq *0x18(%rax)
jmp 0x4750
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x0, %eax
jne 0x47ec
movq 0x20(%rsp), %rcx
movq 0x7390(%rcx), %rax
movl 0x3b4(%rsp), %edx
movq (%rax,%rdx,8), %rax
movl 0x3b0(%rsp), %edx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movq 0x30(%rax), %rdx
movq 0xca20(%rcx), %rax
movl 0x3b8(%rsp), %esi
imulq $0x380, %rsi, %rsi      # imm = 0x380
addq %rsi, %rax
movq %rdx, 0x350(%rax)
movl 0xe65c(%rcx), %eax
cmpl 0xe648(%rcx), %eax
jae 0x47e7
movq 0x20(%rsp), %rax
movq %rax, %rdi
addq $0xe628, %rdi           # imm = 0xE628
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
callq 0x15040
jmp 0x495b
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x1, %eax
jne 0x4888
movq 0x20(%rsp), %rcx
movq 0x7390(%rcx), %rax
movl 0x3b4(%rsp), %edx
movq (%rax,%rdx,8), %rax
movl 0x3b0(%rsp), %edx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movq 0x30(%rax), %rdx
movq 0xca20(%rcx), %rax
movl 0x3b8(%rsp), %esi
imulq $0x380, %rsi, %rsi      # imm = 0x380
addq %rsi, %rax
movq %rdx, 0x358(%rax)
movl 0xe65c(%rcx), %eax
cmpl 0xe648(%rcx), %eax
jae 0x4883
movq 0x20(%rsp), %rax
movq %rax, %rdi
addq $0xe628, %rdi           # imm = 0xE628
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
callq 0x15040
jmp 0x4959
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x3, %eax
jne 0x48da
movq 0x20(%rsp), %rcx
movl 0xe65c(%rcx), %eax
cmpl 0xe648(%rcx), %eax
jae 0x48d8
movq 0x20(%rsp), %rax
movq %rax, %rdi
addq $0xe628, %rdi           # imm = 0xE628
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
callq 0x15040
jmp 0x4957
movq 0x20(%rsp), %rax
movzbl 0x73a4(%rax), %eax
cmpl $0x4, %eax
jne 0x4955
movq 0x20(%rsp), %rax
movq 0xca20(%rax), %rax
movl 0x3b8(%rsp), %ecx
imulq $0x380, %rcx, %rcx      # imm = 0x380
addq %rcx, %rax
movzbl 0x32f(%rax), %eax
cmpl $0x2, %eax
je 0x4955
movq 0x20(%rsp), %rcx
movl 0xe65c(%rcx), %eax
cmpl 0xe648(%rcx), %eax
jae 0x4953
movq 0x20(%rsp), %rax
movq %rax, %rdi
addq $0xe628, %rdi           # imm = 0xE628
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
callq 0x15040
jmp 0x4955
jmp 0x4957
jmp 0x4959
jmp 0x495b
movq 0x20(%rsp), %rax
movq %rax, %rdi
addq $0xc988, %rdi           # imm = 0xC988
movq 0xca20(%rax), %rsi
movl 0x3b8(%rsp), %eax
imulq $0x380, %rax, %rax      # imm = 0x380
addq %rax, %rsi
callq 0x150e0
movq 0x20(%rsp), %rdi
movl 0xc9c0(%rdi), %eax
addl $-0x1, %eax
movl %eax, 0xc9c0(%rdi)
callq 0x4a00
jmp 0x49a2
addq $0x3c8, %rsp            # imm = 0x3C8
retq
nopw (%rax,%rax)