// File: NishadSaraf[P]Championship-Simulator/src/main.cc
// Function: va_to_pa(unsigned int, unsigned long, unsigned long, unsigned long)
uint64_t va_to_pa(uint32_t cpu, uint64_t instr_id, uint64_t va, uint64_t unique_vpage)
{
#ifdef SANITY_CHECK
    if (va == 0) 
        assert(0);
#endif

    uint8_t  swap = 0;
    uint64_t high_bit_mask = rotr64(cpu, lg2(NUM_CPUS)),
             unique_va = va | high_bit_mask;
    //uint64_t vpage = unique_va >> PAGE_SHIFT,
    uint64_t vpage = unique_vpage | high_bit_mask,
             voffset = unique_va & ((1<<PAGE_SHIFT) - 1);

    // smart random number generator
    uint64_t random_ppage;

    map <uint64_t, uint64_t>::iterator pr = page_table.begin();
    map <uint64_t, uint64_t>::iterator ppage_check = inverse_table.begin();

    // check unique cache line footprint
    map <uint64_t, uint64_t>::iterator cl_check = unique_cl[cpu].find(unique_va >> LOG2_BLOCK_SIZE);
    if (cl_check == unique_cl[cpu].end()) { // we've never seen this cache line before
        unique_cl[cpu].insert(make_pair(unique_va >> LOG2_BLOCK_SIZE, 0));
        num_cl[cpu]++;
    }
    else
        cl_check->second++;

    pr = page_table.find(vpage);
    if (pr == page_table.end()) { // no VA => PA translation found 

        if (allocated_pages >= DRAM_PAGES) { // not enough memory

            // TODO: elaborate page replacement algorithm
            // here, ChampSim randomly selects a page that is not recently used and we only track 32K recently accessed pages
            uint8_t  found_NRU = 0;
            uint64_t NRU_vpage = 0; // implement it
            map <uint64_t, uint64_t>::iterator pr2 = recent_page.begin();
            for (pr = page_table.begin(); pr != page_table.end(); pr++) {

                NRU_vpage = pr->first;
                if (recent_page.find(NRU_vpage) == recent_page.end()) {
                    found_NRU = 1;
                    break;
                }
            }
#ifdef SANITY_CHECK
            if (found_NRU == 0)
                assert(0);

            if (pr == page_table.end())
                assert(0);
#endif
            DP ( if (warmup_complete[cpu]) {
            cout << "[SWAP] update page table NRU_vpage: " << hex << pr->first << " new_vpage: " << vpage << " ppage: " << pr->second << dec << endl; });

            // update page table with new VA => PA mapping
            // since we cannot change the key value already inserted in a map structure, we need to erase the old node and add a new node
            uint64_t mapped_ppage = pr->second;
            page_table.erase(pr);
            page_table.insert(make_pair(vpage, mapped_ppage));

            // update inverse table with new PA => VA mapping
            ppage_check = inverse_table.find(mapped_ppage);
#ifdef SANITY_CHECK
            if (ppage_check == inverse_table.end())
                assert(0);
#endif
            ppage_check->second = vpage;

            DP ( if (warmup_complete[cpu]) {
            cout << "[SWAP] update inverse table NRU_vpage: " << hex << NRU_vpage << " new_vpage: ";
            cout << ppage_check->second << " ppage: " << ppage_check->first << dec << endl; });

            // update page_queue
            page_queue.pop();
            page_queue.push(vpage);

            // invalidate corresponding vpage and ppage from the cache hierarchy
            ooo_cpu[cpu].ITLB.invalidate_entry(NRU_vpage);
            ooo_cpu[cpu].DTLB.invalidate_entry(NRU_vpage);
            ooo_cpu[cpu].STLB.invalidate_entry(NRU_vpage);
            for (uint32_t i=0; i<BLOCK_SIZE; i++) {
                uint64_t cl_addr = (mapped_ppage << 6) | i;
                ooo_cpu[cpu].L1I.invalidate_entry(cl_addr);
                ooo_cpu[cpu].L1D.invalidate_entry(cl_addr);
                ooo_cpu[cpu].L2C.invalidate_entry(cl_addr);
                uncore.LLC.invalidate_entry(cl_addr);
            }

            // swap complete
            swap = 1;
        } else {
            uint8_t fragmented = 0;
            if (num_adjacent_page > 0)
                random_ppage = ++previous_ppage;
            else {
                random_ppage = champsim_rand.draw_rand();
                fragmented = 1;
            }

            // encoding cpu number 
            // this allows ChampSim to run homogeneous multi-programmed workloads without VA => PA aliasing
            // (e.g., cpu0: astar  cpu1: astar  cpu2: astar  cpu3: astar...)
            //random_ppage &= (~((NUM_CPUS-1)<< (32-PAGE_SHIFT)));
            //random_ppage |= (cpu<<(32-PAGE_SHIFT)); 

            while (1) { // try to find an empty physical page number
                ppage_check = inverse_table.find(random_ppage); // check if this page can be allocated 
                if (ppage_check != inverse_table.end()) { // random_ppage is not available
                    DP ( if (warmup_complete[cpu]) {
                    cout << "vpage: " << hex << ppage_check->first << " is already mapped to ppage: " << random_ppage << dec << endl; }); 
                    
                    if (num_adjacent_page > 0)
                        fragmented = 1;

                    // try one more time
                    random_ppage = champsim_rand.draw_rand();
                    
                    // encoding cpu number 
                    //random_ppage &= (~((NUM_CPUS-1)<<(32-PAGE_SHIFT)));
                    //random_ppage |= (cpu<<(32-PAGE_SHIFT)); 
                }
                else
                    break;
            }

            // insert translation to page tables
            //printf("Insert  num_adjacent_page: %u  vpage: %lx  ppage: %lx\n", num_adjacent_page, vpage, random_ppage);
            page_table.insert(make_pair(vpage, random_ppage));
            inverse_table.insert(make_pair(random_ppage, vpage));
            page_queue.push(vpage);
            previous_ppage = random_ppage;
            num_adjacent_page--;
            num_page[cpu]++;
            allocated_pages++;

            // try to allocate pages contiguously
            if (fragmented) {
                num_adjacent_page = 1 << (rand() % 10);
                DP ( if (warmup_complete[cpu]) {
                cout << "Recalculate num_adjacent_page: " << num_adjacent_page << endl; });
            }
        }

        if (swap)
            major_fault[cpu]++;
        else
            minor_fault[cpu]++;
    }
    else {
        //printf("Found  vpage: %lx  random_ppage: %lx\n", vpage, pr->second);
    }

    pr = page_table.find(vpage);
#ifdef SANITY_CHECK
    if (pr == page_table.end())
        assert(0);
#endif
    uint64_t ppage = pr->second;

    uint64_t pa = ppage << PAGE_SHIFT;
    pa |= voffset;

    DP ( if (warmup_complete[cpu]) {
    cout << "[PAGE_TABLE] instr_id: " << instr_id << " vpage: " << hex << vpage;
    cout << " => ppage: " << (pa >> PAGE_SHIFT) << " vadress: " << unique_va << " paddress: " << pa << dec << endl; });

    if (swap)
        stall_cycle[cpu] = current_core_cycle[cpu] + SWAP_LATENCY;
    else
        stall_cycle[cpu] = current_core_cycle[cpu] + PAGE_TABLE_LATENCY;

    //cout << "cpu: " << cpu << " allocated unique_vpage: " << hex << unique_vpage << " to ppage: " << ppage << dec << endl;

    return pa;
}

