// File: rapirent[P]JPEG/encoder.c
// Function: main
int main(int argc, char* argv[])
{
    if (argc != 2  && argc != 3) {
        printf("[ERROR]:\nusage: ./encoder <input_file> [<output_file_name>]");
        exit(1);
    }


    FILE* fp;
    if (argc==3 && (fp = fopen(argv[2], "w")) == NULL) {
        printf("%s can't be opened\n", argv[2]);
        exit(1);
    } else if (argc==2 && (fp = fopen("image.jpg", "w")) == NULL) {
        printf("image.jpeg can't be opened\n");
        exit(1);
    }

    bitmap_image image(argv[1]);
    if (!image) {
        printf("%s can't be opened\n", argv[1]);
        exit(1);
    }

    image_height = image.height();
    image_width  = image.width();
    rgb_image = image;

    byte c;
    c = 0xff;
    fwrite(&c, 1, 1, fp);
    c = SOI;
    fwrite(&c, 1, 1, fp);
    c = 0xff;
    fwrite(&c, 1, 1, fp);
    c = APP0;
    fwrite(&c, 1, 1, fp);
    write_word_to_littleendian(fp, 16);
    char comment[5] = "JFIF";
    fwrite(comment, 1, 5, fp);
    c = 0x01;
    fwrite(&c, 1, 1, fp);
    c = 0x01;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    c = 0x01;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    c = 0x01;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);

    c = 0xff;
    fwrite(&c, 1, 1, fp);
    c = DQT;
    fwrite(&c, 1, 1, fp);
    write_word_to_littleendian(fp, 132);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    for (int i = 0; i<8; i++) {
        for (int j = 0; j<8; j++) {
            zigzag_quantize_table[0][zigzag_index[i][j]] = quantize_table[0][i*8+j];
            zigzag_quantize_table[1][zigzag_index[i][j]] = quantize_table[1][i*8+j];
        }
    }
    for (int i = 0; i<8; i++) {
        for (int j = 0; j<8; j++) {
            fwrite(&(zigzag_quantize_table[0][i*8+j]),1,1,fp);
        }
    }
    c = 0x01;
    fwrite(&c, 1, 1, fp);
    for (int i = 0; i<8; i++) {
        for (int j = 0; j<8; j++) {
            fwrite(&(zigzag_quantize_table[1][i*8+j]),1,1,fp);
        }
    }
    c = 0xff;
    fwrite(&c, 1, 1, fp);
    c = SOF0;
    fwrite(&c, 1, 1, fp);
    write_word_to_littleendian(fp, 17);
    c = 8;
    fwrite(&c, 1, 1, fp);
    write_word_to_littleendian(fp,(word)image_height);
    write_word_to_littleendian(fp,(word)image_width);
    c = 3;
    fwrite(&c, 1, 1, fp);
    c = 1;
    fwrite(&c, 1, 1, fp);
    c = 0x11;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    c = 2;
    fwrite(&c, 1, 1, fp);
    c = 0x11;
    fwrite(&c, 1, 1, fp);
    c = 1;
    fwrite(&c, 1, 1, fp);
    c = 3;
    fwrite(&c, 1, 1, fp);
    c = 0x11;
    fwrite(&c, 1, 1, fp);
    c = 1;
    fwrite(&c, 1, 1, fp);

    c = 0xff;
    fwrite(&c, 1, 1, fp);
    c = DHT;
    fwrite(&c, 1, 1, fp);
    write_word_to_littleendian(fp, 0x01a2);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    fwrite(dc_cof_code_length[0], 1, 16, fp);
    fwrite(dc_cof_value[0], 1, 12, fp);
    c = 0x01;
    fwrite(&c, 1, 1, fp);
    fwrite(dc_cof_code_length[1], 1, 16, fp);
    fwrite(dc_cof_value[1], 1, 12, fp);
    c = 0x10;
    fwrite(&c, 1, 1, fp);
    fwrite(ac_cof_code_length[0], 1, 16, fp);
    fwrite(ac_cof_value[0], 1, 162, fp);
    c = 0x11;
    fwrite(&c, 1, 1, fp);
    fwrite(ac_cof_code_length[1], 1, 16, fp);
    fwrite(ac_cof_value[1], 1, 162, fp);

    c = 0xff;
    fwrite(&c, 1, 1, fp);
    c = SOS;
    fwrite(&c, 1, 1, fp);
    write_word_to_littleendian(fp, 12);
    c = 3;
    fwrite(&c, 1, 1, fp);
    c = 1;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    c = 2;
    fwrite(&c, 1, 1, fp);
    c = 0x11;
    fwrite(&c, 1, 1, fp);
    c = 3;
    fwrite(&c, 1, 1, fp);
    c = 0x11;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);
    c = 0x3f;
    fwrite(&c, 1, 1, fp);
    c = 0x00;
    fwrite(&c, 1, 1, fp);

    init_cos_cache();
    for (int y = 0; y<image_height; y+=8) {
        for (int x = 0; x<image_width; x+=8) {
            calculate_mcu(fp,x,y);
        }
    }
    write_one_bit(fp,0,true);
    c = 0xff;
    fwrite(&c, 1, 1, fp);
    c = EOI;
    fwrite(&c, 1, 1, fp);
    fclose(fp);
    return 0;
}

