// File: ASG-ICT[P]SPEC2017-Trace/trace.cpp
// Function: next_translate()
int next_translate()
{
    unsigned int pid;
    unsigned long ppn;
    unsigned long vpn;
    uint64_t val;
    char magic;


    while (1) {
        if (next_record(tracefp) != 0) {
            return 0;
        }
        total_trace += 1;
        trace_id ++;
        uint64_t addr = record.paddr;
        if(addr == malloc_tag_addr + 64){
//             printf("***************** trace_id = %lld seq_no = %d ,r_w = %d, paddr = %lx,  last_seq_no = %d \n",trace_id, seq_no, r_w, paddr, last_seq);
             topmc_tag ++;
        }



        if (is_kernel_tag_trace(addr) && tag_end == 0) {
            tag_cnt += 1;
            // is sync tag
            int kernel_trace_seq = (addr - kernel_config_entry) / (KERNEL_TRACE_CONFIG_SIZE << 20);
            if (kernel_trace_seq >= KERNEL_TRACE_SEQ_NUM) {
                fprintf(stderr, "#### Invalid kernel trace seq:addr=0x%llx, seq=%d\n", addr, kernel_trace_seq);
                exit(-1);
            }

            unsigned long long kernel_trace_seq_entry =
                    addr - kernel_config_entry - kernel_trace_seq * (KERNEL_TRACE_CONFIG_SIZE << 20);

            int kernel_trace_tag = (kernel_trace_seq_entry) / TAG_ACCESS_SIZE;
            if (kernel_trace_tag >= TAG_MAX_POS) {
                fprintf(stderr, "#### Invalid kernel_trace_tag:addr=0x%llx,tag=%d\n", addr, kernel_trace_tag);
                exit(-1);
            }
            int hmtt_kt_type = ((kernel_trace_seq_entry) % TAG_ACCESS_SIZE) / TAG_ACCESS_STEP;
            if (hmtt_kt_type > 1) {
                fprintf(stderr, "#### Invalid hmtt_kt_type:addr=0x%llx,tag=%d,type=%d\n", addr, kernel_trace_tag,
                        hmtt_kt_type);
                exit(-1);
            } else if (hmtt_kt_type == 1)
                continue;

            if (tagp + 13 >= tag_size) {
		printf("trace_id= %llu  tagp = %lu ,in tagp error\n",trace_id, tagp);
//		trace_finish();
//		return 1;		
                error("tag pos");
            }



	    if(show_sync_tag_num > 0){
                                printf("real_trace_id = %lld  ,r_w = %d, paddr = %lx,  sync_tag_num = %d \n",trace_id,  record.rw, record.paddr, tag_cnt);
                                show_sync_tag_num --;
                        }
	    if(kernel_trace_tag == FREE_PTE_TAG)
		free_pte_num ++;;
	    
//	    getchar();
//	    printf("tagp =%llu, has_read = %llu \n", tagp,has_read);
//	    char ttt_ch = (*(char*)(kt_ch));
  ///          printf("magic in KT, %x in KT\n", ttt_ch);
//	    getchar();

            switch (kernel_trace_tag) {
                case SET_PTE_TAG:
                    set_pte_cnt += 1;
		    magic =  (*(char*)(kt_ch));
		    if(magic ==  '$' ){
			miss_set_pte ++;
			break;
		    }



		    if(magic != set_page_table_magic){

			printf("set_pte in hmmt, %x in KT\n",magic);
			printf("tagp =%llu, has_read = %llu \n", tagp,has_read);
			error("bug\n");
			if(magic == free_page_table_magic || magic == free_page_table_get_clear || magic == free_page_table_get_clear_full){
//				printf("set_pte_cnt = %llu, free_pte_cnt = %llu \n", set_pte_cnt ,free_pte_cnt);
				read_len = read_kt();	
				tagp +=13;
				break;
			}
//			printf("set_pte miss match!\n");
			break;
//			while(magic == free_pt_addr_magic)	
//			{
//				printf("SET_PTE in HMTT meet free_pt_addr_magic in KT");
//				tagp += 13;
//				magic = (*(char*)(&(tag[tagp])));  //skip 
//				trace_finish();
//				error("set_page_table offset of hmtt & KT not equal");
//			}
		    }
                    tagp += 1;
		    pid = (*(int*)((kt_ch + 1)));
                    tagp += 4;
		    val = (*(uint64_t*)(kt_ch + 5));
                    ppn = val & 0xffffff;
                    vpn = (val >> 24) & 0xffffffffff;
                    tagp += 8;

		    read_len = read_kt(); 

                    if (ppn >= MAXPPN) {
                        error("invalid ppn");
                    }
                    ppn2pid[ppn] = pid;
                    ppn2vpn[ppn] = vpn;
                    vpn2ppn[vpn] = ppn;
                    if (vpn2ppn[vpn-1] > 0) {
                        unsigned long last_ppn = vpn2ppn[vpn - 1];
                        if (last_ppn != ppn - 1) {
                            next_page_map[last_ppn] = ppn;
                        }
                    }
                    else if (vpn2ppn[vpn - 2] > 0) {
                        unsigned long last_ppn = vpn2ppn[vpn - 2];
                        if (last_ppn != ppn - 2) {
                            next_page_map[last_ppn] = ppn;
                        }
                    }
                    alloc_stamp[ppn] = total_trace;
                    break;

                case FREE_PTE_TAG:
		    magic =  (*(char*)(kt_ch));
		    if(magic ==  '$' ){
                        miss_free_pte ++;
                        break;
                    }

		    if(magic != free_page_table_magic && magic != free_page_table_get_clear && magic != free_page_table_get_clear_full){
//			printf("miss match free tag in KT \n");
//		        printf("free_pte in hmmt, %x in KT\n",magic);
			skip_free_pte ++;
			miss_free_pte = miss_free_pte + 1;
			break;
		    }
                    free_pte_cnt += 1;
		    pid = (*(int*)((kt_ch + 1)));
        	    val = (*(uint64_t*)(kt_ch + 5));
                    ppn = val & 0xffffff;
                    vpn = (val >> 24) & 0xffffffffff;
                    tagp += 13;
		    read_len = read_kt();
                    if (ppn >= MAXPPN) {
                        error("invalid ppn");
                    }
                    ppn2pid[ppn] = 0;
                    ppn2vpn[ppn] = 0;
                    break;


                case DUMP_PAGE_TABLE_TAG:
                    break;
                case KERNEL_TRACE_END_TAG:
                    if (strncmp(kt_ch, "$$$$$$$$$$$$$", 13) == 0) {
			fread(kt_ch, 1, 3, ktfp);
			has_read += 3;
            		int tmp_l = read_kt();
                        printf("kernel trace end.\n");
                    } else {
                        printf("error: kernel trace end\n");
                    }
                    tag_end = 1;
                    break;
                default:;
                    fprintf(stdout, "UnIdentifitable kernel trace tag:addr=0x%llx, tag=%d, type=%d\n",
                            addr,
                            kernel_trace_tag,
                            hmtt_kt_type);
            }
        }
	else if(addr == malloc_tag_addr + 64){
		;
	}
	else {
            // normal trace
            uint64_t ppn = record.paddr >> 12;
	    uint64_t pmd_ppn =(ppn >> 8);
	     if (ppn2vpn[ppn] == 0 && ppn2pid[ppn] == 0) {
                nonpte += 1;
                record.pid = -1;
                record.vaddr = 0;
            } else {
#ifndef VADDR
		if(find_index( ppn2pid[ppn] ) == -1 )
		{
			pidindex[ pid_len] = ppn2pid[ppn];
			pid_len ++;
		}
		pid_trace_num[ find_index( ppn2pid[ppn] ) ][0] ++;
#endif
                record.pid = ppn2pid[ppn];
                record.vaddr = (ppn2vpn[ppn] << 12) | (record.paddr & 0xfff);
            }
            //fwrite(&record, sizeof(record_t), 1, ofp);
            return 1;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0xeeee26(%rip), %rdi    # 0xef07c8
callq 0x17a0
cmpl $0x0, %eax
je 0x19b8
movl $0x0, -0x4(%rbp)
jmp 0x2139
movq 0xeeee31(%rip), %rax    # 0xef07f0
addq $0x1, %rax
movq %rax, 0xeeee26(%rip)    # 0xef07f0
movq 0x6777(%rip), %rax      # 0x8148
addq $0x1, %rax
movq %rax, 0x676c(%rip)      # 0x8148
movq 0x677d(%rip), %rax      # 0x8160
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x6716(%rip), %rcx      # 0x8108
addq $0x40, %rcx
cmpq %rcx, %rax
jne 0x1a0a
movl 0xeeee6f(%rip), %eax    # 0xef0870
addl $0x1, %eax
movl %eax, 0xeeee66(%rip)    # 0xef0870
movq -0x30(%rbp), %rdi
callq 0x1950
cmpl $0x0, %eax
je 0x2055
cmpl $0x0, 0xeeeddd(%rip)    # 0xef0800
jne 0x2055
movq 0xeeedd8(%rip), %rax    # 0xef0808
addq $0x1, %rax
movq %rax, 0xeeedcd(%rip)    # 0xef0808
movq -0x30(%rbp), %rax
subq 0x66ba(%rip), %rax      # 0x8100
shrq $0x14, %rax
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rax
cmpq $0x40, %rax
jb 0x1a80
movq 0x657a(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
movl -0x34(%rbp), %ecx
leaq 0x36f2(%rip), %rsi      # 0x5161
movb $0x0, %al
callq 0x1170
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1160
movq -0x30(%rbp), %rax
subq 0x6675(%rip), %rax      # 0x8100
movslq -0x34(%rbp), %rcx
shlq $0x14, %rcx
subq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
shrq $0xc, %rax
movl %eax, -0x44(%rbp)
cmpl $0x100, -0x44(%rbp)     # imm = 0x100
jb 0x1ad7
movq 0x6523(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
movl -0x44(%rbp), %ecx
leaq 0x36ce(%rip), %rsi      # 0x5194
movb $0x0, %al
callq 0x1170
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1160
movq -0x40(%rbp), %rax
andq $0xfff, %rax            # imm = 0xFFF
shrq $0xb, %rax
movl %eax, -0x48(%rbp)
cmpl $0x1, -0x48(%rbp)
jle 0x1b1b
movq 0x64e3(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
movl -0x44(%rbp), %ecx
movl -0x48(%rbp), %r8d
leaq 0x36bc(%rip), %rsi      # 0x51c6
movb $0x0, %al
callq 0x1170
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1160
cmpl $0x1, -0x48(%rbp)
jne 0x1b26
jmp 0x199b
jmp 0x1b28
movl 0xeeec42(%rip), %eax    # 0xef0770
addl $0xd, %eax
movl %eax, %eax
cmpq 0xeeec3e(%rip), %rax    # 0xef0778
jb 0x1b63
movq 0x6605(%rip), %rsi      # 0x8148
movl 0xeeec27(%rip), %edx    # 0xef0770
leaq 0x36ac(%rip), %rdi      # 0x51fc
movb $0x0, %al
callq 0x1050
leaq 0x36c9(%rip), %rdi      # 0x5227
callq 0x1760
cmpl $0x0, 0xeeec56(%rip)    # 0xef07c0
jle 0x1ba4
movq 0x65d5(%rip), %rsi      # 0x8148
movl 0x65d7(%rip), %edx      # 0x8150
movq 0x65e0(%rip), %rcx      # 0x8160
movq 0xeeec81(%rip), %r8     # 0xef0808
leaq 0x36a1(%rip), %rdi      # 0x522f
movb $0x0, %al
callq 0x1050
movl 0xeeec25(%rip), %eax    # 0xef07c0
addl $-0x1, %eax
movl %eax, 0xeeec1c(%rip)    # 0xef07c0
cmpl $0x1, -0x44(%rbp)
jne 0x1bbc
movq 0xeeebd7(%rip), %rax    # 0xef0788
addq $0x1, %rax
movq %rax, 0xeeebcc(%rip)    # 0xef0788
movl -0x44(%rbp), %eax
movq %rax, -0x98(%rbp)
subq $0x3, %rax
ja 0x202d
movq -0x98(%rbp), %rax
leaq 0x3546(%rip), %rcx      # 0x5124
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0xeeeba2(%rip), %rax    # 0xef0790
addq $0x1, %rax
movq %rax, 0xeeeb97(%rip)    # 0xef0790
movb 0xeeea91(%rip), %al     # 0xef0690
movb %al, -0x21(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x24, %eax
jne 0x1c22
movq 0xeeec7e(%rip), %rax    # 0xef0890
addq $0x1, %rax
movq %rax, 0xeeec73(%rip)    # 0xef0890
jmp 0x2050
movsbl -0x21(%rbp), %eax
movsbl 0x64ed(%rip), %ecx      # 0x811a
cmpl %ecx, %eax
je 0x1cbf
movsbl -0x21(%rbp), %esi
leaq 0x3632(%rip), %rdi      # 0x5272
movb $0x0, %al
callq 0x1050
movl 0xeeeb23(%rip), %esi    # 0xef0770
movq 0xeeea2c(%rip), %rdx    # 0xef0680
leaq 0x3632(%rip), %rdi      # 0x528d
movb $0x0, %al
callq 0x1050
leaq 0x3642(%rip), %rdi      # 0x52ab
callq 0x1760
movsbl -0x21(%rbp), %eax
movsbl 0x64a2(%rip), %ecx      # 0x811b
cmpl %ecx, %eax
je 0x1c9b
movsbl -0x21(%rbp), %eax
movsbl 0x6494(%rip), %ecx      # 0x811c
cmpl %ecx, %eax
je 0x1c9b
movsbl -0x21(%rbp), %eax
movsbl 0x6486(%rip), %ecx      # 0x811d
cmpl %ecx, %eax
jne 0x1cba
callq 0x1720
movl %eax, 0xeeeab2(%rip)    # 0xef0758
movl 0xeeeac4(%rip), %eax    # 0xef0770
addl $0xd, %eax
movl %eax, 0xeeeabb(%rip)    # 0xef0770
jmp 0x2050
jmp 0x2050
movl 0xeeeaab(%rip), %eax    # 0xef0770
addl $0x1, %eax
movl %eax, 0xeeeaa2(%rip)    # 0xef0770
movl 0xeee9bd(%rip), %eax    # 0xef0691
movl %eax, -0x8(%rbp)
movl 0xeeea93(%rip), %eax    # 0xef0770
addl $0x4, %eax
movl %eax, 0xeeea8a(%rip)    # 0xef0770
movq 0xeee9a8(%rip), %rax    # 0xef0695
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
andq $0xffffff, %rax         # imm = 0xFFFFFF
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
shrq $0x18, %rax
movabsq $0xffffffffff, %rcx     # imm = 0xFFFFFFFFFF
andq %rcx, %rax
movq %rax, -0x18(%rbp)
movl 0xeeea52(%rip), %eax    # 0xef0770
addl $0x8, %eax
movl %eax, 0xeeea49(%rip)    # 0xef0770
callq 0x1720
movl %eax, 0xeeea26(%rip)    # 0xef0758
cmpq $0x1000000, -0x10(%rbp) # imm = 0x1000000
jb 0x1d48
leaq 0x356d(%rip), %rdi      # 0x52b0
callq 0x1760
movl -0x8(%rbp), %edx
movq 0xeeea86(%rip), %rax    # 0xef07d8
movq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rdx
movq 0xeeea6c(%rip), %rax    # 0xef07d0
movq -0x10(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq 0xeeeaaa(%rip), %rdi    # 0xef0828
leaq -0x18(%rbp), %rsi
callq 0x2c30
movq -0xa0(%rbp), %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
leaq 0xeeea84(%rip), %rdi    # 0xef0828
leaq -0x50(%rbp), %rsi
callq 0x2d10
cmpq $0x0, (%rax)
jbe 0x1dfc
movq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x60(%rbp)
leaq 0xeeea62(%rip), %rdi    # 0xef0828
leaq -0x60(%rbp), %rsi
callq 0x2d10
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x1dfa
movq -0x10(%rbp), %rdx
movq 0xeeea1e(%rip), %rax    # 0xef0810
movq -0x58(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1e69
movq -0x18(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x68(%rbp)
leaq 0xeeea19(%rip), %rdi    # 0xef0828
leaq -0x68(%rbp), %rsi
callq 0x2d10
cmpq $0x0, (%rax)
jbe 0x1e67
movq -0x18(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x78(%rbp)
leaq 0xeee9f7(%rip), %rdi    # 0xef0828
leaq -0x78(%rbp), %rsi
callq 0x2d10
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
je 0x1e65
movq -0x10(%rbp), %rdx
movq 0xeee9b3(%rip), %rax    # 0xef0810
movq -0x70(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1e67
jmp 0x1e69
movq 0xeee980(%rip), %rdx    # 0xef07f0
movq 0xeee9a9(%rip), %rax    # 0xef0820
movq -0x10(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x2050
movb 0xeee806(%rip), %al     # 0xef0690
movb %al, -0x21(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x24, %eax
jne 0x1ead
movq 0xeee9eb(%rip), %rax    # 0xef0888
addq $0x1, %rax
movq %rax, 0xeee9e0(%rip)    # 0xef0888
jmp 0x2050
movsbl -0x21(%rbp), %eax
movsbl 0x6263(%rip), %ecx      # 0x811b
cmpl %ecx, %eax
je 0x1f03
movsbl -0x21(%rbp), %eax
movsbl 0x6255(%rip), %ecx      # 0x811c
cmpl %ecx, %eax
je 0x1f03
movsbl -0x21(%rbp), %eax
movsbl 0x6247(%rip), %ecx      # 0x811d
cmpl %ecx, %eax
je 0x1f03
movq 0xeee977(%rip), %rax    # 0xef0858
addq $0x1, %rax
movq %rax, 0xeee96c(%rip)    # 0xef0858
movq 0xeee995(%rip), %rax    # 0xef0888
addq $0x1, %rax
movq %rax, 0xeee98a(%rip)    # 0xef0888
jmp 0x2050
movq 0xeee88e(%rip), %rax    # 0xef0798
addq $0x1, %rax
movq %rax, 0xeee883(%rip)    # 0xef0798
movl 0xeee776(%rip), %eax    # 0xef0691
movl %eax, -0x8(%rbp)
movq 0xeee770(%rip), %rax    # 0xef0695
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
andq $0xffffff, %rax         # imm = 0xFFFFFF
movq %rax, -0x10(%rbp)
movq -0x20(%rbp), %rax
shrq $0x18, %rax
movabsq $0xffffffffff, %rcx     # imm = 0xFFFFFFFFFF
andq %rcx, %rax
movq %rax, -0x18(%rbp)
movl 0xeee81a(%rip), %eax    # 0xef0770
addl $0xd, %eax
movl %eax, 0xeee811(%rip)    # 0xef0770
callq 0x1720
movl %eax, 0xeee7ee(%rip)    # 0xef0758
cmpq $0x1000000, -0x10(%rbp) # imm = 0x1000000
jb 0x1f80
leaq 0x3335(%rip), %rdi      # 0x52b0
callq 0x1760
movq 0xeee851(%rip), %rax    # 0xef07d8
movq -0x10(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq 0xeee837(%rip), %rax    # 0xef07d0
movq -0x10(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x2050
jmp 0x2050
leaq 0xeee6da(%rip), %rdi    # 0xef0690
leaq 0x32ff(%rip), %rsi      # 0x52bc
movl $0xd, %edx
callq 0x10a0
cmpl $0x0, %eax
jne 0x2013
movq 0xeee78d(%rip), %rcx    # 0xef0760
leaq 0xeee6b6(%rip), %rdi    # 0xef0690
movl $0x1, %esi
movl $0x3, %edx
callq 0x1190
movq 0xeee690(%rip), %rax    # 0xef0680
addq $0x3, %rax
movq %rax, 0xeee685(%rip)    # 0xef0680
callq 0x1720
movl %eax, -0x7c(%rbp)
leaq 0x32c0(%rip), %rdi      # 0x52ca
movb $0x0, %al
callq 0x1050
jmp 0x2021
leaq 0x32c3(%rip), %rdi      # 0x52dd
movb $0x0, %al
callq 0x1050
movl $0x1, 0xeee7d5(%rip)    # 0xef0800
jmp 0x2050
movq 0x5f8c(%rip), %rax      # 0x7fc0
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
movl -0x44(%rbp), %ecx
movl -0x48(%rbp), %r8d
leaq 0x32ad(%rip), %rsi      # 0x52f6
movb $0x0, %al
callq 0x1170
jmp 0x2134
movq -0x30(%rbp), %rax
movq 0x60a8(%rip), %rcx      # 0x8108
addq $0x40, %rcx
cmpq %rcx, %rax
jne 0x206e
jmp 0x2132
movq 0x60eb(%rip), %rax      # 0x8160
shrq $0xc, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
shrq $0x8, %rax
movq %rax, -0x90(%rbp)
movq 0xeee737(%rip), %rax    # 0xef07d0
movq -0x88(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x20e4
movq 0xeee72a(%rip), %rax    # 0xef07d8
movq -0x88(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x20e4
movq 0xeee736(%rip), %rax    # 0xef07f8
addq $0x1, %rax
movq %rax, 0xeee72b(%rip)    # 0xef07f8
movl $0xffffffff, 0x607d(%rip) # imm = 0xFFFFFFFF
movq $0x0, 0x6086(%rip) # 0x8168
jmp 0x2129
movq 0xeee6ed(%rip), %rax    # 0xef07d8
movq -0x88(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x6059(%rip)      # 0x8154
movq 0xeee6ce(%rip), %rax    # 0xef07d0
movq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shlq $0xc, %rax
movq 0x6048(%rip), %rcx      # 0x8160
andq $0xfff, %rcx            # imm = 0xFFF
orq %rcx, %rax
movq %rax, 0x603f(%rip)      # 0x8168
movl $0x1, -0x4(%rbp)
jmp 0x2139
jmp 0x2134
jmp 0x199b
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)