// Assembly:
subq $0x1f8, %rsp            # imm = 0x1F8
movl %edi, 0x1f4(%rsp)
movq %rsi, 0x1e8(%rsp)
movq %rdx, 0x1e0(%rsp)
movq %rcx, 0x1d8(%rsp)
cmpq $0x0, 0x1e0(%rsp)
jne 0xd280
leaq 0x15d9c(%rip), %rdi     # 0x23004
leaq 0x163f4(%rip), %rsi     # 0x23663
movl $0x153, %edx            # imm = 0x153
leaq 0x164ba(%rip), %rcx     # 0x23735
callq 0x3160
movb $0x0, 0x1d7(%rsp)
movl 0x1f4(%rsp), %eax
movq %rax, 0x10(%rsp)
movl $0x1, %edi
callq 0xd0c0
movq 0x10(%rsp), %rdi
movl %eax, %esi
callq 0xd1a0
movq %rax, 0x1c8(%rsp)
movq 0x1e0(%rsp), %rax
orq 0x1c8(%rsp), %rax
movq %rax, 0x1c0(%rsp)
movq 0x1d8(%rsp), %rax
orq 0x1c8(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movq 0x1c0(%rsp), %rax
andq $0xfff, %rax            # imm = 0xFFF
movq %rax, 0x1b0(%rsp)
leaq 0x1c0b1(%rip), %rdi     # 0x293b0
callq 0xfe90
movq %rax, 0x1a0(%rsp)
leaq 0x1c0cd(%rip), %rdi     # 0x293e0
callq 0xfe90
movq %rax, 0x198(%rsp)
movl 0x1f4(%rsp), %eax
leaq 0x1c112(%rip), %rdi     # 0x29440
imulq $0x30, %rax, %rax
addq %rax, %rdi
movq 0x1c0(%rsp), %rax
shrq $0x6, %rax
movq %rax, 0x188(%rsp)
leaq 0x188(%rsp), %rsi
callq 0xfec0
movq %rax, 0x190(%rsp)
movl 0x1f4(%rsp), %eax
leaq 0x1c0d4(%rip), %rdi     # 0x29440
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0xff10
movq %rax, 0x180(%rsp)
leaq 0x190(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0xfef0
testb $0x1, %al
jne 0xd39e
jmp 0xd463
movl 0x1f4(%rsp), %eax
leaq (%rax,%rax,2), %rcx
shlq $0x4, %rcx
leaq 0x1c08c(%rip), %rax     # 0x29440
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x1c0(%rsp), %rax
shrq $0x6, %rax
movq %rax, 0x168(%rsp)
movl $0x0, 0x164(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x164(%rsp), %rsi
callq 0xff90
movq 0x8(%rsp), %rdi
movl %edx, 0x158(%rsp)
movq %rax, 0x150(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x170(%rsp)
movl 0x158(%rsp), %eax
movl %eax, 0x178(%rsp)
leaq 0x170(%rsp), %rsi
callq 0xff40
movq %rax, 0x140(%rsp)
movb %dl, 0x148(%rsp)
movl 0x1f4(%rsp), %eax
movl %eax, %ecx
leaq 0x1c032(%rip), %rax     # 0x29480
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
leaq 0x1c023(%rip), %rax     # 0x29480
movq %rdx, (%rax,%rcx,8)
jmp 0xd47c
leaq 0x190(%rsp), %rdi
callq 0xffc0
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
leaq 0x1bf2d(%rip), %rdi     # 0x293b0
leaq 0x1b8(%rsp), %rsi
callq 0xfec0
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0x1a0(%rsp)
leaq 0x1bf01(%rip), %rdi     # 0x293b0
callq 0xff10
movq %rax, 0x130(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0xfef0
testb $0x1, %al
jne 0xd4da
jmp 0xdb57
cmpq $0x100000, 0x1bfa3(%rip) # imm = 0x100000
jb 0xd92c
movb $0x0, 0x12f(%rsp)
movq $0x0, 0x120(%rsp)
leaq 0x1bf0a(%rip), %rdi     # 0x29410
callq 0xfe90
movq %rax, 0x118(%rsp)
leaq 0x1be96(%rip), %rdi     # 0x293b0
callq 0xfe90
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x1a0(%rsp)
leaq 0x1be72(%rip), %rdi     # 0x293b0
callq 0xff10
movq %rax, 0x108(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0xffe0
testb $0x1, %al
jne 0xd569
jmp 0xd5f4
leaq 0x1a0(%rsp), %rdi
callq 0xffc0
movq (%rax), %rax
movq %rax, 0x120(%rsp)
leaq 0x1be88(%rip), %rdi     # 0x29410
leaq 0x120(%rsp), %rsi
callq 0xfec0
movq %rax, 0x100(%rsp)
leaq 0x1be6c(%rip), %rdi     # 0x29410
callq 0xff10
movq %rax, 0xf8(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xfef0
testb $0x1, %al
jne 0xd5cc
jmp 0xd5d6
movb $0x1, 0x12f(%rsp)
jmp 0xd5f4
jmp 0xd5d8
leaq 0x1a0(%rsp), %rdi
xorl %esi, %esi
callq 0x10000
movq %rax, 0xf0(%rsp)
jmp 0xd537
movzbl 0x12f(%rsp), %eax
cmpl $0x0, %eax
jne 0xd620
leaq 0x159fc(%rip), %rdi     # 0x23004
leaq 0x16054(%rip), %rsi     # 0x23663
movl $0x180, %edx            # imm = 0x180
leaq 0x1611a(%rip), %rcx     # 0x23735
callq 0x3160
leaq 0x1bd89(%rip), %rdi     # 0x293b0
callq 0xff10
movq %rax, 0xe8(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0xfef0
testb $0x1, %al
jne 0xd64f
jmp 0xd66e
leaq 0x159ae(%rip), %rdi     # 0x23004
leaq 0x16006(%rip), %rsi     # 0x23663
movl $0x183, %edx            # imm = 0x183
leaq 0x160cc(%rip), %rcx     # 0x23735
callq 0x3160
leaq 0x1a0(%rsp), %rdi
callq 0xffc0
movq 0x8(%rax), %rax
movq %rax, 0xe0(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rsi
leaq 0x1bd0a(%rip), %rdi     # 0x293b0
callq 0x10040
movq %rax, 0xd0(%rsp)
leaq 0x1b8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x100d0
movq %rax, 0xc0(%rsp)
movq %rdx, 0xc8(%rsp)
leaq 0x1bcd1(%rip), %rdi     # 0x293b0
leaq 0xc0(%rsp), %rsi
callq 0x10080
movq %rax, 0xb0(%rsp)
movb %dl, 0xb8(%rsp)
leaq 0x1bcde(%rip), %rdi     # 0x293e0
leaq 0xe0(%rsp), %rsi
callq 0xfec0
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x198(%rsp)
leaq 0x1bcb2(%rip), %rdi     # 0x293e0
callq 0xff10
movq %rax, 0xa0(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xfef0
testb $0x1, %al
jne 0xd756
jmp 0xd775
leaq 0x158a7(%rip), %rdi     # 0x23004
leaq 0x15eff(%rip), %rsi     # 0x23663
movl $0x192, %edx            # imm = 0x192
leaq 0x15fc5(%rip), %rcx     # 0x23735
callq 0x3160
movq 0x1b8(%rsp), %rax
movq %rax, (%rsp)
leaq 0x198(%rsp), %rdi
callq 0xffc0
movq (%rsp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x1bbc3(%rip), %rdi     # 0x29360
callq 0x10110
leaq 0x1bbb7(%rip), %rdi     # 0x29360
leaq 0x1b8(%rsp), %rsi
callq 0x10120
movl 0x1f4(%rsp), %eax
leaq 0x1da7c(%rip), %rdi     # 0x2b240
imulq $0x64c80, %rax, %rax    # imm = 0x64C80
addq %rax, %rdi
addq $0x3690, %rdi           # imm = 0x3690
movq 0x120(%rsp), %rsi
callq 0x8000
movl 0x1f4(%rsp), %eax
leaq 0x1da50(%rip), %rdi     # 0x2b240
imulq $0x64c80, %rax, %rax    # imm = 0x64C80
addq %rax, %rdi
addq $0x13a38, %rdi          # imm = 0x13A38
movq 0x120(%rsp), %rsi
callq 0x8000
movl 0x1f4(%rsp), %eax
leaq 0x1da24(%rip), %rdi     # 0x2b240
imulq $0x64c80, %rax, %rax    # imm = 0x64C80
addq %rax, %rdi
addq $0x23de0, %rdi          # imm = 0x23DE0
movq 0x120(%rsp), %rsi
callq 0x8000
movl $0x0, 0x9c(%rsp)
cmpl $0x40, 0x9c(%rsp)
jae 0xd91f
movq 0xe0(%rsp), %rax
shlq $0x6, %rax
movl 0x9c(%rsp), %ecx
orq %rcx, %rax
movq %rax, 0x90(%rsp)
movl 0x1f4(%rsp), %eax
leaq 0x1d9c1(%rip), %rdi     # 0x2b240
imulq $0x64c80, %rax, %rax    # imm = 0x64C80
addq %rax, %rdi
addq $0x34188, %rdi          # imm = 0x34188
movq 0x90(%rsp), %rsi
callq 0x8000
movl 0x1f4(%rsp), %eax
leaq 0x1d995(%rip), %rdi     # 0x2b240
imulq $0x64c80, %rax, %rax    # imm = 0x64C80
addq %rax, %rdi
addq $0x44530, %rdi          # imm = 0x44530
movq 0x90(%rsp), %rsi
callq 0x8000
movl 0x1f4(%rsp), %eax
leaq 0x1d969(%rip), %rdi     # 0x2b240
imulq $0x64c80, %rax, %rax    # imm = 0x64C80
addq %rax, %rdi
addq $0x548d8, %rdi          # imm = 0x548D8
movq 0x90(%rsp), %rsi
callq 0x8000
movq 0x90(%rsp), %rsi
leaq 0x825dc(%rip), %rdi     # 0x8fee0
callq 0x8000
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0xd845
movb $0x1, 0x1d7(%rsp)
jmp 0xdb03
movb $0x0, 0x8f(%rsp)
cmpq $0x0, 0x1bb3c(%rip)     # 0x29478
jbe 0xd95a
movq 0x1bb2b(%rip), %rax     # 0x29470
addq $0x1, %rax
movq %rax, 0x1bb20(%rip)     # 0x29470
movq %rax, 0x1a8(%rsp)
jmp 0xd976
leaq 0x1bb47(%rip), %rdi     # 0x294a8
callq 0x10150
movq %rax, 0x1a8(%rsp)
movb $0x1, 0x8f(%rsp)
jmp 0xd978
leaq 0x1ba61(%rip), %rdi     # 0x293e0
leaq 0x1a8(%rsp), %rsi
callq 0xfec0
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x198(%rsp)
leaq 0x1ba35(%rip), %rdi     # 0x293e0
callq 0xff10
movq %rax, 0x78(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xffe0
testb $0x1, %al
jne 0xd9cd
jmp 0xd9f5
cmpq $0x0, 0x1baa3(%rip)     # 0x29478
jbe 0xd9df
movb $0x1, 0x8f(%rsp)
leaq 0x1bac2(%rip), %rdi     # 0x294a8
callq 0x10150
movq %rax, 0x1a8(%rsp)
jmp 0xd9f7
jmp 0xd9fc
jmp 0xd978
leaq 0x1b8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x100d0
movq %rax, 0x68(%rsp)
movq %rdx, 0x70(%rsp)
leaq 0x1b98e(%rip), %rdi     # 0x293b0
leaq 0x68(%rsp), %rsi
callq 0x10080
movq %rax, 0x58(%rsp)
movb %dl, 0x60(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x100d0
movq %rax, 0x48(%rsp)
movq %rdx, 0x50(%rsp)
leaq 0x1b985(%rip), %rdi     # 0x293e0
leaq 0x48(%rsp), %rsi
callq 0x10080
movq %rax, 0x38(%rsp)
movb %dl, 0x40(%rsp)
leaq 0x1b8eb(%rip), %rdi     # 0x29360
leaq 0x1b8(%rsp), %rsi
callq 0x10120
movq 0x1a8(%rsp), %rax
movq %rax, 0x1b9df(%rip)     # 0x29470
movq 0x1b9e0(%rip), %rax     # 0x29478
addq $-0x1, %rax
movq %rax, 0x1b9d5(%rip)     # 0x29478
movl 0x1f4(%rsp), %eax
movl %eax, %ecx
leaq 0x1b9dd(%rip), %rax     # 0x29490
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
leaq 0x1b9ce(%rip), %rax     # 0x29490
movq %rdx, (%rax,%rcx,8)
movq 0x1b9bb(%rip), %rax     # 0x29488
addq $0x1, %rax
movq %rax, 0x1b9b0(%rip)     # 0x29488
cmpb $0x0, 0x8f(%rsp)
je 0xdb01
callq 0x3090
movl $0xa, %ecx
cltd
idivl %ecx
movl %edx, %ecx
movl $0x1, %eax
shll %cl, %eax
cltq
movq %rax, 0x1b977(%rip)     # 0x29478
jmp 0xdb03
cmpb $0x0, 0x1d7(%rsp)
je 0xdb32
movl 0x1f4(%rsp), %eax
movl %eax, %ecx
leaq 0x1b983(%rip), %rax     # 0x294a0
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
leaq 0x1b974(%rip), %rax     # 0x294a0
movq %rdx, (%rax,%rcx,8)
jmp 0xdb55
movl 0x1f4(%rsp), %eax
movl %eax, %ecx
leaq 0x1b956(%rip), %rax     # 0x29498
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
leaq 0x1b947(%rip), %rax     # 0x29498
movq %rdx, (%rax,%rcx,8)
jmp 0xdb59
jmp 0xdb59
leaq 0x1b850(%rip), %rdi     # 0x293b0
leaq 0x1b8(%rsp), %rsi
callq 0xfec0
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x1a0(%rsp)
leaq 0x1b82a(%rip), %rdi     # 0x293b0
callq 0xff10
movq %rax, 0x28(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xfef0
testb $0x1, %al
jne 0xdba8
jmp 0xdbc7
leaq 0x15455(%rip), %rdi     # 0x23004
leaq 0x15aad(%rip), %rsi     # 0x23663
movl $0x1ed, %edx            # imm = 0x1ED
leaq 0x15b73(%rip), %rcx     # 0x23735
callq 0x3160
leaq 0x1a0(%rsp), %rdi
callq 0xffc0
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
shlq $0xc, %rax
movq %rax, 0x18(%rsp)
movq 0x1b0(%rsp), %rax
orq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpb $0x0, 0x1d7(%rsp)
je 0xdc3a
movl 0x1f4(%rsp), %eax
movl %eax, %ecx
leaq 0x822a9(%rip), %rax     # 0x8fec0
movq (%rax,%rcx,8), %rdx
movl 0x1b73b(%rip), %eax     # 0x2935c
addq %rax, %rdx
movl 0x1f4(%rsp), %eax
movl %eax, %ecx
leaq 0x82294(%rip), %rax     # 0x8fec8
movq %rdx, (%rax,%rcx,8)
jmp 0xdc6b
movl 0x1f4(%rsp), %eax
movl %eax, %ecx
leaq 0x82276(%rip), %rax     # 0x8fec0
movq (%rax,%rcx,8), %rdx
movl 0x1b704(%rip), %eax     # 0x29358
addq %rax, %rdx
movl 0x1f4(%rsp), %eax
movl %eax, %ecx
leaq 0x82261(%rip), %rax     # 0x8fec8
movq %rdx, (%rax,%rcx,8)
movq 0x18(%rsp), %rax
addq $0x1f8, %rsp            # imm = 0x1F8
retq
nopl (%rax,%rax)