// Assembly:
subq $0xe8, %rsp
movl $0x0, 0xe4(%rsp)
movl %edi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
cmpl $0x2, 0xe0(%rsp)
je 0x647d
cmpl $0x3, 0xe0(%rsp)
je 0x647d
leaq 0x4470(%rip), %rdi      # 0xa8dc
movb $0x0, %al
callq 0x5040
movl $0x1, %edi
callq 0x5260
cmpl $0x3, 0xe0(%rsp)
jne 0x64d1
movq 0xd8(%rsp), %rax
movq 0x10(%rax), %rdi
leaq 0x447e(%rip), %rsi      # 0xa918
callq 0x5250
movq %rax, 0xd0(%rsp)
cmpq $0x0, %rax
jne 0x64d1
movq 0xd8(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x445a(%rip), %rdi      # 0xa91a
movb $0x0, %al
callq 0x5040
movl $0x1, %edi
callq 0x5260
cmpl $0x2, 0xe0(%rsp)
jne 0x6514
leaq 0x444c(%rip), %rdi      # 0xa92e
leaq 0x442f(%rip), %rsi      # 0xa918
callq 0x5250
movq %rax, 0xd0(%rsp)
cmpq $0x0, %rax
jne 0x6514
leaq 0x4435(%rip), %rdi      # 0xa938
movb $0x0, %al
callq 0x5040
movl $0x1, %edi
callq 0x5260
jmp 0x6516
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0x5f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x5330
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x7200
jmp 0x654c
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x72c0
jmp 0x6560
leaq 0x60(%rsp), %rdi
callq 0x5130
leaq 0x5f(%rsp), %rdi
callq 0x5220
leaq 0x80(%rsp), %rdi
callq 0x7360
movb %al, 0xf(%rsp)
jmp 0x6587
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x6591
jmp 0x660e
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x4376(%rip), %rdi      # 0xa91a
xorl %eax, %eax
callq 0x5040
jmp 0x65ad
movl $0x1, %edi
callq 0x5260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x65df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x5130
leaq 0x5f(%rsp), %rdi
callq 0x5220
jmp 0x70dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x7190
jmp 0x70dd
leaq 0x80(%rsp), %rdi
callq 0x73d0
movl %eax, 0x8(%rsp)
jmp 0x6621
movl 0x8(%rsp), %eax
movl %eax, 0x8c99(%rip)      # 0xf2c4
leaq 0x80(%rsp), %rdi
callq 0x73e0
movl %eax, 0x4(%rsp)
jmp 0x663e
movl 0x4(%rsp), %eax
movl %eax, 0x8c80(%rip)      # 0xf2c8
leaq 0x8d01(%rip), %rdi      # 0xf350
leaq 0x80(%rsp), %rsi
callq 0x73f0
jmp 0x665e
movb $-0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x667f
movb $-0x28, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x66a0
movb $-0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x66c1
movb $-0x20, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x66e2
movq 0xd0(%rsp), %rdi
movl $0x10, %esi
callq 0x5580
jmp 0x66f6
movb $0x0, 0x48(%rsp)
movl $0x4649464a, 0x44(%rsp) # imm = 0x4649464A
movq 0xd0(%rsp), %rcx
leaq 0x44(%rsp), %rdi
movl $0x1, %esi
movl $0x5, %edx
callq 0x5370
jmp 0x6721
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6742
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6763
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6784
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x67a5
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x67c6
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x67e7
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6808
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6829
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x684a
movb $-0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x686b
movb $-0x25, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x688c
movq 0xd0(%rsp), %rdi
movl $0x84, %esi
callq 0x5580
jmp 0x68a0
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x68c1
movl $0x0, 0x40(%rsp)
cmpl $0x8, 0x40(%rsp)
jge 0x6987
movl $0x0, 0x3c(%rsp)
cmpl $0x8, 0x3c(%rsp)
jge 0x6975
movl 0x40(%rsp), %eax
shll $0x3, %eax
addl 0x3c(%rsp), %eax
movslq %eax, %rcx
leaq 0x4264(%rip), %rax      # 0xab60
movb (%rax,%rcx), %dl
movslq 0x40(%rsp), %rcx
leaq 0x42d5(%rip), %rax      # 0xabe0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x3c(%rsp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x89ae(%rip), %rax      # 0xf2d0
movb %dl, (%rax,%rcx)
movl 0x40(%rsp), %eax
shll $0x3, %eax
addl 0x3c(%rsp), %eax
movslq %eax, %rcx
leaq 0x4226(%rip), %rax      # 0xab60
movb 0x40(%rax,%rcx), %dl
movslq 0x40(%rsp), %rcx
leaq 0x4296(%rip), %rax      # 0xabe0
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x3c(%rsp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x896f(%rip), %rax      # 0xf2d0
movb %dl, 0x40(%rax,%rcx)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x68dc
jmp 0x6977
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x68c9
movl $0x0, 0x38(%rsp)
cmpl $0x8, 0x38(%rsp)
jge 0x69f5
movl $0x0, 0x34(%rsp)
cmpl $0x8, 0x34(%rsp)
jge 0x69e6
movl 0x38(%rsp), %eax
movl 0x34(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,8), %eax
cltq
leaq 0x8913(%rip), %rdi      # 0xf2d0
addq %rax, %rdi
movq 0xd0(%rsp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x69d7
jmp 0x69d9
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x699e
jmp 0x69e8
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x698f
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6a16
movl $0x0, 0x30(%rsp)
cmpl $0x8, 0x30(%rsp)
jge 0x6a86
movl $0x0, 0x2c(%rsp)
cmpl $0x8, 0x2c(%rsp)
jge 0x6a77
movl 0x30(%rsp), %eax
movl 0x2c(%rsp), %edx
movl %eax, %ecx
movl %edx, %eax
leal (%rax,%rcx,8), %eax
cltq
leaq 0x8884(%rip), %rcx      # 0xf2d0
leaq 0x40(%rax,%rcx), %rdi
movq 0xd0(%rsp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6a68
jmp 0x6a6a
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x6a2d
jmp 0x6a79
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x6a1e
movb $-0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6aa7
movb $-0x40, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6ac8
movq 0xd0(%rsp), %rdi
movl $0x11, %esi
callq 0x5580
jmp 0x6adc
movb $0x8, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6afd
movq 0xd0(%rsp), %rdi
movzwl 0x87b8(%rip), %esi      # 0xf2c4
callq 0x5580
jmp 0x6b13
movq 0xd0(%rsp), %rdi
movzwl 0x87a6(%rip), %esi      # 0xf2c8
callq 0x5580
jmp 0x6b29
movb $0x3, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6b4a
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6b6b
movb $0x11, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6b8c
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6bad
movb $0x2, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6bce
movb $0x11, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6bef
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6c10
movb $0x3, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6c31
movb $0x11, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6c52
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6c73
movb $-0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6c94
movb $-0x3c, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6cb5
movq 0xd0(%rsp), %rdi
movl $0x1a2, %esi            # imm = 0x1A2
callq 0x5580
jmp 0x6cc9
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6cea
movq 0xd0(%rsp), %rcx
leaq 0x3fe7(%rip), %rdi      # 0xace0
movl $0x1, %esi
movl $0x10, %edx
callq 0x5370
jmp 0x6d0a
movq 0xd0(%rsp), %rcx
leaq 0x3fe7(%rip), %rdi      # 0xad00
movl $0x1, %esi
movl $0xc, %edx
callq 0x5370
jmp 0x6d2a
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6d4b
movq 0xd0(%rsp), %rcx
leaq 0x3f96(%rip), %rdi      # 0xacf0
movl $0x1, %esi
movl $0x10, %edx
callq 0x5370
jmp 0x6d6b
movq 0xd0(%rsp), %rcx
leaq 0x3f92(%rip), %rdi      # 0xad0c
movl $0x1, %esi
movl $0xc, %edx
callq 0x5370
jmp 0x6d8b
movb $0x10, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6dac
movq 0xd0(%rsp), %rcx
leaq 0x3f65(%rip), %rdi      # 0xad20
movl $0x1, %esi
movl $0x10, %edx
callq 0x5370
jmp 0x6dcc
movq 0xd0(%rsp), %rcx
leaq 0x3f65(%rip), %rdi      # 0xad40
movl $0x1, %esi
movl $0xa2, %edx
callq 0x5370
jmp 0x6dec
movb $0x11, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6e0d
movq 0xd0(%rsp), %rcx
leaq 0x3f14(%rip), %rdi      # 0xad30
movl $0x1, %esi
movl $0x10, %edx
callq 0x5370
jmp 0x6e2d
movq 0xd0(%rsp), %rcx
leaq 0x3fa6(%rip), %rdi      # 0xade2
movl $0x1, %esi
movl $0xa2, %edx
callq 0x5370
jmp 0x6e4d
movb $-0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6e6e
movb $-0x26, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6e8f
movq 0xd0(%rsp), %rdi
movl $0xc, %esi
callq 0x5580
jmp 0x6ea3
movb $0x3, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6ec4
movb $0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6ee5
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6f06
movb $0x2, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6f27
movb $0x11, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6f48
movb $0x3, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6f69
movb $0x11, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6f8a
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6fab
movb $0x3f, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6fcc
movb $0x0, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x6fed
callq 0x55e0
movl $0x0, 0x28(%rsp)
movl 0x28(%rsp), %eax
cmpl 0x82c0(%rip), %eax      # 0xf2c4
jge 0x704f
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x82b0(%rip), %eax      # 0xf2c8
jge 0x7040
movq 0xd0(%rsp), %rdi
movl 0x24(%rsp), %esi
movl 0x28(%rsp), %edx
callq 0x6150
jmp 0x7031
jmp 0x7033
movl 0x24(%rsp), %eax
addl $0x8, %eax
movl %eax, 0x24(%rsp)
jmp 0x700e
jmp 0x7042
movl 0x28(%rsp), %eax
addl $0x8, %eax
movl %eax, 0x28(%rsp)
jmp 0x6ffa
movq 0xd0(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x5680
jmp 0x7065
movb $-0x1, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x7086
movb $-0x27, 0x4b(%rsp)
movq 0xd0(%rsp), %rcx
leaq 0x4b(%rsp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5370
jmp 0x70a7
movq 0xd0(%rsp), %rdi
callq 0x51d0
jmp 0x70b6
movl $0x0, 0xe4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x7190
movl 0xe4(%rsp), %eax
addq $0xe8, %rsp
retq
movq 0x50(%rsp), %rdi
callq 0x5320
nopw (%rax,%rax)