// File: /workspace/github_c_makefile_star2_O0/salextpuru[P]speccy-toochain/src/mhmt/mhmt-emit.c
// Function: emit_hrust
ULONG emit_hrust(struct optchain * optch, ULONG actual_len)
{
    ULONG position;
    LONG length;
    LONG disp;
    LONG max_disp; // maximum encountered displacement
    ULONG varbits,varlen;
    ULONG success = 1;
    UBYTE wrlen[2];
    ULONG expbitlen = 2; // expandable match: bitlength of displacement
    max_disp = 0;

    // some checks
    if( !optch ) {
        printf("mhmt-emit.c:emit_hrust() - NULL passed!\n");
        return 0;
    }

    // initialize
    success = success && emit_file(NULL, EMIT_FILE_INIT);
    success = success && emit_byte(0, EMIT_BYTE_INIT);
    success = success && emit_bits(0, EMIT_BITS_INIT);

    // manage zx header info
    if( wrk.zxheader ) {
        success = success && emit_file( (UBYTE*)"HR", 2);
        wrlen[0] = wrk.inlen&0x00FF;
        wrlen[1] = (wrk.inlen>>8)&0x00FF;
        success = success && emit_file( wrlen, 2); // unpacked length mod 65536
        success = success && emit_file( wrlen, 2); // packed length - !to be filled later!
        success = success && emit_file( &wrk.indata[wrk.inlen-6], 6); // last bytes
    }

    // schedule first byte to be placed just after first bitstream word
    success = success && emit_byte( wrk.indata[0], EMIT_BYTE_ADD);
    // go emitting codes
    position = 1;

    while( (position<actual_len) && success ) {
#ifdef DBG
        printf("%04x:",position);
#endif
        length = optch[position].code.length;
        disp   = optch[position].code.disp;

        if( length==0 ) {
            printf("mhmt-emit.c:emit_hrust() - encountered stop-code in optimal chain before emitting all data!\n");
            return 0;

        } else if( disp==0 ) { // copy-bytes
            if( length==1 ) { // 1 byte: %1<byte>
                success = success && emit_bits( 0x80000000, 1 );
                success = success && emit_byte( wrk.indata[position], EMIT_BYTE_ADD );

            } else if( (12<=length) && (length<=42) && ( !(length&1) ) ) { // %0110001abcd<byte,byte,...>
                varbits = (length-12)<<27;
                success = success && emit_bits( 0x62000000, 7 );
                success = success && emit_bits( varbits, 4 );
                varlen = 0;

                while( success && (varlen<(ULONG)length) ) {
                    success = success && emit_byte( wrk.indata[position+varlen], EMIT_BYTE_ADD );
                    varlen++;
                }

            } else
                goto INVALID_CODE_HRUST;

        } else if( length==(-3) ) { // insertion code
            if( (-16)<=disp && disp<=(-1) ) { // %011001abcd<byte>
                success = success && emit_bits( 0x64000000, 6 );
                success = success && emit_bits( disp<<(32-4), 4 );

            } else if( (-79)<=disp && disp<(-16) ) {
                if( disp&1 ) { // ffb1..ffef: %01001<byte><byte>
                    success = success && emit_bits( 0x48000000, 5 );
                    varbits = disp&0x00FF;
                    varbits += 15;
                    varbits ^= 3;
                    varbits = ( (varbits>>1)&0x007F ) | ( (varbits<<7)&0x0080 );
                    success = success && emit_byte( (UBYTE)(varbits&0x00FF), EMIT_BYTE_ADD );

                } else { // ffb2..ffee: %00110<byte><byte>
                    success = success && emit_bits( 0x30000000, 5 );
                    varbits = disp&0x00FF;
                    varbits += 15;
                    varbits ^= 2;
                    varbits = ( (varbits>>1)&0x007F ) | ( (varbits<<7)&0x0080 );
                    success = success && emit_byte( (UBYTE)(varbits&0x00FF), EMIT_BYTE_ADD );
                }

            } else
                goto INVALID_CODE_HRUST;

            success = success && emit_byte( wrk.indata[position+1], EMIT_BYTE_ADD );

        } else if( length==1 ) { // %000abc
            if( (-8)<=disp && disp<=(-1) ) {
                success = success && emit_bits( 0x00000000, 3 );
                success = success && emit_bits( disp<<(32-3), 3 );

            } else
                goto INVALID_CODE_HRUST;

        } else if( length==2 ) {
            if( (-32)<=disp && disp<=(-1) ) { // %00111abcde
                success = success && emit_bits( 0x38000000, 5 );
                success = success && emit_bits( disp<<(32-5), 5 );

            } else if( (-256)<=disp && disp<(-32) ) { // %00110<byte>
                success = success && emit_bits( 0x30000000, 5 );
                success = success && emit_byte( (UBYTE)(0x00FF & disp), EMIT_BYTE_ADD );

            } else if( (-512)<=disp && disp<(-256) ) { // %00101<byte>
                success = success && emit_bits( 0x28000000, 5 );
                success = success && emit_byte( (UBYTE)(0x00FF & disp), EMIT_BYTE_ADD );

            } else if( (-768)<=disp && disp<(-512) ) { // %00100<byte>
                success = success && emit_bits( 0x20000000, 5 );
                success = success && emit_byte( (UBYTE)(0x00FF & disp), EMIT_BYTE_ADD );

            } else
                goto INVALID_CODE_HRUST;

        } else if (3<=length && length<=3839 && (-65536)<=disp && disp<=(-1) ) {
            // first see if we need emitting expansion codes
            //  -513.. -1024  (FDFF..FC00) - 2 bits
            //  -1025..-2048  (FBFF..F800) - 3
            //  -2049..-4096  (F7FF..F000) - 4
            //  -4097..-8192  (EFFF..E000) - 5
            //  -8193..-16384 (DFFF..C000) - 6
            // -16385..-32768 (BFFF..8000) - 7
            // -32769..-65536 (7FFF..0000) - 8
            if( disp<(-512) ) {
                varbits = 1024;
                varlen  = 2;

                while( (ULONG)(-disp) > varbits ) {
                    varbits <<= 1;
                    varlen++;
                }

                // emit expansion codes, if necessary: %00110<FE>
                while( varlen>expbitlen ) {
                    success = success && emit_bits( 0x30000000, 5 );
                    success = success && emit_byte( 0x00FE, EMIT_BYTE_ADD );
#ifdef DBG
                    printf("expansion\n");
#endif
                    expbitlen++;
                }
            }

            // emit length
            if( length<=15 ) { // 3..15
                success = success && emit_bits( 0, 1 );

                if( length==3 ) {
                    success = success && emit_bits( 0x80000000, 2 ); // %010

                } else {
                    varlen  = length/3;
                    varbits = length%3;
                    success = success && emit_bits( 0xFFFFFFFF, varlen<<1 );

                    if( length!=15 )
                        success = success && emit_bits( varbits<<(32-2), 2 );
                }

            } else if( length<=127 ) { // 16..127: %0110000abcdefg
                success = success && emit_bits( 0x60000000, 7 );
                success = success && emit_bits( length<<(32-7), 7 );

            } else { // 128..3839
                success = success && emit_bits( 0x60000000, 7 );
                success = success && emit_bits( length<<(32-15), 7 );
                success = success && emit_byte( (UBYTE)(length&0x00FF), EMIT_BYTE_ADD );
            }

            // emit displacement
            if( (-32)<=disp ) { // ffe0..ffff: %10abcde
                success = success && emit_bits( 0x80000000, 2 );
                success = success && emit_bits( disp<<(32-5), 5 );

            } else if( (-256)<=disp ) { // ff00..ffdf: %01<byte>
                success = success && emit_bits( 0x40000000, 2 );
                success = success && emit_byte( (UBYTE)(disp&0x00FF), EMIT_BYTE_ADD );

            } else if( (-512)<=disp ) { // fe00..feff: %00<byte>
                success = success && emit_bits( 0x00000000, 2 );
                success = success && emit_byte( (UBYTE)(disp&0x00FF), EMIT_BYTE_ADD );

            } else { // variable code length: [-65536..-512)
                // displacement itself: %11ab[cdefgh]<byte>
                success = success && emit_bits( 0xC0000000, 2 );
                success = success && emit_bits( disp<<(24-expbitlen), expbitlen );
                success = success && emit_byte( (UBYTE)(disp&0x00FF), EMIT_BYTE_ADD );
            }

        } else {
INVALID_CODE_HRUST:
            printf("mhmt-emit.c:emit_hrust() - invalid code: length=%d, displacement=%d\n",length,disp);
            return 0;
        }

#ifdef DBG

        if( length==(-3) ) {
            printf("insert-match.len=%d,disp=%d\n",(-length),disp);

        } else if( disp==0 ) {
            printf("copy.len=%d\n",length);

        } else {
            printf("match.len=%d,disp=%d\n",length,disp);
        }

#endif

        if( max_disp > disp ) max_disp = disp;

        if( length>0 ) // account for negative length
            position += length;

        else
            position -= length;
    }

    // stop-code: %0110_0000_0011_11
    success = success && emit_bits( 0x603C0000, 14 );
    success = success && emit_bits( 0, EMIT_BITS_FINISH ); // this also flushes emit_byte()
    success = success && emit_file( NULL, EMIT_FILE_FINISH );

    if( success ) {
        printf("Maximum displacement actually used is %d.\n",-max_disp);
        // TODO: patch packed length in file, if zx header
    }

    return success;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movl %esi, 0x64(%rsp)
movl $0x1, 0x48(%rsp)
movl $0x2, 0x40(%rsp)
movl $0x0, 0x54(%rsp)
cmpq $0x0, 0x68(%rsp)
jne 0x2818
leaq 0x69c4(%rip), %rdi      # 0x91c8
movb $0x0, %al
callq 0x1040
movl $0x0, 0x74(%rsp)
jmp 0x37b2
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x3f(%rsp)
je 0x283d
xorl %eax, %eax
movl %eax, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1950
cmpl $0x0, %eax
setne %al
movb %al, 0x3f(%rsp)
movb 0x3f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x3e(%rsp)
je 0x286a
xorl %esi, %esi
movl %esi, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x3e(%rsp)
movb 0x3e(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x3d(%rsp)
je 0x289a
xorl %edi, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x3d(%rsp)
movb 0x3d(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
leaq 0xbaf2(%rip), %rax      # 0xe3a0
cmpl $0x0, 0xc(%rax)
je 0x29c7
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x3c(%rsp)
je 0x28e0
leaq 0x6925(%rip), %rdi      # 0x91f1
movl $0x2, %esi
callq 0x1950
cmpl $0x0, %eax
setne %al
movb %al, 0x3c(%rsp)
movb 0x3c(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
leaq 0xbaac(%rip), %rax      # 0xe3a0
movl 0x48(%rax), %eax
andl $0xff, %eax
movb %al, 0x46(%rsp)
leaq 0xba99(%rip), %rax      # 0xe3a0
movl 0x48(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, 0x47(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x3b(%rsp)
je 0x293c
leaq 0x46(%rsp), %rdi
movl $0x2, %esi
callq 0x1950
cmpl $0x0, %eax
setne %al
movb %al, 0x3b(%rsp)
movb 0x3b(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x3a(%rsp)
je 0x296f
leaq 0x46(%rsp), %rdi
movl $0x2, %esi
callq 0x1950
cmpl $0x0, %eax
setne %al
movb %al, 0x3a(%rsp)
movb 0x3a(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x39(%rsp)
je 0x29ba
leaq 0xba10(%rip), %rax      # 0xe3a0
movq 0x40(%rax), %rdi
leaq 0xba05(%rip), %rax      # 0xe3a0
movl 0x48(%rax), %eax
subl $0x6, %eax
movl %eax, %eax
addq %rax, %rdi
movl $0x6, %esi
callq 0x1950
cmpl $0x0, %eax
setne %al
movb %al, 0x39(%rsp)
movb 0x39(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x38(%rsp)
je 0x29f6
leaq 0xb9c5(%rip), %rax      # 0xe3a0
movq 0x40(%rax), %rax
movl $0x2, %esi
movzbl (%rax), %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x38(%rsp)
movb 0x38(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
movl $0x1, 0x60(%rsp)
movl 0x60(%rsp), %ecx
xorl %eax, %eax
cmpl 0x64(%rsp), %ecx
movb %al, 0x37(%rsp)
jae 0x2a27
cmpl $0x0, 0x48(%rsp)
setne %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x2a34
jmp 0x3700
movq 0x68(%rsp), %rax
movl 0x60(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, 0x5c(%rsp)
movq 0x68(%rsp), %rax
movl 0x60(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, 0x58(%rsp)
cmpl $0x0, 0x5c(%rsp)
jne 0x2a83
leaq 0x6785(%rip), %rdi      # 0x91f4
movb $0x0, %al
callq 0x1040
movl $0x0, 0x74(%rsp)
jmp 0x37b2
cmpl $0x0, 0x58(%rsp)
jne 0x2c3b
cmpl $0x1, 0x5c(%rsp)
jne 0x2b0e
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x36(%rsp)
je 0x2abb
movl $0x80000000, %edi       # imm = 0x80000000
movl $0x1, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x36(%rsp)
movb 0x36(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x35(%rsp)
je 0x2afc
leaq 0xb8c4(%rip), %rax      # 0xe3a0
movq 0x40(%rax), %rax
movl 0x60(%rsp), %ecx
movl $0x2, %esi
movzbl (%rax,%rcx), %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x35(%rsp)
movb 0x35(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x2c36
movl $0xc, %eax
cmpl 0x5c(%rsp), %eax
jg 0x2c2f
cmpl $0x2a, 0x5c(%rsp)
jg 0x2c2f
movl 0x5c(%rsp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2c2f
movl 0x5c(%rsp), %eax
subl $0xc, %eax
shll $0x1b, %eax
movl %eax, 0x50(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x34(%rsp)
je 0x2b6c
movl $0x62000000, %edi       # imm = 0x62000000
movl $0x7, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x34(%rsp)
movb 0x34(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x33(%rsp)
je 0x2b9e
movl 0x50(%rsp), %edi
movl $0x4, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x33(%rsp)
movb 0x33(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
movl $0x0, 0x4c(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x32(%rsp)
je 0x2bcf
movl 0x4c(%rsp), %eax
cmpl 0x5c(%rsp), %eax
setb %al
movb %al, 0x32(%rsp)
movb 0x32(%rsp), %al
testb $0x1, %al
jne 0x2bd9
jmp 0x2c2d
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x31(%rsp)
je 0x2c13
leaq 0xb7b3(%rip), %rax      # 0xe3a0
movq 0x40(%rax), %rax
movl 0x60(%rsp), %ecx
addl 0x4c(%rsp), %ecx
movl %ecx, %ecx
movl $0x2, %esi
movzbl (%rax,%rcx), %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x31(%rsp)
movb 0x31(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x2bb3
jmp 0x2c34
jmp 0x3699
jmp 0x2c36
jmp 0x36c4
cmpl $-0x3, 0x5c(%rsp)
jne 0x2ea0
movl $0xfffffff0, %eax       # imm = 0xFFFFFFF0
cmpl 0x58(%rsp), %eax
jg 0x2cc5
cmpl $-0x1, 0x58(%rsp)
jg 0x2cc5
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x30(%rsp)
je 0x2c7e
movl $0x64000000, %edi       # imm = 0x64000000
movl $0x6, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x30(%rsp)
movb 0x30(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x2f(%rsp)
je 0x2cb3
movl 0x58(%rsp), %edi
shll $0x1c, %edi
movl $0x4, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x2f(%rsp)
movb 0x2f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x2e55
movl $0xffffffb1, %eax       # imm = 0xFFFFFFB1
cmpl 0x58(%rsp), %eax
jg 0x2e4e
cmpl $-0x10, 0x58(%rsp)
jge 0x2e4e
movl 0x58(%rsp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2da0
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x2e(%rsp)
je 0x2d15
movl $0x48000000, %edi       # imm = 0x48000000
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x2e(%rsp)
movb 0x2e(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
movl 0x58(%rsp), %eax
andl $0xff, %eax
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
addl $0xf, %eax
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
xorl $0x3, %eax
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
shrl %eax
andl $0x7f, %eax
movl 0x50(%rsp), %ecx
shll $0x7, %ecx
andl $0x80, %ecx
orl %ecx, %eax
movl %eax, 0x50(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x2d(%rsp)
je 0x2d8e
movl 0x50(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x2d(%rsp)
movb 0x2d(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x2e4c
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x2c(%rsp)
je 0x2dc6
movl $0x30000000, %edi       # imm = 0x30000000
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x2c(%rsp)
movb 0x2c(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
movl 0x58(%rsp), %eax
andl $0xff, %eax
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
addl $0xf, %eax
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
xorl $0x2, %eax
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
shrl %eax
andl $0x7f, %eax
movl 0x50(%rsp), %ecx
shll $0x7, %ecx
andl $0x80, %ecx
orl %ecx, %eax
movl %eax, 0x50(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x2b(%rsp)
je 0x2e3f
movl 0x50(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x2b(%rsp)
movb 0x2b(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x2e53
jmp 0x3699
jmp 0x2e55
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x2a(%rsp)
je 0x2e8e
leaq 0xb537(%rip), %rax      # 0xe3a0
movq 0x40(%rax), %rax
movl 0x60(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl $0x2, %esi
movzbl (%rax,%rcx), %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x2a(%rsp)
movb 0x2a(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x36c2
cmpl $0x1, 0x5c(%rsp)
jne 0x2f2e
movl $0xfffffff8, %eax       # imm = 0xFFFFFFF8
cmpl 0x58(%rsp), %eax
jg 0x2f24
cmpl $-0x1, 0x58(%rsp)
jg 0x2f24
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x29(%rsp)
je 0x2ee0
xorl %edi, %edi
movl $0x3, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x29(%rsp)
movb 0x29(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x28(%rsp)
je 0x2f15
movl 0x58(%rsp), %edi
shll $0x1d, %edi
movl $0x3, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x28(%rsp)
movb 0x28(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x2f29
jmp 0x3699
jmp 0x36c0
cmpl $0x2, 0x5c(%rsp)
jne 0x3157
movl $0xffffffe0, %eax       # imm = 0xFFFFFFE0
cmpl 0x58(%rsp), %eax
jg 0x2fb8
cmpl $-0x1, 0x58(%rsp)
jg 0x2fb8
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x27(%rsp)
je 0x2f71
movl $0x38000000, %edi       # imm = 0x38000000
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x26(%rsp)
je 0x2fa6
movl 0x58(%rsp), %edi
shll $0x1b, %edi
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x26(%rsp)
movb 0x26(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x3152
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl 0x58(%rsp), %eax
jg 0x303c
cmpl $-0x20, 0x58(%rsp)
jge 0x303c
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x25(%rsp)
je 0x2ff0
movl $0x30000000, %edi       # imm = 0x30000000
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x25(%rsp)
movb 0x25(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x24(%rsp)
je 0x302a
movl 0x58(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x24(%rsp)
movb 0x24(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x3150
movl $0xfffffe00, %eax       # imm = 0xFFFFFE00
cmpl 0x58(%rsp), %eax
jg 0x30c3
cmpl $0xffffff00, 0x58(%rsp) # imm = 0xFFFFFF00
jge 0x30c3
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x23(%rsp)
je 0x3077
movl $0x28000000, %edi       # imm = 0x28000000
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x23(%rsp)
movb 0x23(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x22(%rsp)
je 0x30b1
movl 0x58(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x22(%rsp)
movb 0x22(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x314e
movl $0xfffffd00, %eax       # imm = 0xFFFFFD00
cmpl 0x58(%rsp), %eax
jg 0x3147
cmpl $0xfffffe00, 0x58(%rsp) # imm = 0xFFFFFE00
jge 0x3147
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x21(%rsp)
je 0x30fe
movl $0x20000000, %edi       # imm = 0x20000000
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x21(%rsp)
movb 0x21(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x20(%rsp)
je 0x3138
movl 0x58(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x20(%rsp)
movb 0x20(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x314c
jmp 0x3699
jmp 0x314e
jmp 0x3150
jmp 0x3152
jmp 0x36be
movl $0x3, %eax
cmpl 0x5c(%rsp), %eax
jg 0x3697
cmpl $0xeff, 0x5c(%rsp)      # imm = 0xEFF
jg 0x3697
movl $0xffff0000, %eax       # imm = 0xFFFF0000
cmpl 0x58(%rsp), %eax
jg 0x3697
cmpl $-0x1, 0x58(%rsp)
jg 0x3697
cmpl $0xfffffe00, 0x58(%rsp) # imm = 0xFFFFFE00
jge 0x3250
movl $0x400, 0x50(%rsp)      # imm = 0x400
movl $0x2, 0x4c(%rsp)
xorl %eax, %eax
subl 0x58(%rsp), %eax
cmpl 0x50(%rsp), %eax
jbe 0x31cf
movl 0x50(%rsp), %eax
shll %eax
movl %eax, 0x50(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x31ac
jmp 0x31d1
movl 0x4c(%rsp), %eax
cmpl 0x40(%rsp), %eax
jbe 0x324e
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x1f(%rsp)
je 0x3201
movl $0x30000000, %edi       # imm = 0x30000000
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x1e(%rsp)
je 0x3234
movl $0xfe, %edi
movl $0x2, %esi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x31d1
jmp 0x3250
cmpl $0xf, 0x5c(%rsp)
jg 0x3361
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x1d(%rsp)
je 0x327e
xorl %edi, %edi
movl $0x1, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x1d(%rsp)
movb 0x1d(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
cmpl $0x3, 0x5c(%rsp)
jne 0x32ca
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x1c(%rsp)
je 0x32b8
movl $0x80000000, %edi       # imm = 0x80000000
movl $0x2, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x1c(%rsp)
movb 0x1c(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x335c
movl 0x5c(%rsp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, 0x4c(%rsp)
movl 0x5c(%rsp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %edx, 0x50(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x1b(%rsp)
je 0x3311
movl 0x4c(%rsp), %esi
shll %esi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x1b(%rsp)
movb 0x1b(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
cmpl $0xf, 0x5c(%rsp)
je 0x335a
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x1a(%rsp)
je 0x334d
movl 0x50(%rsp), %edi
shll $0x1e, %edi
movl $0x2, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x1a(%rsp)
movb 0x1a(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x335c
jmp 0x3479
cmpl $0x7f, 0x5c(%rsp)
jg 0x33d5
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x19(%rsp)
je 0x338e
movl $0x60000000, %edi       # imm = 0x60000000
movl $0x7, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x19(%rsp)
movb 0x19(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x18(%rsp)
je 0x33c3
movl 0x5c(%rsp), %edi
shll $0x19, %edi
movl $0x7, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x18(%rsp)
movb 0x18(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x3477
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x17(%rsp)
je 0x33fb
movl $0x60000000, %edi       # imm = 0x60000000
movl $0x7, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x16(%rsp)
je 0x3430
movl 0x5c(%rsp), %edi
shll $0x11, %edi
movl $0x7, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x16(%rsp)
movb 0x16(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x15(%rsp)
je 0x346a
movl 0x5c(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x15(%rsp)
movb 0x15(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x3479
movl $0xffffffe0, %eax       # imm = 0xFFFFFFE0
cmpl 0x58(%rsp), %eax
jg 0x34f1
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x14(%rsp)
je 0x34aa
movl $0x80000000, %edi       # imm = 0x80000000
movl $0x2, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x14(%rsp)
movb 0x14(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x13(%rsp)
je 0x34df
movl 0x58(%rsp), %edi
shll $0x1b, %edi
movl $0x5, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x3695
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl 0x58(%rsp), %eax
jg 0x356e
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x12(%rsp)
je 0x3522
movl $0x40000000, %edi       # imm = 0x40000000
movl $0x2, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x12(%rsp)
movb 0x12(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x11(%rsp)
je 0x355c
movl 0x58(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0x11(%rsp)
movb 0x11(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x3693
movl $0xfffffe00, %eax       # imm = 0xFFFFFE00
cmpl 0x58(%rsp), %eax
jg 0x35e8
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x10(%rsp)
je 0x359c
xorl %edi, %edi
movl $0x2, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0x10(%rsp)
movb 0x10(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0xf(%rsp)
je 0x35d6
movl 0x58(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x3691
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0xe(%rsp)
je 0x360e
movl $0xc0000000, %edi       # imm = 0xC0000000
movl $0x2, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0xd(%rsp)
je 0x364a
movl 0x58(%rsp), %edi
movl $0x18, %ecx
subl 0x40(%rsp), %ecx
shll %cl, %edi
movl 0x40(%rsp), %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0xd(%rsp)
movb 0xd(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0xc(%rsp)
je 0x3684
movl 0x58(%rsp), %eax
andl $0xff, %eax
movl $0x2, %esi
movzbl %al, %edi
callq 0x1b30
cmpl $0x0, %eax
setne %al
movb %al, 0xc(%rsp)
movb 0xc(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
jmp 0x3693
jmp 0x3695
jmp 0x36bc
jmp 0x3699
movl 0x5c(%rsp), %esi
movl 0x58(%rsp), %edx
leaq 0x5ba9(%rip), %rdi      # 0x9251
movb $0x0, %al
callq 0x1040
movl $0x0, 0x74(%rsp)
jmp 0x37b2
jmp 0x36be
jmp 0x36c0
jmp 0x36c2
jmp 0x36c4
jmp 0x36c6
movl 0x54(%rsp), %eax
cmpl 0x58(%rsp), %eax
jle 0x36d8
movl 0x58(%rsp), %eax
movl %eax, 0x54(%rsp)
cmpl $0x0, 0x5c(%rsp)
jle 0x36ed
movl 0x5c(%rsp), %eax
addl 0x60(%rsp), %eax
movl %eax, 0x60(%rsp)
jmp 0x36fb
movl 0x5c(%rsp), %ecx
movl 0x60(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x60(%rsp)
jmp 0x2a0b
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0xb(%rsp)
je 0x3726
movl $0x603c0000, %edi       # imm = 0x603C0000
movl $0xe, %esi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0xa(%rsp)
je 0x3753
xorl %esi, %esi
movl %esi, %edi
callq 0x1ce0
cmpl $0x0, %eax
setne %al
movb %al, 0xa(%rsp)
movb 0xa(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x48(%rsp)
movb %al, 0x9(%rsp)
je 0x3782
xorl %eax, %eax
movl %eax, %edi
xorl %esi, %esi
callq 0x1950
cmpl $0x0, %eax
setne %al
movb %al, 0x9(%rsp)
movb 0x9(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x48(%rsp)
cmpl $0x0, 0x48(%rsp)
je 0x37aa
xorl %esi, %esi
subl 0x54(%rsp), %esi
leaq 0x592f(%rip), %rdi      # 0x90d2
movb $0x0, %al
callq 0x1040
movl 0x48(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax,%rax)