// File: joncampbell123[P]floppytools/kryo_ibm.cpp
// Function: main
int main(int argc,char **argv) {
    struct flux_bits fb;
    struct kryoflux_event ev;
    std::vector<std::string> cappaths;
    std::string path;
    FILE *dsk_fp;
    int c;

    if (argc < 2) {
        fprintf(stderr,"%s <raw capture directory> [dir...]\n",argv[0]);
        return 1;
    }

    for (int i=1;i < argc;i++) {
        char *a = argv[i];

        if (*a == '-') {
            do { a++; } while (*a == '-');

            if (!strcmp(a,"1.4mb")) {
                sectors = 18;
                heads = 2;
                tracks = 80;
                sector_size = 512;
            }
            else if (!strcmp(a,"720k")) {
                sectors = 9;
                heads = 2;
                tracks = 80;
                sector_size = 512;
            }
            else if (!strcmp(a,"sside")) {
                heads = 1;
            }
            else if (!strcmp(a,"dside")) {
                heads = 2;
            }
            else {
                fprintf(stderr,"Unknown switch %s\n",a);
                return 1;
            }
        }
        else {
            cappaths.push_back(argv[i]);
        }
    }

    dsk_fp = fopen("disk.img","wb");
    if (dsk_fp == NULL) return 1;

    /* sector size auto-detect */
    for (size_t capidx=0;capidx < cappaths.size();capidx++) {
        if (sector_size == 0) {
            printf("Auto-detecting sector size...\n");

            FILE *fp = kryo_fopen(cappaths[capidx],0/*track*/,0/*head*/);
            if (fp == NULL)
                continue;

            if (!autodetect_flux_bits_mfm(fb,ev,fp)) {
                fclose(fp);
                continue;
            }

            flux_bits ofb = fb;

            fseek(fp,0,SEEK_SET);
            fb.clear();

            static const unsigned int max_sector = 40; /* more than enough for even 2.88MB formats */
            unsigned long count_sszcode[max_sector] = {0};

            while (mfm_find_sync(fb,ev,fp)) {
                mfm_sector_id sid;

                if (flux_bits_mfm_read_sync_and_byte(fb,ev,fp) != 0xFE) continue;
                if (flux_bits_mfm_read_sector_id(sid,fb,ev,fp) < 0) continue;

                /* this is a read from track 0 head 0, make sure it matches */
                if (sid.track != 0 || sid.side != 0) continue;
                if (sid.sector_size_code < max_sector) count_sszcode[sid.sector_size_code]++;
            }

            /* scan the histogram for the most common sector size */
            {
                int sel = -1;
                unsigned long sel_count = 0;
                for (unsigned int i=0;i < max_sector;i++) {
                    if (sel_count < count_sszcode[i]) {
                        sel_count = count_sszcode[i];
                        sel = i;
                    }
                }

                if (sel_count >= 6 && sel >= 0) {
                    sector_size = 128u << (unsigned int)sel;
                }
            }

            fclose(fp);
        }
    }

    /* double track detect. Read track 2 and see how they are marked. This is needed to support 360KB DD floppies imaged by a 1.2MB HD drive. */
    for (size_t capidx=0;capidx < cappaths.size();capidx++) {
        if (sector_size != 0 && double_track == 0) {
            printf("Auto-detecting double/single track...\n");

            FILE *fp = kryo_fopen(cappaths[capidx],2/*track*/,0/*head*/);
            if (fp == NULL)
                continue;

            if (!autodetect_flux_bits_mfm(fb,ev,fp)) {
                fclose(fp);
                continue;
            }

            flux_bits ofb = fb;

            fseek(fp,0,SEEK_SET);
            fb.clear();

            unsigned long count_1x = 0;
            unsigned long count_2x = 0;

            while (mfm_find_sync(fb,ev,fp)) {
                mfm_sector_id sid;

                if (flux_bits_mfm_read_sync_and_byte(fb,ev,fp) != 0xFE) continue;
                if (flux_bits_mfm_read_sector_id(sid,fb,ev,fp) < 0) continue;

                /* this is a read from track 0 head 0, make sure it matches */
                if (sid.side != 0) continue;
                if (sid.sector_size() != sector_size) continue;

                if (sid.track == 1/*DD in HD case*/) count_2x++;
                else if (sid.track == 2/*HD in HD case or normal floppy*/) count_1x++;
            }

            /* scan the histogram for the most common sector size */
            if (count_1x >= 4 || count_2x >= 4) {
                if (count_2x > (count_1x / 2u))
                    double_track = 2;
                else if (count_1x > (count_2x / 2u))
                    double_track = 1;
            }

            fclose(fp);
        }
    }

    /* sectors per track autodetect. scan multiple tracks in case of missing/unreadable sectors in track 0 */
    for (size_t capidx=0;capidx < cappaths.size();capidx++) {
        if (sectors == 0 && sector_size != 0 && double_track != 0) {
            printf("Auto-detecting sectors per track...\n");

            for (unsigned int track=0;track < 20;track++) {
                FILE *fp = kryo_fopen(cappaths[capidx],track*double_track/*track*/,0/*head*/);
                if (fp == NULL)
                    continue;

                if (!autodetect_flux_bits_mfm(fb,ev,fp)) {
                    fclose(fp);
                    continue;
                }

                flux_bits ofb = fb;

                fseek(fp,0,SEEK_SET);
                fb.clear();

                while (mfm_find_sync(fb,ev,fp)) {
                    mfm_sector_id sid;

                    if (flux_bits_mfm_read_sync_and_byte(fb,ev,fp) != 0xFE) continue;
                    if (flux_bits_mfm_read_sector_id(sid,fb,ev,fp) < 0) continue;

                    /* this is a read from track <track> head 0, make sure it matches */
                    if (sid.track != track || sid.side != 0 || sid.sector_size() != sector_size) continue;

                    /* reject copy protection sectors that most likely have out of range numbers */
                    if (sid.sector > 24) continue; /* more than enough for 1.44MB and even DMF */

                    if (sectors < sid.sector)
                        sectors = sid.sector;
                }

                fclose(fp);
            }
        }
    }

    /* number of heads. look at side 2 (head == 1) and make sure the format matches. */
    for (size_t capidx=0;capidx < cappaths.size();capidx++) {
        if (sectors != 0 && sector_size != 0 && double_track != 0 && heads == 0) {
            unsigned int sectors2 = 0;

            printf("Auto-detecting heads...\n");

            for (unsigned int track=0;track < 20;track++) {
                FILE *fp = kryo_fopen(cappaths[capidx],track*double_track/*track*/,1/*head*/);
                if (fp == NULL)
                    continue;

                if (!autodetect_flux_bits_mfm(fb,ev,fp)) {
                    fclose(fp);
                    continue;
                }

                flux_bits ofb = fb;

                fseek(fp,0,SEEK_SET);
                fb.clear();

                while (mfm_find_sync(fb,ev,fp)) {
                    mfm_sector_id sid;

                    if (flux_bits_mfm_read_sync_and_byte(fb,ev,fp) != 0xFE) continue;
                    if (flux_bits_mfm_read_sector_id(sid,fb,ev,fp) < 0) continue;

                    /* this is a read from track <track> head 1, make sure it matches */
                    if (sid.track != track || sid.side != 1 || sid.sector_size() != sector_size) continue;

                    /* reject copy protection sectors that most likely have out of range numbers */
                    if (sid.sector > 24) continue; /* more than enough for 1.44MB and even DMF */

                    if (sectors2 < sid.sector)
                        sectors2 = sid.sector;
                }

                fclose(fp);
            }

            if (sectors2 == sectors)
                heads = 2;
            else
                heads = 1;
        }
    }

    /* number of tracks */
    for (size_t capidx=0;capidx < cappaths.size();capidx++) {
        if (sectors != 0 && sector_size != 0 && double_track != 0 && heads != 0 && tracks == 0) {
            printf("Auto-detecting tracks...\n");

            for (unsigned int track=0;track < (84/double_track);track++) {
                unsigned long sectcount = 0;
                unsigned long hsectmin = 4;
                unsigned long sectmin = hsectmin * heads; /* in case of damaged or lost sectors */

                for (unsigned int head=0;head < heads;head++) {
                    unsigned long hsectcount = 0;

		    printf("\x0D" "t=%u h=%u ",track,head);
		    fflush(stdout);

                    FILE *fp = kryo_fopen(cappaths[capidx],track*double_track/*track*/,head/*head*/);
                    if (fp == NULL)
                        continue;

                    if (!autodetect_flux_bits_mfm(fb,ev,fp)) {
                        fclose(fp);
                        continue;
                    }

                    flux_bits ofb = fb;

                    fseek(fp,0,SEEK_SET);
                    fb.clear();

                    while (mfm_find_sync(fb,ev,fp)) {
                        mfm_sector_id sid;

                        if (flux_bits_mfm_read_sync_and_byte(fb,ev,fp) != 0xFE) continue;
                        if (flux_bits_mfm_read_sector_id(sid,fb,ev,fp) < 0) continue;

                        /* this is a read from track <track> head <head>, make sure it matches */
                        if (sid.track != track || sid.side != head || sid.sector_size() != sector_size || sid.sector > sectors) continue;

                        sectcount++;
                        hsectcount++;
                        if (hsectcount >= hsectmin) break;
                    }

                    fclose(fp);
                }

		printf("\x0D            \x0D");
		fflush(stdout);

                if (sectcount >= sectmin) {
                    if (tracks <= track)
                        tracks = track + 1;
                }
            }
        }
    }

    printf("Using disk geometry C/H/S/Sz %u/%u/%u/%u doubletrack=%u\n",tracks,heads,sectors,sector_size,double_track);
    if (heads == 0 || sectors == 0 || tracks == 0 || sector_size == 0 || double_track == 0) {
        fprintf(stderr,"Unable to detect format\n");
        return 1;
    }

    captured.resize(heads * sectors * tracks);

    for (size_t pass=0;pass < 3;pass++) {
	    for (size_t capidx=0;capidx < cappaths.size();capidx++) {
		    for (unsigned int track=0;track < tracks;track++) {
			    for (unsigned int head=0;head < heads;head++) {
				    printf("Track %u head %u\n",track,head);

				    FILE *fp = kryo_fopen(cappaths[capidx],track*double_track,head);
				    if (fp == NULL) {
					    printf("Failed to open\n");
					    continue;
				    }

				    if (!autodetect_flux_bits_mfm(fb,ev,fp)) {
					    fprintf(stderr,"Autodetect failure\n");
					    fclose(fp);
					    continue;
				    }

				    flux_bits ofb = fb;
				    unsigned int capcount = 0;

				    int adj_span;
				    int dadj_span;

				    switch (pass) {
					    case 0:
						    adj_span = 0;
						    dadj_span = 0;
						    break;
					    case 1:
						    adj_span = 2;
						    dadj_span = 2;
						    break;
					    case 2:
						    adj_span = 4;
						    dadj_span = 4;
						    break;
					    default:
						    abort();
				    }

				    for (int adj_c = 0;adj_c <= (adj_span*2);adj_c++) {
					    for (int dadj_c = 0;dadj_c <= (dadj_span*2);dadj_c++) {
						    unsigned int capcount = 0;

						    int adj = adj_c;
						    int dadj = dadj_c;

						    if (adj >= (adj_span+1)) adj -= adj_span*2;
						    if (dadj >= (dadj_span+1)) dadj -= dadj_span*2;

						    if ((int)ofb.shortest+(int)adj <= 0)
							    continue;
						    fb.shortest = ofb.shortest + adj;

						    if ((int)ofb.dist+(int)dadj <= 0)
							    continue;
						    fb.dist = ofb.dist + dadj;

						    unsigned long snum = ((track * heads) + head) * sectors;

						    for (size_t i=0;i < sectors;i++)
							    capcount += captured[i+snum];

						    if (capcount >= sectors)
							    break;

						    fseek(fp,0,SEEK_SET);
						    fb.clear();

						    while (mfm_find_sync(fb,ev,fp))
							    process_sync(dsk_fp,fb,ev,fp,track,head);
					    }
				    }

				    {
					    unsigned int capcount = 0;
					    {
						    unsigned long snum = ((track * heads) + head) * sectors;
						    for (size_t i=0;i < sectors;i++)
							    capcount += captured[i+snum];
					    }

					    unsigned long snum = ((track * heads) + head) * sectors;
					    printf("Track %u head %u capture progress: %u/%u ",track,head,capcount,sectors);
					    for (size_t i=0;i < sectors;i++) printf("%u",captured[i+snum]?1:0);
					    printf("\n");

					    if (capcount < sectors) {
						    printf("Track %u head %u not captured fully (%u < %u)\n",track,head,capcount,sectors);
					    }
				    }

				    fclose(fp);
			    }
		    }
	    }
    }

    {
        size_t count = 0;

        for (size_t i=0;i < captured.size();i++) {
            if (captured[i]) count++;
        }

        printf("Capture report: %zu captured / %zu total\n",count,captured.size());

        if (count < captured.size()) {
            printf("Missing sectors:\n");
            for (size_t i=0;i < captured.size();i++) {
                if (!captured[i])
                    printf(" %zu (C/H/S %u/%u/%u)\n",
                        i,
                        i / heads / sectors,
                        (i / sectors) % heads,
                        (i % sectors) + 1);
            }
        }
    }

    printf("Using disk geometry C/H/S/Sz %u/%u/%u/%u doubletrack=%u\n",tracks,heads,sectors,sector_size,double_track);
    fclose(dsk_fp);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6c0, %rsp            # imm = 0x6C0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x47a0
leaq -0x60(%rbp), %rdi
callq 0x47c0
leaq -0x80(%rbp), %rdi
callq 0x2220
cmpl $0x2, -0x8(%rbp)
jge 0x288f
movq 0xd77f(%rip), %rax      # 0xffe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x8854(%rip), %rsi      # 0xb0c6
movb $0x0, %al
callq 0x2240
movl $0x1, -0x4(%rbp)
movl $0x1, -0x90(%rbp)
jmp 0x454d
movl $0x1, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2ad0
movq -0x10(%rbp), %rax
movslq -0x94(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2a06
jmp 0x28d3
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x28d3
movq -0xa0(%rbp), %rdi
leaq 0x87e9(%rip), %rsi      # 0xb0eb
callq 0x2230
cmpl $0x0, %eax
jne 0x2939
movl $0x12, 0xd87a(%rip)     # 0x10190
movl $0x2, 0xd874(%rip)      # 0x10194
movl $0x50, 0xd86e(%rip)     # 0x10198
movl $0x200, 0xd868(%rip)    # imm = 0x200
jmp 0x2a01
movq -0xa0(%rbp), %rdi
leaq 0x87aa(%rip), %rsi      # 0xb0f1
callq 0x2230
cmpl $0x0, %eax
jne 0x297e
movl $0x9, 0xd835(%rip)      # 0x10190
movl $0x2, 0xd82f(%rip)      # 0x10194
movl $0x50, 0xd829(%rip)     # 0x10198
movl $0x200, 0xd823(%rip)    # imm = 0x200
jmp 0x29ff
movq -0xa0(%rbp), %rdi
leaq 0x876a(%rip), %rsi      # 0xb0f6
callq 0x2230
cmpl $0x0, %eax
jne 0x29a2
movl $0x1, 0xd7f4(%rip)      # 0x10194
jmp 0x29fd
movq -0xa0(%rbp), %rdi
leaq 0x874c(%rip), %rsi      # 0xb0fc
callq 0x2230
cmpl $0x0, %eax
jne 0x29c6
movl $0x2, 0xd7d0(%rip)      # 0x10194
jmp 0x29fb
movq 0xd613(%rip), %rax      # 0xffe0
movq (%rax), %rdi
movq -0xa0(%rbp), %rdx
leaq 0x8724(%rip), %rsi      # 0xb102
movb $0x0, %al
callq 0x2240
movl $0x1, -0x4(%rbp)
movl $0x1, -0x90(%rbp)
jmp 0x454d
jmp 0x29fd
jmp 0x29ff
jmp 0x2a01
jmp 0x2aba
movq -0x10(%rbp), %rax
movslq -0x94(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x558(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x550(%rbp)
callq 0x22a0
movq -0x558(%rbp), %rsi
movq -0x550(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x2210
jmp 0x2a4b
leaq -0x60(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x47e0
jmp 0x2a5d
leaq -0xc0(%rbp), %rdi
callq 0x2110
leaq -0xc1(%rbp), %rdi
callq 0x21a0
jmp 0x2aba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x2aa9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x2110
leaq -0xc1(%rbp), %rdi
callq 0x21a0
jmp 0x4574
jmp 0x2abc
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x2899
leaq 0x863e(%rip), %rdi      # 0xb115
leaq 0x8640(%rip), %rsi      # 0xb11e
callq 0x21d0
movq %rax, -0x560(%rbp)
jmp 0x2aec
movq -0x560(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
jne 0x2b31
movl $0x1, -0x4(%rbp)
movl $0x1, -0x90(%rbp)
jmp 0x454d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x4574
movq $0x0, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x568(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4810
movq %rax, %rcx
movq -0x568(%rbp), %rax
cmpq %rcx, %rax
jae 0x2e24
cmpl $0x0, 0xd62f(%rip)      # 0x1019c
jne 0x2e0b
leaq 0x85a7(%rip), %rdi      # 0xb121
xorl %eax, %eax
callq 0x2050
jmp 0x2b83
movq -0xe0(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4830
movq %rax, %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x9020
movq %rax, -0x570(%rbp)
jmp 0x2ba8
movq -0x570(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0xe8(%rbp)
jne 0x2bc5
jmp 0x2e0d
movq -0xe8(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x85d0
movb %al, -0x571(%rbp)
jmp 0x2be1
movb -0x571(%rbp), %al
testb $0x1, %al
jne 0x2c00
jmp 0x2bed
movq -0xe8(%rbp), %rdi
callq 0x2180
jmp 0x2bfb
jmp 0x2e0d
movups -0x20(%rbp), %xmm0
movaps %xmm0, -0x100(%rbp)
movq -0xe8(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x21b0
jmp 0x2c1d
leaq -0x20(%rbp), %rdi
callq 0x84d0
jmp 0x2c28
leaq -0x240(%rbp), %rdi
xorl %esi, %esi
movl $0x140, %edx            # imm = 0x140
callq 0x20e0
leaq -0x268(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x46f0
jmp 0x2c4d
movq -0xe8(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x9150
movb %al, -0x572(%rbp)
jmp 0x2c6c
leaq -0x268(%rbp), %rdi
callq 0x4730
movb -0x572(%rbp), %al
testb $0x1, %al
jne 0x2c87
jmp 0x2d62
leaq -0x26d(%rbp), %rdi
callq 0x93e0
jmp 0x2c95
movq -0xe8(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9380
movl %eax, -0x578(%rbp)
jmp 0x2cb1
movl -0x578(%rbp), %eax
cmpl $0xfe, %eax
je 0x2ce6
jmp 0x2c3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x4730
jmp 0x4574
movq -0xe8(%rbp), %rcx
leaq -0x26d(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x9470
movl %eax, -0x57c(%rbp)
jmp 0x2d09
movl -0x57c(%rbp), %eax
cmpl $0x0, %eax
jge 0x2d19
jmp 0x2c3b
movzbl -0x26d(%rbp), %eax
cmpl $0x0, %eax
jne 0x2d31
movzbl -0x26c(%rbp), %eax
cmpl $0x0, %eax
je 0x2d36
jmp 0x2c3b
movzbl -0x26a(%rbp), %eax
cmpl $0x28, %eax
jae 0x2d5d
movzbl -0x26a(%rbp), %eax
movq -0x240(%rbp,%rax,8), %rcx
addq $0x1, %rcx
movq %rcx, -0x240(%rbp,%rax,8)
jmp 0x2c3b
movl $0xffffffff, -0x274(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x280(%rbp)
movl $0x0, -0x284(%rbp)
cmpl $0x28, -0x284(%rbp)
jae 0x2dd5
movq -0x280(%rbp), %rax
movl -0x284(%rbp), %ecx
cmpq -0x240(%rbp,%rcx,8), %rax
jae 0x2dc2
movl -0x284(%rbp), %eax
movq -0x240(%rbp,%rax,8), %rax
movq %rax, -0x280(%rbp)
movl -0x284(%rbp), %eax
movl %eax, -0x274(%rbp)
jmp 0x2dc4
movl -0x284(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x284(%rbp)
jmp 0x2d81
cmpq $0x6, -0x280(%rbp)
jb 0x2dfb
cmpl $0x0, -0x274(%rbp)
jl 0x2dfb
movl -0x274(%rbp), %ecx
movl $0x80, %eax
shll %cl, %eax
movl %eax, 0xd3a1(%rip)      # 0x1019c
movq -0xe8(%rbp), %rdi
callq 0x2180
jmp 0x2e09
jmp 0x2e0b
jmp 0x2e0d
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x2b3c
movq $0x0, -0x290(%rbp)
movq -0x290(%rbp), %rax
movq %rax, -0x588(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4810
movq %rax, %rcx
movq -0x588(%rbp), %rax
cmpq %rcx, %rax
jae 0x311f
cmpl $0x0, 0xd33c(%rip)      # 0x1019c
je 0x3106
cmpl $0x0, 0xd333(%rip)      # 0x101a0
jne 0x3106
leaq 0x82c6(%rip), %rdi      # 0xb140
xorl %eax, %eax
callq 0x2050
jmp 0x2e83
movq -0x290(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4830
movq %rax, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x9020
movq %rax, -0x590(%rbp)
jmp 0x2eab
movq -0x590(%rbp), %rax
movq %rax, -0x298(%rbp)
cmpq $0x0, -0x298(%rbp)
jne 0x2ec8
jmp 0x3108
movq -0x298(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x85d0
movb %al, -0x591(%rbp)
jmp 0x2ee4
movb -0x591(%rbp), %al
testb $0x1, %al
jne 0x2f03
jmp 0x2ef0
movq -0x298(%rbp), %rdi
callq 0x2180
jmp 0x2efe
jmp 0x3108
movups -0x20(%rbp), %xmm0
movaps %xmm0, -0x2b0(%rbp)
movq -0x298(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x21b0
jmp 0x2f20
leaq -0x20(%rbp), %rdi
callq 0x84d0
jmp 0x2f2b
movq $0x0, -0x2b8(%rbp)
movq $0x0, -0x2c0(%rbp)
leaq -0x2e8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x46f0
jmp 0x2f53
movq -0x298(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x9150
movb %al, -0x592(%rbp)
jmp 0x2f72
leaq -0x2e8(%rbp), %rdi
callq 0x4730
movb -0x592(%rbp), %al
testb $0x1, %al
jne 0x2f8d
jmp 0x309c
leaq -0x2ed(%rbp), %rdi
callq 0x93e0
jmp 0x2f9b
movq -0x298(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9380
movl %eax, -0x598(%rbp)
jmp 0x2fb7
movl -0x598(%rbp), %eax
cmpl $0xfe, %eax
je 0x2fec
jmp 0x2f41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x4730
jmp 0x4574
movq -0x298(%rbp), %rcx
leaq -0x2ed(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x9470
movl %eax, -0x59c(%rbp)
jmp 0x300f
movl -0x59c(%rbp), %eax
cmpl $0x0, %eax
jge 0x301f
jmp 0x2f41
movzbl -0x2ec(%rbp), %eax
cmpl $0x0, %eax
je 0x3030
jmp 0x2f41
leaq -0x2ed(%rbp), %rdi
callq 0x9430
movl %eax, -0x5a0(%rbp)
jmp 0x3044
movl -0x5a0(%rbp), %eax
cmpl 0xd14c(%rip), %eax      # 0x1019c
je 0x3057
jmp 0x2f41
movzbl -0x2ed(%rbp), %eax
cmpl $0x1, %eax
jne 0x3077
movq -0x2c0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2c0(%rbp)
jmp 0x3097
movzbl -0x2ed(%rbp), %eax
cmpl $0x2, %eax
jne 0x3095
movq -0x2b8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2b8(%rbp)
jmp 0x3097
jmp 0x2f41
cmpq $0x4, -0x2b8(%rbp)
jae 0x30b0
cmpq $0x4, -0x2c0(%rbp)
jb 0x30f6
movq -0x2c0(%rbp), %rax
movq -0x2b8(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jbe 0x30d2
movl $0x2, 0xd0d0(%rip)      # 0x101a0
jmp 0x30f4
movq -0x2b8(%rbp), %rax
movq -0x2c0(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jbe 0x30f2
movl $0x1, 0xd0ae(%rip)      # 0x101a0
jmp 0x30f4
jmp 0x30f6
movq -0x298(%rbp), %rdi
callq 0x2180
jmp 0x3104
jmp 0x3106
jmp 0x3108
movq -0x290(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x290(%rbp)
jmp 0x2e2f
movq $0x0, -0x2f8(%rbp)
movq -0x2f8(%rbp), %rax
movq %rax, -0x5a8(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4810
movq %rax, %rcx
movq -0x5a8(%rbp), %rax
cmpq %rcx, %rax
jae 0x33e9
cmpl $0x0, 0xd035(%rip)      # 0x10190
jne 0x33d0
cmpl $0x0, 0xd034(%rip)      # 0x1019c
je 0x33d0
cmpl $0x0, 0xd02b(%rip)      # 0x101a0
je 0x33d0
leaq 0x7fe5(%rip), %rdi      # 0xb167
xorl %eax, %eax
callq 0x2050
jmp 0x318b
movl $0x0, -0x2fc(%rbp)
cmpl $0x14, -0x2fc(%rbp)
jae 0x33ce
movq -0x2f8(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4830
movq %rax, %rdi
movl -0x2fc(%rbp), %esi
movl 0xcfdf(%rip), %eax      # 0x101a0
imull %eax, %esi
xorl %edx, %edx
callq 0x9020
movq %rax, -0x5b0(%rbp)
jmp 0x31d4
movq -0x5b0(%rbp), %rax
movq %rax, -0x308(%rbp)
cmpq $0x0, -0x308(%rbp)
jne 0x31f1
jmp 0x33ba
movq -0x308(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x85d0
movb %al, -0x5b1(%rbp)
jmp 0x320d
movb -0x5b1(%rbp), %al
testb $0x1, %al
jne 0x322c
jmp 0x3219
movq -0x308(%rbp), %rdi
callq 0x2180
jmp 0x3227
jmp 0x33ba
movups -0x20(%rbp), %xmm0
movaps %xmm0, -0x320(%rbp)
movq -0x308(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x21b0
jmp 0x3249
leaq -0x20(%rbp), %rdi
callq 0x84d0
jmp 0x3254
jmp 0x3256
leaq -0x348(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x46f0
jmp 0x3268
movq -0x308(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x9150
movb %al, -0x5b2(%rbp)
jmp 0x3287
leaq -0x348(%rbp), %rdi
callq 0x4730
movb -0x5b2(%rbp), %al
testb $0x1, %al
jne 0x32a2
jmp 0x33aa
leaq -0x34d(%rbp), %rdi
callq 0x93e0
jmp 0x32b0
movq -0x308(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9380
movl %eax, -0x5b8(%rbp)
jmp 0x32cc
movl -0x5b8(%rbp), %eax
cmpl $0xfe, %eax
je 0x3301
jmp 0x3256
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x4730
jmp 0x4574
movq -0x308(%rbp), %rcx
leaq -0x34d(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x9470
movl %eax, -0x5bc(%rbp)
jmp 0x3324
movl -0x5bc(%rbp), %eax
cmpl $0x0, %eax
jge 0x3334
jmp 0x3256
movzbl -0x34d(%rbp), %eax
cmpl -0x2fc(%rbp), %eax
jne 0x3371
movzbl -0x34c(%rbp), %eax
cmpl $0x0, %eax
jne 0x3371
leaq -0x34d(%rbp), %rdi
callq 0x9430
movl %eax, -0x5c0(%rbp)
jmp 0x3363
movl -0x5c0(%rbp), %eax
cmpl 0xce2d(%rip), %eax      # 0x1019c
je 0x3376
jmp 0x3256
movzbl -0x34b(%rbp), %eax
cmpl $0x18, %eax
jle 0x3387
jmp 0x3256
movl 0xce03(%rip), %eax      # 0x10190
movzbl -0x34b(%rbp), %ecx
cmpl %ecx, %eax
jae 0x33a5
movzbl -0x34b(%rbp), %eax
movl %eax, 0xcdeb(%rip)      # 0x10190
jmp 0x3256
movq -0x308(%rbp), %rdi
callq 0x2180
jmp 0x33b8
jmp 0x33ba
movl -0x2fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2fc(%rbp)
jmp 0x3195
jmp 0x33d0
jmp 0x33d2
movq -0x2f8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2f8(%rbp)
jmp 0x312a
movq $0x0, -0x358(%rbp)
movq -0x358(%rbp), %rax
movq %rax, -0x5c8(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4810
movq %rax, %rcx
movq -0x5c8(%rbp), %rax
cmpq %rcx, %rax
jae 0x36f1
cmpl $0x0, 0xcd6b(%rip)      # 0x10190
je 0x36d8
cmpl $0x0, 0xcd6a(%rip)      # 0x1019c
je 0x36d8
cmpl $0x0, 0xcd61(%rip)      # 0x101a0
je 0x36d8
cmpl $0x0, 0xcd48(%rip)      # 0x10194
jne 0x36d8
movl $0x0, -0x35c(%rbp)
leaq 0x7d29(%rip), %rdi      # 0xb18c
xorl %eax, %eax
callq 0x2050
jmp 0x346c
movl $0x0, -0x360(%rbp)
cmpl $0x14, -0x360(%rbp)
jae 0x36b2
movq -0x358(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4830
movq %rax, %rdi
movl -0x360(%rbp), %esi
movl 0xccfe(%rip), %eax      # 0x101a0
imull %eax, %esi
movl $0x1, %edx
callq 0x9020
movq %rax, -0x5d0(%rbp)
jmp 0x34b8
movq -0x5d0(%rbp), %rax
movq %rax, -0x368(%rbp)
cmpq $0x0, -0x368(%rbp)
jne 0x34d5
jmp 0x369e
movq -0x368(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x85d0
movb %al, -0x5d1(%rbp)
jmp 0x34f1
movb -0x5d1(%rbp), %al
testb $0x1, %al
jne 0x3510
jmp 0x34fd
movq -0x368(%rbp), %rdi
callq 0x2180
jmp 0x350b
jmp 0x369e
movups -0x20(%rbp), %xmm0
movaps %xmm0, -0x380(%rbp)
movq -0x368(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x21b0
jmp 0x352d
leaq -0x20(%rbp), %rdi
callq 0x84d0
jmp 0x3538
jmp 0x353a
leaq -0x3a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x46f0
jmp 0x354c
movq -0x368(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x9150
movb %al, -0x5d2(%rbp)
jmp 0x356b
leaq -0x3a8(%rbp), %rdi
callq 0x4730
movb -0x5d2(%rbp), %al
testb $0x1, %al
jne 0x3586
jmp 0x368e
leaq -0x3ad(%rbp), %rdi
callq 0x93e0
jmp 0x3594
movq -0x368(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9380
movl %eax, -0x5d8(%rbp)
jmp 0x35b0
movl -0x5d8(%rbp), %eax
cmpl $0xfe, %eax
je 0x35e5
jmp 0x353a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x4730
jmp 0x4574
movq -0x368(%rbp), %rcx
leaq -0x3ad(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x9470
movl %eax, -0x5dc(%rbp)
jmp 0x3608
movl -0x5dc(%rbp), %eax
cmpl $0x0, %eax
jge 0x3618
jmp 0x353a
movzbl -0x3ad(%rbp), %eax
cmpl -0x360(%rbp), %eax
jne 0x3655
movzbl -0x3ac(%rbp), %eax
cmpl $0x1, %eax
jne 0x3655
leaq -0x3ad(%rbp), %rdi
callq 0x9430
movl %eax, -0x5e0(%rbp)
jmp 0x3647
movl -0x5e0(%rbp), %eax
cmpl 0xcb49(%rip), %eax      # 0x1019c
je 0x365a
jmp 0x353a
movzbl -0x3ab(%rbp), %eax
cmpl $0x18, %eax
jle 0x366b
jmp 0x353a
movl -0x35c(%rbp), %eax
movzbl -0x3ab(%rbp), %ecx
cmpl %ecx, %eax
jae 0x3689
movzbl -0x3ab(%rbp), %eax
movl %eax, -0x35c(%rbp)
jmp 0x353a
movq -0x368(%rbp), %rdi
callq 0x2180
jmp 0x369c
jmp 0x369e
movl -0x360(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x360(%rbp)
jmp 0x3476
movl -0x35c(%rbp), %eax
cmpl 0xcad2(%rip), %eax      # 0x10190
jne 0x36cc
movl $0x2, 0xcaca(%rip)      # 0x10194
jmp 0x36d6
movl $0x1, 0xcabe(%rip)      # 0x10194
jmp 0x36d8
jmp 0x36da
movq -0x358(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x358(%rbp)
jmp 0x33f4
movq $0x0, -0x3b8(%rbp)
movq -0x3b8(%rbp), %rax
movq %rax, -0x5e8(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4810
movq %rax, %rcx
movq -0x5e8(%rbp), %rax
cmpq %rcx, %rax
jae 0x3af6
cmpl $0x0, 0xca63(%rip)      # 0x10190
je 0x3add
cmpl $0x0, 0xca62(%rip)      # 0x1019c
je 0x3add
cmpl $0x0, 0xca59(%rip)      # 0x101a0
je 0x3add
cmpl $0x0, 0xca40(%rip)      # 0x10194
je 0x3add
cmpl $0x0, 0xca37(%rip)      # 0x10198
jne 0x3add
leaq 0x7a37(%rip), %rdi      # 0xb1a5
xorl %eax, %eax
callq 0x2050
jmp 0x3777
movl $0x0, -0x3bc(%rbp)
movl -0x3bc(%rbp), %eax
movl %eax, -0x5ec(%rbp)
movl $0x54, %eax
xorl %edx, %edx
divl 0xca06(%rip)            # 0x101a0
movl %eax, %ecx
movl -0x5ec(%rbp), %eax
cmpl %ecx, %eax
jae 0x3adb
movq $0x0, -0x3c8(%rbp)
movq $0x4, -0x3d0(%rbp)
movq -0x3d0(%rbp), %rax
movl 0xc9c7(%rip), %ecx      # 0x10194
imulq %rcx, %rax
movq %rax, -0x3d8(%rbp)
movl $0x0, -0x3dc(%rbp)
movl -0x3dc(%rbp), %eax
cmpl 0xc9a6(%rip), %eax      # 0x10194
jae 0x3a75
movq $0x0, -0x3e8(%rbp)
movl -0x3bc(%rbp), %esi
movl -0x3dc(%rbp), %edx
leaq 0x79ad(%rip), %rdi      # 0xb1bf
xorl %eax, %eax
callq 0x2050
jmp 0x381b
movq 0xc7a6(%rip), %rax      # 0xffc8
movq (%rax), %rdi
callq 0x21c0
jmp 0x382c
movq -0x3b8(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4830
movq %rax, %rdi
movl -0x3bc(%rbp), %esi
movl 0xc955(%rip), %eax      # 0x101a0
imull %eax, %esi
movl -0x3dc(%rbp), %edx
callq 0x9020
movq %rax, -0x5f8(%rbp)
jmp 0x3862
movq -0x5f8(%rbp), %rax
movq %rax, -0x3f0(%rbp)
cmpq $0x0, -0x3f0(%rbp)
jne 0x387f
jmp 0x3a61
movq -0x3f0(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x85d0
movb %al, -0x5f9(%rbp)
jmp 0x389b
movb -0x5f9(%rbp), %al
testb $0x1, %al
jne 0x38ba
jmp 0x38a7
movq -0x3f0(%rbp), %rdi
callq 0x2180
jmp 0x38b5
jmp 0x3a61
movups -0x20(%rbp), %xmm0
movaps %xmm0, -0x400(%rbp)
movq -0x3f0(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x21b0
jmp 0x38d7
leaq -0x20(%rbp), %rdi
callq 0x84d0
jmp 0x38e2
jmp 0x38e4
leaq -0x428(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x46f0
jmp 0x38f6
movq -0x3f0(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x428(%rbp), %rsi
callq 0x9150
movb %al, -0x5fa(%rbp)
jmp 0x3915
leaq -0x428(%rbp), %rdi
callq 0x4730
movb -0x5fa(%rbp), %al
testb $0x1, %al
jne 0x3930
jmp 0x3a51
leaq -0x42d(%rbp), %rdi
callq 0x93e0
jmp 0x393e
movq -0x3f0(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9380
movl %eax, -0x600(%rbp)
jmp 0x395a
movl -0x600(%rbp), %eax
cmpl $0xfe, %eax
je 0x398f
jmp 0x38e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x428(%rbp), %rdi
callq 0x4730
jmp 0x4574
movq -0x3f0(%rbp), %rcx
leaq -0x42d(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x9470
movl %eax, -0x604(%rbp)
jmp 0x39b2
movl -0x604(%rbp), %eax
cmpl $0x0, %eax
jge 0x39c2
jmp 0x38e4
movzbl -0x42d(%rbp), %eax
cmpl -0x3bc(%rbp), %eax
jne 0x3a11
movzbl -0x42c(%rbp), %eax
cmpl -0x3dc(%rbp), %eax
jne 0x3a11
leaq -0x42d(%rbp), %rdi
callq 0x9430
movl %eax, -0x608(%rbp)
jmp 0x39f4
movl -0x608(%rbp), %eax
cmpl 0xc79c(%rip), %eax      # 0x1019c
jne 0x3a11
movzbl -0x42b(%rbp), %eax
cmpl 0xc781(%rip), %eax      # 0x10190
jbe 0x3a16
jmp 0x38e4
movq -0x3c8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x3c8(%rbp)
movq -0x3e8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x3e8(%rbp)
movq -0x3e8(%rbp), %rax
cmpq -0x3d0(%rbp), %rax
jb 0x3a4c
jmp 0x3a51
jmp 0x38e4
movq -0x3f0(%rbp), %rdi
callq 0x2180
jmp 0x3a5f
jmp 0x3a61
movl -0x3dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3dc(%rbp)
jmp 0x37e2
leaq 0x774f(%rip), %rdi      # 0xb1cb
xorl %eax, %eax
callq 0x2050
jmp 0x3a85
movq 0xc53c(%rip), %rax      # 0xffc8
movq (%rax), %rdi
callq 0x21c0
jmp 0x3a96
movq -0x3c8(%rbp), %rax
cmpq -0x3d8(%rbp), %rax
jb 0x3ac5
movl 0xc6ec(%rip), %eax      # 0x10198
cmpl -0x3bc(%rbp), %eax
ja 0x3ac3
movl -0x3bc(%rbp), %eax
addl $0x1, %eax
movl %eax, 0xc6d5(%rip)      # 0x10198
jmp 0x3ac5
jmp 0x3ac7
movl -0x3bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3bc(%rbp)
jmp 0x3781
jmp 0x3add
jmp 0x3adf
movq -0x3b8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x3b8(%rbp)
jmp 0x36fc
movl 0xc69c(%rip), %esi      # 0x10198
movl 0xc692(%rip), %edx      # 0x10194
movl 0xc688(%rip), %ecx      # 0x10190
movl 0xc68d(%rip), %r8d      # 0x1019c
movl 0xc68a(%rip), %r9d      # 0x101a0
leaq 0x76bd(%rip), %rdi      # 0xb1da
xorl %eax, %eax
callq 0x2050
jmp 0x3b26
cmpl $0x0, 0xc667(%rip)      # 0x10194
je 0x3b53
cmpl $0x0, 0xc65a(%rip)      # 0x10190
je 0x3b53
cmpl $0x0, 0xc659(%rip)      # 0x10198
je 0x3b53
cmpl $0x0, 0xc654(%rip)      # 0x1019c
je 0x3b53
cmpl $0x0, 0xc64f(%rip)      # 0x101a0
jne 0x3b81
movq 0xc486(%rip), %rax      # 0xffe0
movq (%rax), %rdi
leaq 0x76af(%rip), %rsi      # 0xb213
movb $0x0, %al
callq 0x2240
movl $0x1, -0x4(%rbp)
movl $0x1, -0x90(%rbp)
jmp 0x454d
movl 0xc60d(%rip), %eax      # 0x10194
movl 0xc603(%rip), %ecx      # 0x10190
imull %ecx, %eax
movl 0xc602(%rip), %ecx      # 0x10198
imull %ecx, %eax
movl %eax, %esi
leaq 0x1061e(%rip), %rdi     # 0x141c0
xorl %edx, %edx
callq 0x4850
jmp 0x3bab
movq $0x0, -0x438(%rbp)
cmpq $0x3, -0x438(%rbp)
jae 0x42b2
movq $0x0, -0x440(%rbp)
movq -0x440(%rbp), %rax
movq %rax, -0x610(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4810
movq %rax, %rcx
movq -0x610(%rbp), %rax
cmpq %rcx, %rax
jae 0x4299
movl $0x0, -0x444(%rbp)
movl -0x444(%rbp), %eax
cmpl 0xc589(%rip), %eax      # 0x10198
jae 0x4280
movl $0x0, -0x448(%rbp)
movl -0x448(%rbp), %eax
cmpl 0xc569(%rip), %eax      # 0x10194
jae 0x426a
movl -0x444(%rbp), %esi
movl -0x448(%rbp), %edx
leaq 0x75e8(%rip), %rdi      # 0xb22c
xorl %eax, %eax
callq 0x2050
jmp 0x3c4d
movq -0x440(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4830
movq %rax, %rdi
movl -0x444(%rbp), %esi
movl 0xc534(%rip), %eax      # 0x101a0
imull %eax, %esi
movl -0x448(%rbp), %edx
callq 0x9020
movq %rax, -0x618(%rbp)
jmp 0x3c83
movq -0x618(%rbp), %rax
movq %rax, -0x450(%rbp)
cmpq $0x0, -0x450(%rbp)
jne 0x3cb0
leaq 0x759c(%rip), %rdi      # 0xb23e
xorl %eax, %eax
callq 0x2050
jmp 0x3cab
jmp 0x4256
movq -0x450(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x85d0
movb %al, -0x619(%rbp)
jmp 0x3ccc
movb -0x619(%rbp), %al
testb $0x1, %al
jne 0x3d03
jmp 0x3cd8
movq 0xc301(%rip), %rax      # 0xffe0
movq (%rax), %rdi
leaq 0x7565(%rip), %rsi      # 0xb24e
xorl %eax, %eax
callq 0x2240
movq -0x450(%rbp), %rdi
callq 0x2180
jmp 0x3cfe
jmp 0x4256
movups -0x20(%rbp), %xmm0
movaps %xmm0, -0x460(%rbp)
movl $0x0, -0x464(%rbp)
movq -0x438(%rbp), %rax
movq %rax, -0x628(%rbp)
testq %rax, %rax
je 0x3d4b
jmp 0x3d2d
movq -0x628(%rbp), %rax
subq $0x1, %rax
je 0x3d61
jmp 0x3d3c
movq -0x628(%rbp), %rax
subq $0x2, %rax
je 0x3d77
jmp 0x3d8d
movl $0x0, -0x468(%rbp)
movl $0x0, -0x46c(%rbp)
jmp 0x3d92
movl $0x2, -0x468(%rbp)
movl $0x2, -0x46c(%rbp)
jmp 0x3d92
movl $0x4, -0x468(%rbp)
movl $0x4, -0x46c(%rbp)
jmp 0x3d92
callq 0x20f0
movl $0x0, -0x470(%rbp)
movl -0x470(%rbp), %eax
movl -0x468(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jg 0x4044
movl $0x0, -0x474(%rbp)
movl -0x474(%rbp), %eax
movl -0x46c(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jg 0x402e
movl $0x0, -0x478(%rbp)
movl -0x470(%rbp), %eax
movl %eax, -0x47c(%rbp)
movl -0x474(%rbp), %eax
movl %eax, -0x480(%rbp)
movl -0x47c(%rbp), %eax
movl -0x468(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jl 0x3e1d
movl -0x468(%rbp), %ecx
shll %ecx
movl -0x47c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x47c(%rbp)
movl -0x480(%rbp), %eax
movl -0x46c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jl 0x3e46
movl -0x46c(%rbp), %ecx
shll %ecx
movl -0x480(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x480(%rbp)
movl -0x458(%rbp), %eax
addl -0x47c(%rbp), %eax
cmpl $0x0, %eax
jg 0x3e5c
jmp 0x401a
movl -0x458(%rbp), %eax
addl -0x47c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x454(%rbp), %eax
addl -0x480(%rbp), %eax
cmpl $0x0, %eax
jg 0x3e81
jmp 0x401a
movl -0x454(%rbp), %eax
addl -0x480(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x444(%rbp), %eax
imull 0xc2f7(%rip), %eax      # 0x10194
addl -0x448(%rbp), %eax
imull 0xc2e6(%rip), %eax      # 0x10190
movl %eax, %eax
movq %rax, -0x488(%rbp)
movq $0x0, -0x490(%rbp)
movq -0x490(%rbp), %rax
movl 0xc2c5(%rip), %ecx      # 0x10190
cmpq %rcx, %rax
jae 0x3f4d
movq -0x490(%rbp), %rsi
movq -0x488(%rbp), %rax
addq %rax, %rsi
leaq 0x102d8(%rip), %rdi     # 0x141c0
callq 0x4660
movq %rdx, -0x638(%rbp)
movq %rax, -0x630(%rbp)
jmp 0x3efd
movq -0x638(%rbp), %rax
movq -0x630(%rbp), %rcx
movq %rcx, -0x4a0(%rbp)
movq %rax, -0x498(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0x46c0
andb $0x1, %al
movzbl %al, %eax
addl -0x478(%rbp), %eax
movl %eax, -0x478(%rbp)
movq -0x490(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x490(%rbp)
jmp 0x3ebe
movl -0x478(%rbp), %eax
cmpl 0xc237(%rip), %eax      # 0x10190
jb 0x3f60
jmp 0x402e
movq -0x450(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x21b0
jmp 0x3f72
leaq -0x20(%rbp), %rdi
callq 0x84d0
jmp 0x3f7d
jmp 0x3f7f
leaq -0x4c8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x46f0
jmp 0x3f91
movq -0x450(%rbp), %rdx
leaq -0x20(%rbp), %rdi
leaq -0x4c8(%rbp), %rsi
callq 0x9150
movb %al, -0x639(%rbp)
jmp 0x3fb0
leaq -0x4c8(%rbp), %rdi
callq 0x4730
movb -0x639(%rbp), %al
testb $0x1, %al
jne 0x3fc8
jmp 0x4018
movq -0x88(%rbp), %rdi
movq -0x450(%rbp), %rcx
movl -0x444(%rbp), %r8d
movl -0x448(%rbp), %r9d
leaq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x2410
jmp 0x3ff3
jmp 0x3f7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0x4c8(%rbp), %rdi
callq 0x4730
jmp 0x4574
jmp 0x401a
movl -0x474(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x474(%rbp)
jmp 0x3dbc
jmp 0x4030
movl -0x470(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x470(%rbp)
jmp 0x3d9c
movl $0x0, -0x4cc(%rbp)
movl -0x444(%rbp), %eax
imull 0xc139(%rip), %eax      # 0x10194
addl -0x448(%rbp), %eax
imull 0xc128(%rip), %eax      # 0x10190
movl %eax, %eax
movq %rax, -0x4d8(%rbp)
movq $0x0, -0x4e0(%rbp)
movq -0x4e0(%rbp), %rax
movl 0xc107(%rip), %ecx      # 0x10190
cmpq %rcx, %rax
jae 0x410b
movq -0x4e0(%rbp), %rsi
movq -0x4d8(%rbp), %rax
addq %rax, %rsi
leaq 0x1011a(%rip), %rdi     # 0x141c0
callq 0x4660
movq %rdx, -0x650(%rbp)
movq %rax, -0x648(%rbp)
jmp 0x40bb
movq -0x650(%rbp), %rax
movq -0x648(%rbp), %rcx
movq %rcx, -0x4f0(%rbp)
movq %rax, -0x4e8(%rbp)
leaq -0x4f0(%rbp), %rdi
callq 0x46c0
andb $0x1, %al
movzbl %al, %eax
addl -0x4cc(%rbp), %eax
movl %eax, -0x4cc(%rbp)
movq -0x4e0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4e0(%rbp)
jmp 0x407c
movl -0x444(%rbp), %eax
movl 0xc07d(%rip), %ecx      # 0x10194
imull %ecx, %eax
movl -0x448(%rbp), %ecx
addl %ecx, %eax
movl 0xc068(%rip), %ecx      # 0x10190
imull %ecx, %eax
movq %rax, -0x4f8(%rbp)
movl -0x444(%rbp), %esi
movl -0x448(%rbp), %edx
movl -0x4cc(%rbp), %ecx
movl 0xc045(%rip), %r8d      # 0x10190
leaq 0x7110(%rip), %rdi      # 0xb262
xorl %eax, %eax
callq 0x2050
jmp 0x415b
movq $0x0, -0x500(%rbp)
movq -0x500(%rbp), %rax
movl 0xc01d(%rip), %ecx      # 0x10190
cmpq %rcx, %rax
jae 0x41fd
movq -0x500(%rbp), %rsi
movq -0x4f8(%rbp), %rax
addq %rax, %rsi
leaq 0x1002c(%rip), %rdi     # 0x141c0
callq 0x4660
movq %rdx, -0x660(%rbp)
movq %rax, -0x658(%rbp)
jmp 0x41a9
movq -0x660(%rbp), %rax
movq -0x658(%rbp), %rcx
movq %rcx, -0x510(%rbp)
movq %rax, -0x508(%rbp)
leaq -0x510(%rbp), %rdi
callq 0x46c0
movzbl %al, %esi
leaq 0x70b1(%rip), %rdi      # 0xb28c
xorl %eax, %eax
callq 0x2050
jmp 0x41e4
jmp 0x41e6
movq -0x500(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x500(%rbp)
jmp 0x4166
leaq 0x70b8(%rip), %rdi      # 0xb2bc
xorl %eax, %eax
callq 0x2050
jmp 0x420d
movl -0x4cc(%rbp), %eax
cmpl 0xbf77(%rip), %eax      # 0x10190
jae 0x4246
movl -0x444(%rbp), %esi
movl -0x448(%rbp), %edx
movl -0x4cc(%rbp), %ecx
movl 0xbf5c(%rip), %r8d      # 0x10190
leaq 0x7054(%rip), %rdi      # 0xb28f
xorl %eax, %eax
callq 0x2050
jmp 0x4244
jmp 0x4246
movq -0x450(%rbp), %rdi
callq 0x2180
jmp 0x4254
jmp 0x4256
movl -0x448(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x448(%rbp)
jmp 0x3c1f
jmp 0x426c
movl -0x444(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x444(%rbp)
jmp 0x3c03
jmp 0x4282
movq -0x440(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x440(%rbp)
jmp 0x3bcf
jmp 0x429b
movq -0x438(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x438(%rbp)
jmp 0x3bb6
movq $0x0, -0x518(%rbp)
movq $0x0, -0x520(%rbp)
movq -0x520(%rbp), %rax
movq %rax, -0x668(%rbp)
leaq 0xfee3(%rip), %rdi      # 0x141c0
callq 0x45e0
movq %rax, %rcx
movq -0x668(%rbp), %rax
cmpq %rcx, %rax
jae 0x436d
movq -0x520(%rbp), %rsi
leaq 0xfec1(%rip), %rdi      # 0x141c0
callq 0x4660
movq %rdx, -0x678(%rbp)
movq %rax, -0x670(%rbp)
jmp 0x4314
movq -0x678(%rbp), %rax
movq -0x670(%rbp), %rcx
movq %rcx, -0x530(%rbp)
movq %rax, -0x528(%rbp)
leaq -0x530(%rbp), %rdi
callq 0x46c0
testb $0x1, %al
jne 0x4342
jmp 0x4354
movq -0x518(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x518(%rbp)
jmp 0x4356
movq -0x520(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x520(%rbp)
jmp 0x42c8
movq -0x518(%rbp), %rax
movq %rax, -0x680(%rbp)
leaq 0xfe3e(%rip), %rdi      # 0x141c0
callq 0x45e0
movq -0x680(%rbp), %rsi
movq %rax, %rdx
leaq 0x6f26(%rip), %rdi      # 0xb2be
xorl %eax, %eax
callq 0x2050
jmp 0x43a1
movq -0x518(%rbp), %rax
movq %rax, -0x688(%rbp)
leaq 0xfe0a(%rip), %rdi      # 0x141c0
callq 0x45e0
movq %rax, %rcx
movq -0x688(%rbp), %rax
cmpq %rcx, %rax
jae 0x44fe
leaq 0x6f13(%rip), %rdi      # 0xb2e8
xorl %eax, %eax
callq 0x2050
jmp 0x43de
movq $0x0, -0x538(%rbp)
movq -0x538(%rbp), %rax
movq %rax, -0x690(%rbp)
leaq 0xfdc2(%rip), %rdi      # 0x141c0
callq 0x45e0
movq %rax, %rcx
movq -0x690(%rbp), %rax
cmpq %rcx, %rax
jae 0x44fc
movq -0x538(%rbp), %rsi
leaq 0xfd9c(%rip), %rdi      # 0x141c0
callq 0x4660
movq %rdx, -0x6a0(%rbp)
movq %rax, -0x698(%rbp)
jmp 0x4439
movq -0x6a0(%rbp), %rax
movq -0x698(%rbp), %rcx
movq %rcx, -0x548(%rbp)
movq %rax, -0x540(%rbp)
leaq -0x548(%rbp), %rdi
callq 0x46c0
xorb $-0x1, %al
testb $0x1, %al
jne 0x4469
jmp 0x44e3
movq -0x538(%rbp), %rsi
movl 0xbd1e(%rip), %eax      # 0x10194
movl %eax, %ecx
xorl %eax, %eax
movl %eax, -0x6ac(%rbp)
movl %eax, %edx
movq %rdx, -0x6b8(%rbp)
movq %rsi, %rax
divq %rcx
movq -0x6b8(%rbp), %rdx
movl 0xbcf4(%rip), %edi      # 0x10190
divq %rdi
movq -0x6b8(%rbp), %rdx
movq %rax, -0x6a8(%rbp)
movq %rsi, %rax
divq %rdi
movq %rdx, %r8
movq -0x6b8(%rbp), %rdx
divq %rcx
movl -0x6ac(%rbp), %eax
movq %rdx, %rcx
movq -0x6a8(%rbp), %rdx
incq %r8
leaq 0x6e20(%rip), %rdi      # 0xb2fa
callq 0x2050
jmp 0x44e1
jmp 0x44e3
jmp 0x44e5
movq -0x538(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x538(%rbp)
jmp 0x43e9
jmp 0x44fe
movl 0xbc94(%rip), %esi      # 0x10198
movl 0xbc8a(%rip), %edx      # 0x10194
movl 0xbc80(%rip), %ecx      # 0x10190
movl 0xbc85(%rip), %r8d      # 0x1019c
movl 0xbc82(%rip), %r9d      # 0x101a0
leaq 0x6cb5(%rip), %rdi      # 0xb1da
xorl %eax, %eax
callq 0x2050
jmp 0x452e
movq -0x88(%rbp), %rdi
callq 0x2180
jmp 0x453c
movl $0x0, -0x4(%rbp)
movl $0x1, -0x90(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x2110
leaq -0x60(%rbp), %rdi
callq 0x4970
leaq -0x48(%rbp), %rdi
callq 0x4730
movl -0x4(%rbp), %eax
addq $0x6c0, %rsp            # imm = 0x6C0
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x2110
leaq -0x60(%rbp), %rdi
callq 0x4970
leaq -0x48(%rbp), %rdi
callq 0x4730
movq -0xd0(%rbp), %rdi
callq 0x2290
nopl (%rax,%rax)