// File: qhan1028[P]JPEG-Decoder/jpeg-decoder.cpp
// Function: process_scan(std::basic_ifstream<char, std::char_traits<char>>&, unsigned char**, sof&, std::map<std::pair<unsigned char, unsigned short>, unsigned char, std::less<std::pair<unsigned char, unsigned short>>, std::allocator<std::pair<std::pair<unsigned char, unsigned short> const, unsigned char>>>*, sos&)
image_t process_scan(ifstream& jpegfile, qtable_t qtable, sof_t& sof, htable_t* htable, sos_t& sos) {
    if (debug) {
        cout << "[Process Scan]" << endl;
        cout << "  get index" << endl;
    }

    /* get number of blocks in MCU, get start px and py of each block */
    unsigned int n_blocks = 0, ci = 0;
    vector<unsigned int> cid(n_blocks); // channel ids for each blocks in 1 MCU
    vector<block_sxy_t> b_sxy(n_blocks); // start index of blocks of each channel in 1 MCU

    for (unsigned int i = 1; i < sof.N; i++) { // id starts from 1
        n_blocks += sof.hvq[i].H * sof.hvq[i].V;

        cid.resize(n_blocks); // extend cid
        b_sxy.resize(n_blocks); // extend b_sxy
        unsigned int sci = ci; // start of current ci
        while(ci < n_blocks) {
            cid[ci] = i;
            b_sxy[ci].stx = ((ci - sci) % sof.hvq[i].H) * 8;
            b_sxy[ci].sty = ((ci - sci) / sof.hvq[i].H) * 8;
            b_sxy[ci].sdx = sof.hmax / sof.hvq[i].H;
            b_sxy[ci].sdy = sof.vmax / sof.hvq[i].V;
            ci++;
        }
    }

    unsigned int x_blocks = sof.hmax;
    unsigned int y_blocks = sof.vmax;
    unsigned int block_w = 8;
    unsigned int block_h = 8;

    /* get number of MCUs in this image */
    unsigned int MCU_w = sof.hmax * 8;
    unsigned int MCU_h = sof.vmax * 8;
    unsigned int x_MCUs = (sof.X - 1) / (MCU_w) + 1;
    unsigned int y_MCUs = (sof.Y - 1) / (MCU_h) + 1;
    unsigned int n_MCUs = x_MCUs * y_MCUs;

    if (debug) {
        cout << "  blocks in MCU = " << n_blocks << endl;
        cout << "  x MCUs = " << x_MCUs << endl;
        cout << "  y MCUs = " << y_MCUs << endl;
        cout << "  total MCUs = " << n_MCUs << endl;
        cout << "  read image..." << endl;
    }

    /* init image and buffer */
    image_t image = init_image(n_MCUs, n_blocks, 64);
    buffer_t buffer;

    /* prev dc, init to 0, index start from 1 */
    vector<uint16_t> prev_dc(sof.N, 0);

    /* read image */
    for (unsigned int i = 0; i < n_MCUs; i++) {
        for (unsigned int j = 0; j < n_blocks; j++) {

            bool end_of_block = false;

            /* qtable id, dc table id, ac table id */
            unsigned int qid = sof.hvq[cid[j]].Q;
            unsigned int dc = sos.cda[cid[j]].td;
            unsigned int ac = 2 + sos.cda[cid[j]].ta;

            for (unsigned int k = 0; k < 64; k++) {

                /* if end of block, then fill 0 until end */
                if (end_of_block) {
                    while (k < 64) {
                        image[i][j][k] = 0;
                        k++;
                    }
                    break;
                }

                /* get h table id */
                unsigned int hid = (k == 0) ? dc : ac;

                /* read bits and check htable */
                bool get_hkey = false;
                uint8_t len = 0;
                uint16_t symbol = 0;
                uint8_t code = 0;
                htable_t::iterator iter;
                do {
                    symbol = symbol << 1; // left shift 1 bit
                    symbol = symbol | read_bits(jpegfile, buffer, prev_dc, 1, true);
                    len += 1;

                    /* search from h table with length and symbol */
                    iter = htable[hid].find(hkey_t(len, symbol));
                    if (iter != htable[hid].end()) {
                        get_hkey = true;
                        code = iter->second;
                        //cout << "len = " << (int)len << ", symbol = " << symbol << ", code = " << (uint)code << endl;
                    }
                } while (!get_hkey);

                if (k == 0) {
                    int16_t delta = read_bits(jpegfile, buffer, prev_dc, code, false);
                    image[i][j][k] = prev_dc[cid[j]] + delta;
                    prev_dc[cid[j]] = image[i][j][k];

                    image[i][j][k] = image[i][j][k] * qtable[qid][k];

                } else {
                    if (code == 0x00) {
                        /* end of block */
                        image[i][j][k] = 0;
                        end_of_block = true;

                    } else {
                        /* run length coding */
                        uint8_t n_zeros = code >> 4;
                        uint8_t value = code & 0x0F;

                        k += n_zeros;
                        //cout << k << ", " << (int)n_zeros << ", " << (int)value << endl;

                        image[i][j][k] = read_bits(jpegfile, buffer, prev_dc, value, false);
                        image[i][j][k] = image[i][j][k] * qtable[qid][k];
                    }
                }
            }
            

            /* reverse zig-zag */
            int16_t uzz_block[64]; // un-zig-zagged block

            for (int k = 0; k < 64; k++) {
                uzz_block[k] = image[i][j][zzi[k]];
            }

            /* fast inverse discrete cosine transform */
            for (int r = 0; r < 8; r++) {
                fast_idct(uzz_block, r, true);
            }
            for (int c = 0; c < 8; c++) {
                fast_idct(uzz_block, c, false);
            }

            /* assign back to image */
            for (int k = 0; k < 64; k++) {
                image[i][j][k] = uzz_block[k];
            }
        }
    }

    if (debug) {
        cout << "  MCUs to YCbCr" << endl;
    }

    /* convert MCUs to YCbCr pixels */
    unsigned int channels = sos.ns;
    unsigned int height = MCU_h * y_MCUs;
    unsigned int width = MCU_w * x_MCUs;
    
    image_t ycbcr = init_image(channels, height, width);

    for (unsigned int i = 0; i < n_MCUs; i++) {
        /* find top left coord of MCU */
        unsigned int mcu_sx = (i % x_MCUs) * MCU_w;
        unsigned int mcu_sy = ((int)(i / x_MCUs)) * MCU_h;

        for (unsigned int j = 0; j < n_blocks; j++) {
            /* top left coord of block */
            unsigned int b_sx = mcu_sx + b_sxy[j].stx;
            unsigned int b_sy = mcu_sy + b_sxy[j].sty;

            /* channel */
            unsigned int c = cid[j] - 1; // channel id start from 1

            /* stride y */
            for (unsigned int sdy = 0; sdy < b_sxy[j].sdy; sdy++) {
                
                /* stride x */
                for (unsigned int sdx = 0; sdx < b_sxy[j].sdx; sdx++) {
                    
                    /* block */
                    for (unsigned int k = 0; k < 64; k++) {
                        /* find coord */
                        unsigned int px = b_sx + ((k % 8) * b_sxy[j].sdx + sdx);
                        unsigned int py = b_sy + ((k / 8) * b_sxy[j].sdy + sdy);

                        ycbcr[c][py][px] = image[i][j][k];
                    }
                }
            }
        }
    }

    /* free memory of image */
    delete_image(image, n_MCUs, n_blocks, 64);

    if (debug) {
        cout << "  YCbCr to RGB" << endl;
    }

    /* convert YCbCr to RGB */
    image_t rgb = init_image(channels, sof.Y, sof.X);

    for (int py = 0; py < sof.Y; py++) {
        for (int px = 0; px < sof.X; px++) {
            int16_t y = ycbcr[0][py][px];
            int16_t cb = ycbcr[1][py][px];
            int16_t cr = ycbcr[2][py][px];

            int16_t r = y + (int16_t)(1.402 * cr) + 128;
            int16_t g = y - (int16_t)(0.34414 * cb) - (int16_t)(0.71414 * cr) + 128;
            int16_t b = y + (int16_t)(1.772 * cb) + 128;

            rgb[R][py][px] = (r < 0) ? 0 : (r > 255) ? 255 : r;
            rgb[G][py][px] = (g < 0) ? 0 : (g > 255) ? 255 : g;
            rgb[B][py][px] = (b < 0) ? 0 : (b > 255) ? 255 : b;
        }
    }

    /* free memory of YCbCr */
    delete_image(ycbcr, channels, height, width);

    if (debug) {
        string rgb_str[3] = {"Red", "Green", "Blue"};

        for (int c = 0; c < 3; c++) {
            cout << "  " << rgb_str[c] << endl;

            for (int py = 0; py < 16; py++) {
                cout << "    ";

                for (int px = 0; px < 16; px++) {
                    printf("%3d ", rgb[0][py][px]);
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    
    return rgb;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
testb $0x1, 0xbd94(%rip)      # 0x1021a
je 0x44cc
movq 0xbb41(%rip), %rdi      # 0xffd0
leaq 0x6dd7(%rip), %rsi      # 0xb26d
callq 0x21b0
movq %rax, %rdi
movq 0xbb1b(%rip), %rsi      # 0xffc0
callq 0x21f0
movq 0xbb1f(%rip), %rdi      # 0xffd0
leaq 0x6dc4(%rip), %rsi      # 0xb27c
callq 0x21b0
movq %rax, %rdi
movq 0xbaf9(%rip), %rsi      # 0xffc0
callq 0x21f0
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x2c(%rbp), %eax
movq %rax, -0x2b8(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x6a00
movq -0x2b8(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x6a20
jmp 0x450d
leaq -0x49(%rbp), %rdi
callq 0x6a90
movl -0x2c(%rbp), %eax
movq %rax, -0x2c8(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x6ab0
movq -0x2c8(%rbp), %rsi
movq -0x2c0(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0x6ad0
jmp 0x4549
leaq -0x79(%rbp), %rdi
callq 0x6b40
movl $0x1, -0x80(%rbp)
movl -0x80(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x4733
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x80(%rbp), %ecx
leaq (%rcx,%rcx,2), %rdx
movl (%rax,%rdx,4), %ecx
movl 0x4(%rax,%rdx,4), %eax
imull %eax, %ecx
movl -0x2c(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x6b60
jmp 0x459a
movl -0x2c(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6bf0
jmp 0x45aa
movl -0x30(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x4723
movl -0x80(%rbp), %eax
movl %eax, -0x2dc(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x6c80
movl -0x2dc(%rbp), %ecx
movl %ecx, (%rax)
movl -0x30(%rbp), %eax
subl -0x84(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x80(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
xorl %edx, %edx
divl (%rcx)
shll $0x3, %edx
movl %edx, -0x2d8(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movl -0x2d8(%rbp), %edx
movl %edx, (%rax)
movl -0x30(%rbp), %eax
subl -0x84(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x80(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
xorl %edx, %edx
divl (%rcx)
shll $0x3, %eax
movl %eax, -0x2d4(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movl -0x2d4(%rbp), %ecx
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x80(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
xorl %edx, %edx
divl (%rcx)
movl %eax, -0x2d0(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movl -0x2d0(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x80(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
xorl %edx, %edx
divl 0x4(%rcx)
movl %eax, -0x2cc(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movl -0x2cc(%rbp), %ecx
movl %ecx, 0xc(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x45b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x6a90
jmp 0x5bc8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x6b40
jmp 0x5bbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5bb6
jmp 0x4725
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x4559
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x8c(%rbp)
movl $0x8, -0x90(%rbp)
movl $0x8, -0x94(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
shll $0x3, %eax
movl %eax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %eax
shll $0x3, %eax
movl %eax, -0x9c(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
xorl %edx, %edx
divl -0x98(%rbp)
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
xorl %edx, %edx
divl -0x9c(%rbp)
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
movl -0xa0(%rbp), %eax
imull -0xa4(%rbp), %eax
movl %eax, -0xa8(%rbp)
testb $0x1, 0xba49(%rip)      # 0x1021a
je 0x4937
movq 0xb7f2(%rip), %rdi      # 0xffd0
leaq 0x6aa3(%rip), %rsi      # 0xb288
callq 0x21b0
movq %rax, -0x2e8(%rbp)
jmp 0x47f3
movq -0x2e8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x2260
movq %rax, -0x2f0(%rbp)
jmp 0x480b
movq -0x2f0(%rbp), %rdi
movq 0xb7a7(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x4820
movq 0xb7a9(%rip), %rdi      # 0xffd0
leaq 0x6a6d(%rip), %rsi      # 0xb29b
callq 0x21b0
movq %rax, -0x2f8(%rbp)
jmp 0x483c
movq -0x2f8(%rbp), %rdi
movl -0xa0(%rbp), %esi
callq 0x2260
movq %rax, -0x300(%rbp)
jmp 0x4857
movq -0x300(%rbp), %rdi
movq 0xb75b(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x486c
movq 0xb75d(%rip), %rdi      # 0xffd0
leaq 0x6a2d(%rip), %rsi      # 0xb2a7
callq 0x21b0
movq %rax, -0x308(%rbp)
jmp 0x4888
movq -0x308(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0x2260
movq %rax, -0x310(%rbp)
jmp 0x48a3
movq -0x310(%rbp), %rdi
movq 0xb70f(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x48b8
movq 0xb711(%rip), %rdi      # 0xffd0
leaq 0x69ed(%rip), %rsi      # 0xb2b3
callq 0x21b0
movq %rax, -0x318(%rbp)
jmp 0x48d4
movq -0x318(%rbp), %rdi
movl -0xa8(%rbp), %esi
callq 0x2260
movq %rax, -0x320(%rbp)
jmp 0x48ef
movq -0x320(%rbp), %rdi
movq 0xb6c3(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x4904
movq 0xb6c5(%rip), %rdi      # 0xffd0
leaq 0x69b1(%rip), %rsi      # 0xb2c3
callq 0x21b0
movq %rax, -0x328(%rbp)
jmp 0x4920
movq -0x328(%rbp), %rdi
movq 0xb692(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x4935
jmp 0x4937
movl -0xa8(%rbp), %edi
movl -0x2c(%rbp), %esi
movl $0x40, %edx
callq 0x4100
movq %rax, -0x330(%rbp)
jmp 0x4953
movq -0x330(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0xbc(%rbp), %rdi
callq 0x6cc0
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movq %rax, -0x340(%rbp)
movw $0x0, -0xda(%rbp)
leaq -0xdb(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x6ce0
movq -0x340(%rbp), %rsi
movq -0x338(%rbp), %rcx
leaq -0xd8(%rbp), %rdi
leaq -0xda(%rbp), %rdx
callq 0x6d00
jmp 0x49ba
leaq -0xdb(%rbp), %rdi
callq 0x6d80
movl $0x0, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
cmpl -0xa8(%rbp), %eax
jae 0x50e0
movl $0x0, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x50ca
movb $0x0, -0xe5(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x358(%rbp)
movl -0xe4(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x6c80
movq %rax, %rcx
movq -0x358(%rbp), %rax
movl (%rcx), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0xec(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x350(%rbp)
movl -0xe4(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x6c80
movq %rax, %rcx
movq -0x350(%rbp), %rax
movl (%rcx), %ecx
movl (%rax,%rcx,8), %eax
movl %eax, -0xf0(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x348(%rbp)
movl -0xe4(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x6c80
movq %rax, %rcx
movq -0x348(%rbp), %rax
movl (%rcx), %ecx
movl 0x4(%rax,%rcx,8), %eax
addl $0x2, %eax
movl %eax, -0xf4(%rbp)
movl $0x0, -0xf8(%rbp)
cmpl $0x40, -0xf8(%rbp)
jae 0x4f84
testb $0x1, -0xe5(%rbp)
je 0x4b31
jmp 0x4ace
cmpl $0x40, -0xf8(%rbp)
jae 0x4b2c
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movw $0x0, (%rax,%rcx,2)
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x4ace
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xdb(%rbp), %rdi
callq 0x6d80
jmp 0x5bb6
jmp 0x4f84
cmpl $0x0, -0xf8(%rbp)
jne 0x4b48
movl -0xf0(%rbp), %eax
movl %eax, -0x35c(%rbp)
jmp 0x4b54
movl -0xf4(%rbp), %eax
movl %eax, -0x35c(%rbp)
movl -0x35c(%rbp), %eax
movl %eax, -0xfc(%rbp)
movb $0x0, -0xfd(%rbp)
movb $0x0, -0xfe(%rbp)
movw $0x0, -0x100(%rbp)
movb $0x0, -0x101(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x6280
movzwl -0x100(%rbp), %eax
addl %eax, %eax
movw %ax, -0x100(%rbp)
movzwl -0x100(%rbp), %eax
movl %eax, -0x364(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xbc(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
movl $0x1, %r8d
movl %r8d, %ecx
callq 0x2550
movw %ax, -0x35e(%rbp)
jmp 0x4bd0
movl -0x364(%rbp), %eax
movw -0x35e(%rbp), %dx
movw %dx, %cx
orl %ecx, %eax
movw %ax, -0x100(%rbp)
movb -0xfe(%rbp), %al
incb %al
movb %al, -0xfe(%rbp)
movq -0x20(%rbp), %rax
movl -0xfc(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x370(%rbp)
leaq -0x11c(%rbp), %rdi
leaq -0xfe(%rbp), %rsi
leaq -0x100(%rbp), %rdx
callq 0x6dd0
jmp 0x4c2f
movq -0x370(%rbp), %rdi
leaq -0x11c(%rbp), %rsi
callq 0x6da0
movq %rax, -0x378(%rbp)
jmp 0x4c4b
movq -0x378(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x20(%rbp), %rdi
movl -0xfc(%rbp), %eax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x6300
movq %rax, -0x128(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x62d0
testb $0x1, %al
jne 0x4c9d
jmp 0x4ccc
movb $0x1, -0xfd(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x6330
movb 0x4(%rax), %al
movb %al, -0x101(%rbp)
jmp 0x4ccc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5baa
jmp 0x4cce
movb -0xfd(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4b8a
cmpl $0x0, -0xf8(%rbp)
jne 0x4e3c
movq -0x8(%rbp), %rdi
movzbl -0x101(%rbp), %ecx
leaq -0xbc(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
xorl %r8d, %r8d
callq 0x2550
movw %ax, -0x37a(%rbp)
jmp 0x4d15
movw -0x37a(%rbp), %ax
movw %ax, -0x12a(%rbp)
movl -0xe4(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x6c80
movl (%rax), %eax
movl %eax, %esi
leaq -0xd8(%rbp), %rdi
callq 0x6240
movzwl (%rax), %eax
movswl -0x12a(%rbp), %ecx
addl %ecx, %eax
movw %ax, %dx
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movw (%rax,%rcx,2), %ax
movw %ax, -0x37c(%rbp)
movl -0xe4(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x6c80
movl (%rax), %eax
movl %eax, %esi
leaq -0xd8(%rbp), %rdi
callq 0x6240
movw -0x37c(%rbp), %cx
movw %cx, (%rax)
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movswl (%rax,%rcx,2), %eax
movq -0x10(%rbp), %rcx
movl -0xec(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movl -0xf8(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
imull %ecx, %eax
movw %ax, %dx
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
jmp 0x4f6e
movzbl -0x101(%rbp), %eax
cmpl $0x0, %eax
jne 0x4e7b
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movw $0x0, (%rax,%rcx,2)
movb $0x1, -0xe5(%rbp)
jmp 0x4f6c
movzbl -0x101(%rbp), %eax
shrl $0x4, %eax
movb %al, -0x12b(%rbp)
movb -0x101(%rbp), %al
andb $0xf, %al
movb %al, -0x12c(%rbp)
movzbl -0x12b(%rbp), %ecx
movl -0xf8(%rbp), %eax
addl %ecx, %eax
movl %eax, -0xf8(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x12c(%rbp), %ecx
leaq -0xbc(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
xorl %r8d, %r8d
callq 0x2550
movw %ax, -0x37e(%rbp)
jmp 0x4ed8
movw -0x37e(%rbp), %dx
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movswl (%rax,%rcx,2), %eax
movq -0x10(%rbp), %rcx
movl -0xec(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movl -0xf8(%rbp), %edx
movzbl (%rcx,%rdx), %ecx
imull %ecx, %eax
movw %ax, %dx
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xf8(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
jmp 0x4f6e
jmp 0x4f70
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0x4ab6
movl $0x0, -0x1b4(%rbp)
cmpl $0x40, -0x1b4(%rbp)
jge 0x4fe8
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movslq -0x1b4(%rbp), %rdx
leaq 0xb210(%rip), %rcx      # 0x101d0
movzbl (%rcx,%rdx), %ecx
movw (%rax,%rcx,2), %cx
movslq -0x1b4(%rbp), %rax
movw %cx, -0x1b0(%rbp,%rax,2)
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0x4f8e
movl $0x0, -0x1b8(%rbp)
cmpl $0x8, -0x1b8(%rbp)
jge 0x5023
leaq -0x1b0(%rbp), %rdi
movl -0x1b8(%rbp), %esi
movl $0x1, %edx
callq 0x2760
movl -0x1b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b8(%rbp)
jmp 0x4ff2
movl $0x0, -0x1bc(%rbp)
cmpl $0x8, -0x1bc(%rbp)
jge 0x505b
leaq -0x1b0(%rbp), %rdi
movl -0x1bc(%rbp), %esi
xorl %edx, %edx
callq 0x2760
movl -0x1bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1bc(%rbp)
jmp 0x502d
movl $0x0, -0x1c0(%rbp)
cmpl $0x40, -0x1c0(%rbp)
jge 0x50b4
movslq -0x1c0(%rbp), %rax
movw -0x1b0(%rbp,%rax,2), %dx
movq -0xb0(%rbp), %rax
movl -0xe0(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0xe4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movslq -0x1c0(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x1c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c0(%rbp)
jmp 0x5065
jmp 0x50b6
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x49ec
jmp 0x50cc
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0x49d0
testb $0x1, 0xb133(%rip)      # 0x1021a
je 0x511c
movq 0xaee0(%rip), %rdi      # 0xffd0
leaq 0x61dc(%rip), %rsi      # 0xb2d3
callq 0x21b0
movq %rax, -0x388(%rbp)
jmp 0x5105
movq -0x388(%rbp), %rdi
movq 0xaead(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x511a
jmp 0x511c
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c4(%rbp)
movl -0x9c(%rbp), %eax
movl -0xa4(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x1c8(%rbp)
movl -0x98(%rbp), %eax
movl -0xa0(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x1cc(%rbp)
movl -0x1c4(%rbp), %edi
movl -0x1c8(%rbp), %esi
movl -0x1cc(%rbp), %edx
callq 0x4100
movq %rax, -0x390(%rbp)
jmp 0x5172
movq -0x390(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movl $0x0, -0x1dc(%rbp)
movl -0x1dc(%rbp), %eax
cmpl -0xa8(%rbp), %eax
jae 0x543d
movl -0x1dc(%rbp), %eax
xorl %edx, %edx
divl -0xa0(%rbp)
imull -0x98(%rbp), %edx
movl %edx, -0x1e0(%rbp)
movl -0x1dc(%rbp), %eax
xorl %edx, %edx
divl -0xa0(%rbp)
imull -0x9c(%rbp), %eax
movl %eax, -0x1e4(%rbp)
movl $0x0, -0x1e8(%rbp)
movl -0x1e8(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x5427
movl -0x1e0(%rbp), %eax
movl %eax, -0x398(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movq %rax, %rcx
movl -0x398(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x1ec(%rbp)
movl -0x1e4(%rbp), %eax
movl %eax, -0x394(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movq %rax, %rcx
movl -0x394(%rbp), %eax
addl 0x4(%rcx), %eax
movl %eax, -0x1f0(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x6c80
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x1f4(%rbp)
movl $0x0, -0x1f8(%rbp)
movl -0x1f8(%rbp), %eax
movl %eax, -0x39c(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movq %rax, %rcx
movl -0x39c(%rbp), %eax
cmpl 0xc(%rcx), %eax
jae 0x5411
movl $0x0, -0x1fc(%rbp)
movl -0x1fc(%rbp), %eax
movl %eax, -0x3a0(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movq %rax, %rcx
movl -0x3a0(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x53fb
movl $0x0, -0x200(%rbp)
cmpl $0x40, -0x200(%rbp)
jae 0x53e5
movl -0x1ec(%rbp), %eax
movl %eax, -0x3ac(%rbp)
movl -0x200(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x3b0(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movl -0x3b0(%rbp), %ecx
movq %rax, %rdx
movl -0x3ac(%rbp), %eax
imull 0x8(%rdx), %ecx
addl -0x1fc(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x204(%rbp)
movl -0x1f0(%rbp), %eax
movl %eax, -0x3a4(%rbp)
movl -0x200(%rbp), %eax
shrl $0x3, %eax
movl %eax, -0x3a8(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
callq 0x6ca0
movl -0x3a8(%rbp), %ecx
movq %rax, %rdx
movl -0x3a4(%rbp), %eax
imull 0xc(%rdx), %ecx
addl -0x1f8(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x208(%rbp)
movq -0xb0(%rbp), %rax
movl -0x1dc(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0x1e8(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0x200(%rbp), %ecx
movw (%rax,%rcx,2), %dx
movq -0x1d8(%rbp), %rax
movl -0x1f4(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0x208(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0x204(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movl -0x200(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x200(%rbp)
jmp 0x52e0
jmp 0x53e7
movl -0x1fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1fc(%rbp)
jmp 0x52a7
jmp 0x53fd
movl -0x1f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f8(%rbp)
jmp 0x526e
jmp 0x5413
movl -0x1e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e8(%rbp)
jmp 0x51dc
jmp 0x5429
movl -0x1dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1dc(%rbp)
jmp 0x518a
movq -0xb0(%rbp), %rdi
movl -0xa8(%rbp), %esi
movl -0x2c(%rbp), %edx
movl $0x40, %ecx
callq 0x4200
testb $0x1, 0xadbc(%rip)      # 0x1021a
je 0x5493
movq 0xab69(%rip), %rdi      # 0xffd0
leaq 0x5e75(%rip), %rsi      # 0xb2e3
callq 0x21b0
movq %rax, -0x3b8(%rbp)
jmp 0x547c
movq -0x3b8(%rbp), %rdi
movq 0xab36(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x5491
jmp 0x5493
movl -0x1c4(%rbp), %edi
movq -0x18(%rbp), %rax
movl 0x4(%rax), %esi
movl 0x8(%rax), %edx
callq 0x4100
movq %rax, -0x3c0(%rbp)
jmp 0x54b1
movq -0x3c0(%rbp), %rax
movq %rax, -0x210(%rbp)
movl $0x0, -0x214(%rbp)
movl -0x214(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x57a7
movl $0x0, -0x218(%rbp)
movl -0x218(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x5791
movq -0x1d8(%rbp), %rax
movq (%rax), %rax
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x218(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movw %ax, -0x21a(%rbp)
movq -0x1d8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x218(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movw %ax, -0x21c(%rbp)
movq -0x1d8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x218(%rbp), %rcx
movw (%rax,%rcx,2), %ax
movw %ax, -0x21e(%rbp)
movzwl -0x21a(%rbp), %ecx
movswl -0x21e(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd 0x5abe(%rip), %xmm1     # 0xb048
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
movl %ecx, %eax
movl %edx, %ecx
leal 0x80(%rax,%rcx), %eax
movw %ax, -0x220(%rbp)
movzwl -0x21a(%rbp), %eax
movswl -0x21c(%rbp), %ecx
cvtsi2sd %ecx, %xmm0
movsd 0x5a92(%rip), %xmm1     # 0xb050
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
subl %ecx, %eax
movswl -0x21e(%rbp), %ecx
cvtsi2sd %ecx, %xmm0
movsd 0x5a7d(%rip), %xmm1     # 0xb058
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
subl %ecx, %eax
subl $-0x80, %eax
movw %ax, -0x222(%rbp)
movswl -0x21a(%rbp), %eax
movswl -0x21c(%rbp), %ecx
cvtsi2sd %ecx, %xmm0
movsd 0x5a57(%rip), %xmm1     # 0xb060
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movswl %cx, %ecx
addl %ecx, %eax
addl $0x80, %eax
movw %ax, -0x224(%rbp)
movswl -0x220(%rbp), %eax
cmpl $0x0, %eax
jge 0x5638
xorl %eax, %eax
movl %eax, -0x3c4(%rbp)
jmp 0x566c
movswl -0x220(%rbp), %eax
cmpl $0xff, %eax
jle 0x5653
movl $0xff, %eax
movl %eax, -0x3c8(%rbp)
jmp 0x5660
movswl -0x220(%rbp), %eax
movl %eax, -0x3c8(%rbp)
movl -0x3c8(%rbp), %eax
movl %eax, -0x3c4(%rbp)
movl -0x3c4(%rbp), %eax
movw %ax, %dx
movq -0x210(%rbp), %rax
movq (%rax), %rax
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x218(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movswl -0x222(%rbp), %eax
cmpl $0x0, %eax
jge 0x56ab
xorl %eax, %eax
movl %eax, -0x3cc(%rbp)
jmp 0x56df
movswl -0x222(%rbp), %eax
cmpl $0xff, %eax
jle 0x56c6
movl $0xff, %eax
movl %eax, -0x3d0(%rbp)
jmp 0x56d3
movswl -0x222(%rbp), %eax
movl %eax, -0x3d0(%rbp)
movl -0x3d0(%rbp), %eax
movl %eax, -0x3cc(%rbp)
movl -0x3cc(%rbp), %eax
movw %ax, %dx
movq -0x210(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x218(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movswl -0x224(%rbp), %eax
cmpl $0x0, %eax
jge 0x571f
xorl %eax, %eax
movl %eax, -0x3d4(%rbp)
jmp 0x5753
movswl -0x224(%rbp), %eax
cmpl $0xff, %eax
jle 0x573a
movl $0xff, %eax
movl %eax, -0x3d8(%rbp)
jmp 0x5747
movswl -0x224(%rbp), %eax
movl %eax, -0x3d8(%rbp)
movl -0x3d8(%rbp), %eax
movl %eax, -0x3d4(%rbp)
movl -0x3d4(%rbp), %eax
movw %ax, %dx
movq -0x210(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x218(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movl -0x218(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x218(%rbp)
jmp 0x54e6
jmp 0x5793
movl -0x214(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x214(%rbp)
jmp 0x54c9
movq -0x1d8(%rbp), %rdi
movl -0x1c4(%rbp), %esi
movl -0x1c8(%rbp), %edx
movl -0x1cc(%rbp), %ecx
callq 0x4200
testb $0x1, 0xaa4e(%rip)      # 0x1021a
je 0x5b6e
movb $0x1, -0x29c(%rbp)
leaq -0x290(%rbp), %rax
movq %rax, -0x3e8(%rbp)
movq %rax, -0x298(%rbp)
leaq -0x299(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x2350
movq -0x3e8(%rbp), %rdi
movq -0x3e0(%rbp), %rdx
leaq 0x5adc(%rip), %rsi      # 0xb2f2
callq 0x2290
jmp 0x581d
leaq -0x270(%rbp), %rax
movq %rax, -0x3f8(%rbp)
movq %rax, -0x298(%rbp)
leaq -0x29a(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x2350
movq -0x3f8(%rbp), %rdi
movq -0x3f0(%rbp), %rdx
leaq 0x5a9c(%rip), %rsi      # 0xb2f6
callq 0x2290
jmp 0x5861
leaq -0x250(%rbp), %rax
movq %rax, -0x408(%rbp)
movq %rax, -0x298(%rbp)
leaq -0x29b(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x2350
movq -0x408(%rbp), %rdi
movq -0x400(%rbp), %rdx
leaq 0x5a5e(%rip), %rsi      # 0xb2fc
callq 0x2290
jmp 0x58a5
movb $0x0, -0x29c(%rbp)
leaq -0x29b(%rbp), %rdi
callq 0x2200
leaq -0x29a(%rbp), %rdi
callq 0x2200
leaq -0x299(%rbp), %rdi
callq 0x2200
movl $0x0, -0x2a0(%rbp)
cmpl $0x3, -0x2a0(%rbp)
jge 0x5aef
movq 0xa6e2(%rip), %rdi      # 0xffd0
leaq 0x584e(%rip), %rsi      # 0xb143
callq 0x21b0
movq %rax, -0x410(%rbp)
jmp 0x5903
movq -0x410(%rbp), %rdi
movslq -0x2a0(%rbp), %rax
shlq $0x5, %rax
leaq -0x290(%rbp,%rax), %rsi
callq 0x2180
movq %rax, -0x418(%rbp)
jmp 0x592b
movq -0x418(%rbp), %rdi
movq 0xa687(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x5940
movl $0x0, -0x2a4(%rbp)
cmpl $0x10, -0x2a4(%rbp)
jge 0x5ac4
movq 0xa672(%rip), %rdi      # 0xffd0
leaq 0x57dc(%rip), %rsi      # 0xb141
callq 0x21b0
jmp 0x596c
movl $0x0, -0x2a8(%rbp)
cmpl $0x10, -0x2a8(%rbp)
jge 0x5a99
movq -0x210(%rbp), %rax
movq (%rax), %rax
movslq -0x2a4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2a8(%rbp), %rcx
movswl (%rax,%rcx,2), %esi
leaq 0x5957(%rip), %rdi      # 0xb301
xorl %eax, %eax
callq 0x2040
jmp 0x59b3
jmp 0x59b5
movl -0x2a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2a8(%rbp)
jmp 0x5976
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5a06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x59fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x29b(%rbp), %rdi
callq 0x2200
leaq -0x29a(%rbp), %rdi
callq 0x2200
leaq -0x299(%rbp), %rdi
callq 0x2200
testb $0x1, -0x29c(%rbp)
jne 0x5a1d
jmp 0x5a6a
movq -0x298(%rbp), %rax
leaq -0x290(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x420(%rbp)
je 0x5a68
movq -0x420(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x428(%rbp)
callq 0x2120
movq -0x428(%rbp), %rax
leaq -0x290(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x420(%rbp)
jne 0x5a37
jmp 0x5a6a
jmp 0x5baa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x290(%rbp), %rax
movq %rax, -0x438(%rbp)
addq $0x60, %rax
movq %rax, -0x430(%rbp)
jmp 0x5b3b
movq 0xa530(%rip), %rdi      # 0xffd0
movq 0xa519(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x5aae
jmp 0x5ab0
movl -0x2a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2a4(%rbp)
jmp 0x594a
movq 0xa505(%rip), %rdi      # 0xffd0
movq 0xa4ee(%rip), %rsi      # 0xffc0
callq 0x21f0
jmp 0x5ad9
jmp 0x5adb
movl -0x2a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2a0(%rbp)
jmp 0x58da
leaq -0x290(%rbp), %rax
movq %rax, -0x448(%rbp)
addq $0x60, %rax
movq %rax, -0x440(%rbp)
movq -0x440(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x450(%rbp)
callq 0x2120
movq -0x448(%rbp), %rcx
movq -0x450(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x440(%rbp)
jne 0x5b08
jmp 0x5b6e
movq -0x430(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x458(%rbp)
callq 0x2120
movq -0x438(%rbp), %rcx
movq -0x458(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x430(%rbp)
jne 0x5b3b
jmp 0x5baa
movq -0x210(%rbp), %rax
movq %rax, -0x460(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x6e00
leaq -0x78(%rbp), %rdi
callq 0x6e60
leaq -0x48(%rbp), %rdi
callq 0x6ec0
movq -0x460(%rbp), %rax
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
leaq -0xd8(%rbp), %rdi
callq 0x6e00
leaq -0x78(%rbp), %rdi
callq 0x6e60
leaq -0x48(%rbp), %rdi
callq 0x6ec0
movq -0x58(%rbp), %rdi
callq 0x2340
nopw %cs:(%rax,%rax)