// File: /workspace/github_c_makefile_star2_O3/dwelch67[P]lc3/vsim.c
// Function: sim
int sim ( void )
{
    unsigned short inst;
    unsigned short test;
    unsigned short simm;
    unsigned short dest;
    unsigned short rd,rd_data;
    unsigned short sr1,sr1_data;
    unsigned short sr2,sr2_data;
    while(1)
    {
        printf("\n");
        inst=fetch_mem(pc);
        printf("---- 0x%04X: 0x%04X ",pc,inst);
        pc=(pc+1)&MEMMASK;
        switch((inst>>12)&0xF)
        {
            case 0x0: //br
            {
                printf("br");
                if(inst&0x0800) printf("n");
                if(inst&0x0400) printf("z");
                if(inst&0x0200) printf("p");
                simm=sext9(inst);
                dest=(pc+simm)&0xFFFF;
                printf(" 0x%04X",dest);
                if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                else            printf(" ; +%u",simm);
                printf("\n");

                test=(psr&7)&((inst>>9)&7);
                if(test)
                {
                    pc=pc+sext9(inst&0x1FF);
                }
                break;
            }
            case 0x1: //add
            {
                rd=(inst>>9)&7;
                sr1=(inst>>6)&7;
                if(inst&0x20)
                {
                    simm=sext5(inst);
                    printf("add r%u,r%u,#0x%04X\n",rd,sr1,simm);

                    sr1_data=read_reg(sr1);
                    rd_data=sr1_data+simm;
                }
                else
                {
                    sr2=(inst>>0)&7;
                    printf("add r%u,r%u,r%u",rd,sr1,sr2);

                    sr1_data=read_reg(sr1);
                    sr2_data=read_reg(sr2);
                    rd_data=sr1_data+sr2_data;
                }
                write_reg(rd,rd_data);
                docc(rd_data);
                break;
            }
            case 0x2: //ld
            {
                rd=(inst>>9)&7;
                simm=sext9(inst);
                dest=(pc+simm)&0xFFFF;
                printf("ld r%u,0x%04X",rd,dest);
                if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                else            printf(" ; +%u",simm);
                printf("\n");

                rd_data=read_mem(dest);
                write_reg(rd,rd_data);
                docc(rd_data);
                break;
            }
            case 0x3: //st
            {
                rd=(inst>>9)&7;
                simm=sext9(inst);
                dest=(pc+simm)&0xFFFF;
                printf("st r%u,0x%04X",rd,dest);
                if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                else            printf(" ; +%u",simm);
                printf("\n");

                rd_data=read_reg(rd);
                write_mem(dest,rd_data);
                break;
            }
            case 0x4: //jsr/jsrr
            {
                if(inst&0x0800)
                {
                    simm=sext11(inst);
                    dest=(pc+simm)&0xFFFF;
                    printf("jsr 0x%04X",dest);
                    if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                    else            printf(" ; +%u",simm);
                    printf("\n");

                    write_reg(7,pc);
                    pc=dest;
                }
                else
                {
                    rd=(inst>>6)&7;
                    printf("jsrr r%u\n",rd);

                    write_reg(7,pc);
                    pc=read_reg(rd);
                }
                break;
            }
            case 0x5: //and
            {
                rd=(inst>>9)&7;
                sr1=(inst>>6)&7;
                if(inst&0x20)
                {
                    simm=sext5(inst);
                    printf("and r%u,r%u,#0x%04X\n",rd,sr1,simm);

                    sr1_data=read_reg(sr1);
                    rd_data=sr1_data&simm;
                }
                else
                {
                    sr2=(inst>>0)&7;
                    printf("add r%u,r%u,r%u",rd,sr1,sr2);

                    sr1_data=read_reg(sr1);
                    sr2_data=read_reg(sr2);
                    rd_data=sr1_data&sr2_data;
                }
                write_reg(rd,rd_data);
                docc(rd_data);
                break;
            }
            case 0x6: //ldr
            {
                rd=(inst>>9)&7;
                sr1=(inst>>6)&7;
                simm=sext6(inst);
                printf("ldr r%u,r%u,#0x%04X",rd,sr1,simm);
                if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                else            printf(" ; +%u",simm);
                printf("\n");

                sr1_data=read_reg(sr1);
                dest=(sr1_data+simm)&0xFFFF;
                rd_data=read_mem(dest);
                write_reg(rd,rd_data);
                docc(rd_data);
                break;
            }
            case 0x7: //str
            {
                rd=(inst>>9)&7;
                sr1=(inst>>6)&7;
                simm=sext6(inst);
                printf("str r%u,r%u,#0x%04X",rd,sr1,simm);
                if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                else            printf(" ; +%u",simm);
                printf("\n");

                sr1_data=read_reg(sr1);
                dest=(sr1_data+simm)&0xFFFF;
                rd_data=read_reg(rd);
                write_mem(dest,rd_data);
                break;
            }
            case 0x8: //rti
            {
                printf("rti\n");
                if(psr&0x8000)
                {
                    printf("exception\n");
                    exit(1);
                }
                else
                {
                    rd_data=read_reg(6);
                    pc=read_mem(rd_data);
                    write_reg(6,(rd_data+1)&0xFFFF);
                    rd_data=read_reg(6);
                    psr=read_mem(rd_data);
                    write_reg(6,(rd_data+1)&0xFFFF);
                }
                break;
            }
            case 0x9: //not
            {
                rd=(inst>>9)&7;
                sr1=(inst>>6)&7;
                printf("not r%u,r%u\n",rd,sr1);

                sr1_data=read_reg(sr1);
                rd_data = ~sr1_data;
                write_reg(rd,rd_data);
                docc(rd_data);
                break;
            }
            case 0xA: //ldi
            {
                rd=(inst>>9)&7;
                simm=sext9(inst);
                dest=(pc+simm)&0xFFFF;
                printf("ldi r%u,0x%04X",rd,dest);
                if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                else            printf(" ; +%u",simm);
                printf("\n");

                rd_data=read_mem(read_mem(dest));
                write_reg(rd,rd_data);
                docc(rd_data);
                break;
            }
            case 0xB: //sti
            {
                rd=(inst>>9)&7;
                simm=sext9(inst);
                dest=(pc+simm)&0xFFFF;
                printf("sti r%u,0x%04X",rd,dest);
                if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                else            printf(" ; +%u",simm);
                printf("\n");

                rd_data=read_reg(rd);
                write_mem(read_mem(dest),rd_data);
                break;
            }
            case 0xC: //jmp/ret
            {
                sr1=(inst>>6)&7;
                printf("jmp r%u",sr1);
                if(sr1==7) printf(" ; ret");
                printf("\n");

                pc=read_reg(sr1);
                break;
            }
            case 0xD: //undefined
            {
                printf("undefined instruction\n");
                exit(1);
                break;
            }
            case 0xE: //lea
            {
                rd=(inst>>9)&7;
                simm=sext9(inst);
                dest=(pc+simm)&0xFFFF;
                printf("lea r%u,0x%04X",rd,dest);
                if(simm&0x8000) printf(" ; -%u",(simm^0xFFFF)+1);
                else            printf(" ; +%u",simm);
                printf("\n");

                write_reg(rd,dest);
                docc(dest);
                break;
            }
            case 0xF: //trap
            {
                printf("trap 0x%02X\n",inst&0xFF);
                if((inst&0xFF)==0x67)
                {
                    printf("show 0x%04X\n",reg[0]);
                }
                else
                if((inst&0xFF)==0x25)
                {
                    printf("halt\n");
                    return(0);
                }
                else
                {
                    reg[7]=pc;
                    pc=mem[inst&0xFF];
                }
                break;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x3cb8(%rip), %r12      # 0x50a0
movl $0xa, %edi
callq 0x1030
movzwl 0x23cc9(%rip), %esi     # 0x250c2
incl 0x3c91(%rip)            # 0x5090
movzwl (%r12,%rsi,2), %r15d
leaq 0x1c39(%rip), %rdi      # 0x3044
movl %r15d, %edx
xorl %eax, %eax
callq 0x1060
movzwl 0x23ca6(%rip), %esi     # 0x250c2
leaq 0x1caa(%rip), %rdi      # 0x30cd
movl %r15d, %edx
xorl %eax, %eax
callq 0x1060
movzwl 0x23c8e(%rip), %eax     # 0x250c2
incl %eax
movw %ax, 0x23c85(%rip)      # 0x250c2
movl %r15d, %ecx
shrl $0xc, %ecx
leaq 0x1bba(%rip), %rdx      # 0x3004
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x1c88(%rip), %rdi      # 0x30e2
xorl %eax, %eax
callq 0x1060
btl $0xb, %r15d
jae 0x1472
movl $0x6e, %edi
callq 0x1030
btl $0xa, %r15d
jae 0x1483
movl $0x7a, %edi
callq 0x1030
btl $0x9, %r15d
jae 0x1494
movl $0x70, %edi
callq 0x1030
movl %r15d, %r14d
andl $0x1ff, %r14d           # imm = 0x1FF
xorl %eax, %eax
cmpl $0x100, %r14d           # imm = 0x100
setb %al
shll $0x9, %eax
leal (%rax,%r14), %ebx
addl $0xfffffe00, %ebx       # imm = 0xFFFFFE00
movzwl 0x23c04(%rip), %eax     # 0x250c2
addw %bx, %ax
movzwl %ax, %esi
leaq 0x1c6c(%rip), %rdi      # 0x3137
xorl %eax, %eax
callq 0x1060
movzwl %bx, %esi
cmpl $0x100, %r14d           # imm = 0x100
jae 0x1b4b
leaq 0x1c03(%rip), %rdi      # 0x30ec
jmp 0x1b5b
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
andl $0x1ff, %r15d           # imm = 0x1FF
xorl %ecx, %ecx
cmpl $0x100, %r15d           # imm = 0x100
setb %cl
shll $0x9, %ecx
leal (%rcx,%r15), %r14d
addl $0xfffffe00, %r14d      # imm = 0xFFFFFE00
orl %r15d, %ecx
movl $0xffff, %edx           # imm = 0xFFFF
andl %edx, %r14d
leal (%rax,%rcx), %ebx
addl $0xfffffe00, %ebx       # imm = 0xFFFFFE00
andl %edx, %ebx
leaq 0x1c6b(%rip), %rdi      # 0x31a2
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
cmpl $0x100, %r15d           # imm = 0x100
jae 0x1993
leaq 0x1b95(%rip), %rdi      # 0x30ec
movl %r14d, %esi
jmp 0x19a2
btl $0xb, %r15d
jb 0x1a0e
shrl $0x6, %r15d
andl $0x7, %r15d
leaq 0x1bc6(%rip), %rdi      # 0x313f
movl %r15d, %esi
xorl %eax, %eax
callq 0x1060
movzwl 0x23b38(%rip), %edx     # 0x250c2
movw %dx, 0x23b2d(%rip)      # 0x250be
leaq 0x1b12(%rip), %rdi      # 0x30aa
movl $0x7, %esi
xorl %eax, %eax
callq 0x1060
leaq 0x23b05(%rip), %rax     # 0x250b0
movzwl (%rax,%r15,2), %ebx
jmp 0x15f8
shrl $0x6, %r15d
andl $0x7, %r15d
leaq 0x1bf0(%rip), %rdi      # 0x31b1
movl %r15d, %esi
xorl %eax, %eax
callq 0x1060
cmpw $0x7, %r15w
jne 0x15e0
leaq 0x1be0(%rip), %rdi      # 0x31b9
xorl %eax, %eax
callq 0x1060
movl $0xa, %edi
callq 0x1030
movl %r15d, %eax
leaq 0x23abc(%rip), %rcx     # 0x250b0
movzwl (%rcx,%rax,2), %ebx
leaq 0x1a95(%rip), %rdi      # 0x3094
movl %r15d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
movw %bx, 0x23ab0(%rip)      # 0x250c2
jmp 0x13e8
movl %r15d, %ebx
shrl $0x9, %ebx
andl $0x7, %ebx
shrl $0x6, %r15d
andl $0x7, %r15d
leaq 0x1b57(%rip), %rdi      # 0x3186
movl %ebx, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1060
leaq 0x23a6e(%rip), %rax     # 0x250b0
movq %r12, %r13
movq %rax, %r12
movzwl (%rax,%r15,2), %r14d
leaq 0x1a40(%rip), %rdi      # 0x3094
movl %r15d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
movl %r14d, %eax
notl %eax
movw %ax, (%r12,%rbx,2)
movq %r13, %r12
movzwl %ax, %edx
leaq 0x1a32(%rip), %rdi      # 0x30aa
movl %ebx, %esi
xorl %eax, %eax
callq 0x1060
movzwl 0x23a38(%rip), %eax     # 0x250c0
andl $0x8000, %eax           # imm = 0x8000
xorl %ecx, %ecx
cmpw $-0x1, %r14w
sete %cl
incl %ecx
testw %r14w, %r14w
movl $0x4, %edx
cmovnsl %edx, %ecx
movzbl %cl, %esi
jmp 0x1cf4
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
andl $0x1ff, %r15d           # imm = 0x1FF
xorl %ecx, %ecx
cmpl $0x100, %r15d           # imm = 0x100
setb %cl
shll $0x9, %ecx
leal (%rcx,%r15), %r14d
addl $0xfffffe00, %r14d      # imm = 0xFFFFFE00
orl %r15d, %ecx
movl $0xffff, %edx           # imm = 0xFFFF
andl %edx, %r14d
leal (%rax,%rcx), %ebx
addl $0xfffffe00, %ebx       # imm = 0xFFFFFE00
andl %edx, %ebx
leaq 0x1a22(%rip), %rdi      # 0x3118
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
cmpl $0x100, %r15d           # imm = 0x100
jae 0x1a71
leaq 0x19d6(%rip), %rdi      # 0x30ec
movl %r14d, %esi
jmp 0x1a80
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
andl $0x1ff, %r15d           # imm = 0x1FF
xorl %ecx, %ecx
cmpl $0x100, %r15d           # imm = 0x100
setb %cl
shll $0x9, %ecx
leal (%rcx,%r15), %r14d
addl $0xfffffe00, %r14d      # imm = 0xFFFFFE00
orl %r15d, %ecx
movl $0xffff, %edx           # imm = 0xFFFF
andl %edx, %r14d
leal (%rax,%rcx), %ebx
addl $0xfffffe00, %ebx       # imm = 0xFFFFFE00
andl %edx, %ebx
leaq 0x19bf(%rip), %rdi      # 0x3126
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
cmpl $0x100, %r15d           # imm = 0x100
jae 0x1aea
leaq 0x1965(%rip), %rdi      # 0x30ec
movl %r14d, %esi
jmp 0x1af9
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
movl %r15d, %ebx
shrl $0x6, %ebx
andl $0x7, %ebx
andl $0x3f, %r15d
xorl %eax, %eax
cmpw $0x20, %r15w
setb %al
shll $0x6, %eax
addl %r15d, %eax
addl $-0x40, %eax
movzwl %ax, %r14d
leaq 0x1999(%rip), %rdi      # 0x315e
movl %r13d, %esi
movl %ebx, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x1060
cmpw $0x20, %r15w
jae 0x1b8e
leaq 0x1906(%rip), %rdi      # 0x30ec
movl %r14d, %esi
jmp 0x1b9d
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
andl $0x1ff, %r15d           # imm = 0x1FF
xorl %ecx, %ecx
cmpl $0x100, %r15d           # imm = 0x100
setb %cl
shll $0x9, %ecx
leal (%rcx,%r15), %r14d
addl $0xfffffe00, %r14d      # imm = 0xFFFFFE00
orl %r15d, %ecx
movl $0xffff, %edx           # imm = 0xFFFF
andl %edx, %r14d
leal (%rax,%rcx), %ebx
addl $0xfffffe00, %ebx       # imm = 0xFFFFFE00
andl %edx, %ebx
leaq 0x195c(%rip), %rdi      # 0x3193
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
cmpl $0x100, %r15d           # imm = 0x100
jae 0x1c3f
leaq 0x1895(%rip), %rdi      # 0x30ec
movl %r14d, %esi
jmp 0x1c4e
leaq 0x19d3(%rip), %rdi      # 0x3239
callq 0x1040
cmpw $0x0, 0x2384d(%rip)     # 0x250c0
js 0x2171
movzwl 0x2383c(%rip), %ebx     # 0x250bc
leaq 0x180d(%rip), %rdi      # 0x3094
movl $0x6, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
incl 0x23805(%rip)           # 0x250a0
movzwl (%r12,%rbx,2), %r14d
leaq 0x17b8(%rip), %r13      # 0x305f
movq %r13, %rdi
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
movw %r14w, 0x23804(%rip)    # 0x250c2
incl %ebx
movw %bx, 0x237f5(%rip)      # 0x250bc
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebx
movq %r12, %r15
leaq 0x17d2(%rip), %r12      # 0x30aa
movq %r12, %rdi
movl $0x6, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
movzwl 0x237cc(%rip), %ebx     # 0x250bc
leaq 0x179d(%rip), %rdi      # 0x3094
movl $0x6, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
incl 0x23795(%rip)           # 0x250a0
movzwl (%r15,%rbx,2), %r14d
movq %r13, %rdi
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
movw %r14w, 0x23799(%rip)    # 0x250c0
incl %ebx
movw %bx, 0x2378c(%rip)      # 0x250bc
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebx
movq %r12, %rdi
movq %r15, %r12
movl $0x6, %esi
movl %ebx, %edx
jmp 0x1b3f
movzbl %r15b, %ebx
leaq 0x187b(%rip), %rdi      # 0x31cf
movl %ebx, %esi
xorl %eax, %eax
callq 0x1060
cmpb $0x67, %r15b
je 0x1d10
movzbl %r15b, %eax
cmpl $0x25, %eax
je 0x214b
movzwl 0x23747(%rip), %eax     # 0x250c2
movw %ax, 0x2373c(%rip)      # 0x250be
movzwl (%r12,%rbx,2), %eax
movw %ax, 0x23734(%rip)      # 0x250c2
jmp 0x13e8
movl $0x10000, %esi          # imm = 0x10000
subl %r14d, %esi
leaq 0x1743(%rip), %rdi      # 0x30e5
xorl %eax, %eax
callq 0x1060
leaq 0x16e4(%rip), %r15      # 0x3094
movl $0xa, %edi
callq 0x1030
movl %r13d, %eax
leaq 0x236ec(%rip), %rcx     # 0x250b0
movzwl (%rcx,%rax,2), %r14d
movq %r15, %rdi
movl %r13d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
incl 0x236c1(%rip)           # 0x250a0
movl %ebx, %eax
movzwl (%r12,%rax,2), %r15d
leaq 0x1672(%rip), %rdi      # 0x305f
movl %ebx, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1060
incl 0x236a5(%rip)           # 0x250a4
leaq 0x1673(%rip), %rdi      # 0x3079
movl %r15d, %esi
jmp 0x1b3c
andl $0x7ff, %r15d           # imm = 0x7FF
xorl %ecx, %ecx
cmpl $0x400, %r15d           # imm = 0x400
setb %cl
shll $0xb, %ecx
leal (%rcx,%r15), %ebx
addl $0xfffff800, %ebx       # imm = 0xFFFFF800
orl %r15d, %ecx
movl $0xffff, %edx           # imm = 0xFFFF
andl %edx, %ebx
leal (%rax,%rcx), %r14d
addl $0xfffff800, %r14d      # imm = 0xFFFFF800
movl %r14d, %esi
andl %edx, %esi
leaq 0x16e5(%rip), %rdi      # 0x3134
xorl %eax, %eax
callq 0x1060
cmpl $0x400, %r15d           # imm = 0x400
jae 0x1d20
leaq 0x1682(%rip), %rdi      # 0x30ec
movl %ebx, %esi
jmp 0x1d2e
movl $0x10000, %esi          # imm = 0x10000
subl %r14d, %esi
leaq 0x1665(%rip), %rdi      # 0x30e5
xorl %eax, %eax
callq 0x1060
movl $0xa, %edi
callq 0x1030
movl %ebx, %eax
movzwl (%r12,%rax,2), %r14d
xorl %r15d, %r15d
testw %r14w, %r14w
sete %r15b
incl %r15d
testw %r14w, %r14w
movl $0x4, %eax
cmovsl %eax, %r15d
incl 0x235e7(%rip)           # 0x250a0
leaq 0x159f(%rip), %rdi      # 0x305f
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
leaq 0x235dd(%rip), %rax     # 0x250b0
movw %r14w, (%rax,%r13,2)
leaq 0x15cb(%rip), %rdi      # 0x30aa
movl %r13d, %esi
movl %r14d, %edx
jmp 0x1cdd
movl $0x10000, %esi          # imm = 0x10000
subl %r14d, %esi
leaq 0x15ec(%rip), %rdi      # 0x30e5
xorl %eax, %eax
callq 0x1060
leaq 0x158d(%rip), %r15      # 0x3094
movl $0xa, %edi
callq 0x1030
leaq 0x23598(%rip), %rax     # 0x250b0
movzwl (%rax,%r13,2), %r14d
movq %r15, %rdi
movl %r13d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
incl 0x23571(%rip)           # 0x250a4
leaq 0x153f(%rip), %rdi      # 0x3079
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
jmp 0x13e8
movl $0x10000, %eax          # imm = 0x10000
subl %esi, %eax
leaq 0x158c(%rip), %rdi      # 0x30e5
movl %eax, %esi
xorl %eax, %eax
callq 0x1060
movl $0xa, %edi
callq 0x1030
shrl $0x9, %r15d
andw 0x23548(%rip), %r15w    # 0x250c0
testb $0x7, %r15b
je 0x13e8
addw %bx, 0x23539(%rip)      # 0x250c2
jmp 0x13e8
movl $0x10000, %esi          # imm = 0x10000
subl %r14d, %esi
leaq 0x1548(%rip), %rdi      # 0x30e5
xorl %eax, %eax
callq 0x1060
movl $0xa, %edi
callq 0x1030
leaq 0x234fb(%rip), %r12     # 0x250b0
movzwl (%r12,%rbx,2), %r15d
leaq 0x14d3(%rip), %rdi      # 0x3094
movl %ebx, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1060
addl %r15d, %r14d
movzwl %r14w, %esi
leaq 0x34c5(%rip), %r15      # 0x50a0
movzwl (%r15,%rsi,2), %ebx
xorl %r14d, %r14d
testw %bx, %bx
sete %r14b
incl %r14d
testw %bx, %bx
movl $0x4, %eax
cmovsl %eax, %r14d
incl 0x234a1(%rip)           # 0x250a0
leaq 0x1459(%rip), %rdi      # 0x305f
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
movw %bx, (%r12,%r13,2)
movq %r15, %r12
leaq 0x148c(%rip), %rdi      # 0x30aa
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
movzwl 0x2348f(%rip), %eax     # 0x250c0
andl $0x8000, %eax           # imm = 0x8000
movzbl %r14b, %esi
jmp 0x1cf4
movl $0x10000, %esi          # imm = 0x10000
subl %r14d, %esi
leaq 0x1497(%rip), %rdi      # 0x30e5
xorl %eax, %eax
callq 0x1060
movl $0xa, %edi
callq 0x1030
incl 0x2343b(%rip)           # 0x250a0
movl %ebx, %eax
movzwl (%r12,%rax,2), %r14d
leaq 0x13ec(%rip), %r12      # 0x305f
movq %r12, %rdi
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
leaq 0x3417(%rip), %rax      # 0x50a0
movzwl (%rax,%r14,2), %ebx
xorl %r15d, %r15d
testw %bx, %bx
sete %r15b
incl %r15d
testw %bx, %bx
movl $0x4, %eax
cmovsl %eax, %r15d
incl 0x233f3(%rip)           # 0x250a0
movq %r12, %rdi
leaq 0x33e9(%rip), %r12      # 0x50a0
movl %r14d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
movl %r13d, %eax
leaq 0x233e3(%rip), %rcx     # 0x250b0
movw %bx, (%rcx,%rax,2)
leaq 0x13d2(%rip), %rdi      # 0x30aa
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
movzwl 0x233d5(%rip), %eax     # 0x250c0
andl $0x8000, %eax           # imm = 0x8000
movzbl %r15b, %esi
orl %eax, %esi
movw %si, 0x233c3(%rip)      # 0x250c0
leaq 0x13bd(%rip), %rdi      # 0x30c1
xorl %eax, %eax
callq 0x1060
jmp 0x13e8
movzwl 0x23399(%rip), %esi     # 0x250b0
leaq 0x14be(%rip), %rdi      # 0x31dc
jmp 0x1d04
movl $0x10000, %esi          # imm = 0x10000
subl %ebx, %esi
leaq 0x13b7(%rip), %rdi      # 0x30e5
xorl %eax, %eax
callq 0x1060
movl $0xa, %edi
callq 0x1030
movzwl 0x2337c(%rip), %edx     # 0x250c2
movw %dx, 0x23371(%rip)      # 0x250be
leaq 0x1356(%rip), %rdi      # 0x30aa
movl $0x7, %esi
xorl %eax, %eax
callq 0x1060
movw %r14w, 0x2335a(%rip)    # 0x250c2
jmp 0x13e8
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
andl $0x1ff, %r15d           # imm = 0x1FF
xorl %ecx, %ecx
cmpl $0x100, %r15d           # imm = 0x100
setb %cl
shll $0x9, %ecx
leal (%rcx,%r15), %r14d
addl $0xfffffe00, %r14d      # imm = 0xFFFFFE00
orl %r15d, %ecx
movl $0xffff, %edx           # imm = 0xFFFF
andl %edx, %r14d
leal (%rax,%rcx), %r12d
addl $0xfffffe00, %r12d      # imm = 0xFFFFFE00
movl %r12d, %ebx
andl %edx, %ebx
leaq 0x1405(%rip), %rdi      # 0x31c0
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
cmpl $0x100, %r15d           # imm = 0x100
jae 0x1f2a
leaq 0x1311(%rip), %rdi      # 0x30ec
movl %r14d, %esi
jmp 0x1f39
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
movl %r15d, %r12d
shrl $0x6, %r12d
andl $0x7, %r12d
andl $0x3f, %r15d
xorl %eax, %eax
cmpw $0x20, %r15w
setb %al
shll $0x6, %eax
addl %r15d, %eax
addl $-0x40, %eax
movzwl %ax, %ebx
leaq 0x1358(%rip), %rdi      # 0x3172
movl %r13d, %esi
movl %r12d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1060
cmpw $0x20, %r15w
jae 0x1f83
leaq 0x12b1(%rip), %rdi      # 0x30ec
movl %ebx, %esi
jmp 0x1f91
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
movl %r15d, %r12d
shrl $0x6, %r12d
andl $0x7, %r12d
testb $0x20, %r15b
jne 0x2006
andl $0x7, %r15d
movzwl %r13w, %esi
movzwl %r12w, %edx
movl %edx, -0x30(%rbp)
leaq 0x1290(%rip), %rdi      # 0x3108
movl %esi, -0x2c(%rbp)
movl %r15d, %ecx
xorl %eax, %eax
callq 0x1060
leaq 0x23224(%rip), %rax     # 0x250b0
movq %rax, %r14
movzwl (%rax,%r12,2), %ebx
movzwl %bx, %edx
leaq 0x11f6(%rip), %r12      # 0x3094
movq %r12, %rdi
movl -0x30(%rbp), %esi
xorl %eax, %eax
callq 0x1060
movq %r12, %rdi
movl %r15d, %r12d
jmp 0x204a
movl %r15d, %r13d
shrl $0x9, %r13d
andl $0x7, %r13d
movl %r15d, %r12d
shrl $0x6, %r12d
andl $0x7, %r12d
testb $0x20, %r15b
jne 0x2092
andl $0x7, %r15d
movzwl %r13w, %esi
movzwl %r12w, %edx
movl %edx, -0x30(%rbp)
leaq 0x121c(%rip), %rdi      # 0x3108
movl %esi, -0x2c(%rbp)
movl %r15d, %ecx
xorl %eax, %eax
callq 0x1060
leaq 0x231b0(%rip), %rax     # 0x250b0
movq %rax, %r14
movzwl (%rax,%r12,2), %ebx
movzwl %bx, %edx
leaq 0x1182(%rip), %r12      # 0x3094
movq %r12, %rdi
movl -0x30(%rbp), %esi
xorl %eax, %eax
callq 0x1060
movq %r12, %rdi
movl %r15d, %r12d
jmp 0x20d6
movl $0x10000, %esi          # imm = 0x10000
subl %r14d, %esi
leaq 0x11ac(%rip), %rdi      # 0x30e5
xorl %eax, %eax
callq 0x1060
xorl %r14d, %r14d
testw %r12w, %r12w
sete %r14b
incl %r14d
testw %r12w, %r12w
movl $0x4, %eax
cmovsl %eax, %r14d
movl $0xa, %edi
callq 0x1030
movl %r13d, %eax
leaq 0x23141(%rip), %rcx     # 0x250b0
movw %r12w, (%rcx,%rax,2)
leaq 0x112f(%rip), %rdi      # 0x30aa
movl %r13d, %esi
jmp 0x2116
movl $0x10000, %esi          # imm = 0x10000
subl %ebx, %esi
leaq 0x1154(%rip), %rdi      # 0x30e5
xorl %eax, %eax
callq 0x1060
leaq 0x23111(%rip), %r14     # 0x250b0
movl $0xa, %edi
callq 0x1030
movl %r12d, %eax
movq %r14, %r15
movzwl (%r14,%rax,2), %r14d
leaq 0x10d9(%rip), %rdi      # 0x3094
movl %r12d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
addl %r14d, %ebx
movl %r13d, %eax
movzwl (%r15,%rax,2), %r14d
leaq 0x10ba(%rip), %rdi      # 0x3094
movl %r13d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
incl 0x230b7(%rip)           # 0x250a4
movzwl %bx, %esi
leaq 0x1082(%rip), %rdi      # 0x3079
movl %r14d, %edx
xorl %eax, %eax
callq 0x1060
jmp 0x13e1
andl $0x1f, %r15d
xorl %eax, %eax
cmpw $0x10, %r15w
setb %al
shll $0x5, %eax
leal (%rax,%r15), %ebx
addl $-0x20, %ebx
movzwl %bx, %ecx
leaq 0x10cb(%rip), %rdi      # 0x30f3
movl %r13d, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x1060
movl %r12d, %r15d
movl %r13d, -0x2c(%rbp)
leaq 0x2306d(%rip), %r14     # 0x250b0
leaq 0x104a(%rip), %rdi      # 0x3094
movzwl %r12w, %eax
movq %r14, %r12
movzwl (%r14,%rax,2), %edx
addl %edx, %ebx
xorl %r14d, %r14d
testw %bx, %bx
sete %r14b
incl %r14d
testw %bx, %bx
movl $0x4, %eax
cmovsl %eax, %r14d
movl %r15d, %esi
xorl %eax, %eax
callq 0x1060
movw %bx, (%r12,%r13,2)
movzwl %bx, %edx
leaq 0x1020(%rip), %rdi      # 0x30aa
movl -0x2c(%rbp), %esi
jmp 0x2118
andl $0x1f, %r15d
xorl %eax, %eax
cmpw $0x10, %r15w
setb %al
shll $0x5, %eax
leal (%rax,%r15), %ebx
addl $-0x20, %ebx
movzwl %bx, %ecx
leaq 0x1095(%rip), %rdi      # 0x3149
movl %r13d, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x1060
movl %r12d, %r15d
movl %r13d, -0x2c(%rbp)
leaq 0x22fe1(%rip), %r14     # 0x250b0
leaq 0xfbe(%rip), %rdi       # 0x3094
movzwl %r12w, %eax
movq %r14, %r12
movzwl (%r14,%rax,2), %edx
andl %edx, %ebx
xorl %r14d, %r14d
testw %bx, %bx
sete %r14b
incl %r14d
testw %bx, %bx
movl $0x4, %eax
cmovsl %eax, %r14d
movl %r15d, %esi
xorl %eax, %eax
callq 0x1060
movw %bx, (%r12,%r13,2)
leaq 0xf97(%rip), %rdi       # 0x30aa
movl -0x2c(%rbp), %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
movzwl 0x22f9a(%rip), %eax     # 0x250c0
andl $0x8000, %eax           # imm = 0x8000
movzbl %r14b, %esi
orl %eax, %esi
movw %si, 0x22f88(%rip)      # 0x250c0
leaq 0xf82(%rip), %rdi       # 0x30c1
xorl %eax, %eax
callq 0x1060
jmp 0x13e1
leaq 0x10cc(%rip), %rdi      # 0x321e
callq 0x1040
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10b4(%rip), %rdi      # 0x3223
jmp 0x2178
leaq 0x10c5(%rip), %rdi      # 0x323d
callq 0x1040
movl $0x1, %edi
callq 0x10c0