// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x338, %rsp            # imm = 0x338
movq %rsi, %rbx
xorl %eax, %eax
movq %rax, -0x48(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, -0x58(%rbp)
movq %rax, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
leaq -0x210(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
cmpl $0x2, %edi
jl 0x3b42
movl %edi, %r12d
movl $0x1, %r15d
leaq -0x360(%rbp), %r13
movq (%rbx,%r15,8), %r14
cmpb $0x2d, (%r14)
jne 0x2894
cmpb $0x2d, 0x1(%r14)
leaq 0x1(%r14), %r14
je 0x2825
movq %r14, %rdi
leaq 0x38cd(%rip), %rsi      # 0x6107
callq 0x21d0
testl %eax, %eax
je 0x28cc
movq %r14, %rdi
leaq 0x38bc(%rip), %rsi      # 0x610d
callq 0x21d0
testl %eax, %eax
je 0x28d8
movq %r14, %rdi
leaq 0x38ae(%rip), %rsi      # 0x6112
callq 0x21d0
testl %eax, %eax
je 0x290e
movq %r14, %rdi
leaq 0x389d(%rip), %rsi      # 0x6118
callq 0x21d0
testl %eax, %eax
jne 0x3b6f
movl $0x2, 0x68d2(%rip)      # 0x9164
jmp 0x2900
movq %r13, %rdi
movq %r14, %rsi
leaq -0x6d(%rbp), %rdx
callq 0x2090
leaq -0x90(%rbp), %rdi
movq %r13, %rsi
callq 0x3fea
movq -0x360(%rbp), %rdi
leaq -0x350(%rbp), %rax
cmpq %rax, %rdi
je 0x2900
callq 0x2140
jmp 0x2900
movl $0x12, 0x688a(%rip)     # 0x9160
jmp 0x28e2
movl $0x9, 0x687e(%rip)      # 0x9160
movl $0x2, 0x6878(%rip)      # 0x9164
movl $0x50, 0x6872(%rip)     # 0x9168
movl $0x200, 0x686c(%rip)    # imm = 0x200
incq %r15
cmpq %r12, %r15
jne 0x281b
jmp 0x291a
movl $0x1, 0x684c(%rip)      # 0x9164
jmp 0x2900
leaq 0x3810(%rip), %rdi      # 0x6131
leaq 0x3812(%rip), %rsi      # 0x613a
callq 0x2190
movl $0x1, -0x34(%rbp)
movq %rax, -0xd0(%rbp)
testq %rax, %rax
je 0x3ced
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
je 0x35eb
xorl %r14d, %r14d
leaq -0xa8(%rbp), %r12
cmpl $0x0, 0x6803(%rip)      # 0x916c
jne 0x2b48
leaq 0x39c9(%rip), %rdi      # 0x633f
callq 0x21f0
movq %r14, %rdi
shlq $0x5, %rdi
addq -0x90(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5065
movq %rax, %rbx
testq %rax, %rax
je 0x2b48
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x4ae8
testb %al, %al
je 0x2b40
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
movq %r12, %rdi
callq 0x4a8c
movl $0x140, %edx            # imm = 0x140
leaq -0x360(%rbp), %rdi
xorl %esi, %esi
callq 0x20d0
movups -0x68(%rbp), %xmm0
movaps %xmm0, -0x200(%rbp)
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rsi
movq %rax, %r13
leaq -0x1f0(%rbp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
subq %rsi, %r13
je 0x2a2d
js 0x3b65
movq %r13, %rdi
callq 0x2160
movq %rax, %r12
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
movq %rax, %r15
subq %rsi, %r15
jmp 0x2a33
movq %r13, %r15
xorl %r12d, %r12d
movq %r12, -0x1f0(%rbp)
movq %r12, -0x1e8(%rbp)
addq %r12, %r13
movq %r13, -0x1e0(%rbp)
cmpq %rsi, %rax
je 0x2a5b
movq %r12, %rdi
movq %r15, %rdx
callq 0x2210
addq %r15, %r12
movq %r12, -0x1e8(%rbp)
leaq -0xa8(%rbp), %r12
movq %r12, %rdi
leaq -0x200(%rbp), %rsi
movq %rbx, %rdx
callq 0x51b3
movl %eax, %r15d
movq -0x1f0(%rbp), %rdi
testq %rdi, %rdi
je 0x2a92
callq 0x2140
testb %r15b, %r15b
je 0x2afc
leaq -0x6d(%rbp), %rdi
callq 0x534a
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x5305
cmpl $0xfe, %eax
jne 0x29dc
leaq -0x6d(%rbp), %rdi
movq %r12, %rsi
leaq -0x68(%rbp), %rdx
movq %rbx, %rcx
callq 0x5382
testl %eax, %eax
js 0x29dc
movb -0x6c(%rbp), %al
orb -0x6d(%rbp), %al
jne 0x29dc
movzbl -0x6a(%rbp), %eax
cmpq $0x27, %rax
ja 0x29dc
incq -0x360(%rbp,%rax,8)
jmp 0x29dc
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %eax, %eax
xorl %edx, %edx
movq %rdx, %rsi
movq -0x360(%rbp,%rax,8), %rdx
cmpq %rdx, %rsi
cmovaq %rsi, %rdx
cmovbl %eax, %ecx
incq %rax
cmpq $0x28, %rax
jne 0x2b05
cmpq $0x6, %rdx
setae %al
testl %ecx, %ecx
setns %dl
testb %dl, %al
je 0x2b40
movl $0x80, %eax
shll %cl, %eax
movl %eax, 0x662c(%rip)      # 0x916c
movq %rbx, %rdi
callq 0x2150
incq %r14
movq -0x90(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rdx, %r14
jb 0x2962
cmpq %rax, %rcx
je 0x35eb
xorl %r14d, %r14d
leaq -0xa8(%rbp), %r12
cmpl $0x0, 0x65e6(%rip)      # 0x916c
je 0x2d9b
cmpl $0x0, 0x65dd(%rip)      # 0x9170
jne 0x2d9b
leaq 0x3779(%rip), %rdi      # 0x6319
callq 0x21f0
movq %r14, %rdi
shlq $0x5, %rdi
addq -0x90(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x5065
movq %rax, %rbx
testq %rax, %rax
je 0x2d9b
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x4ae8
movq %r14, -0x40(%rbp)
testb %al, %al
je 0x2d8f
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
movq %r12, %rdi
callq 0x4a8c
xorl %r14d, %r14d
movq $0x0, -0x30(%rbp)
movups -0x68(%rbp), %xmm0
movaps %xmm0, -0x1d0(%rbp)
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rsi
movq %rax, %r12
leaq -0x1c0(%rbp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
subq %rsi, %r12
je 0x2c56
js 0x3b6a
movq %r12, %rdi
callq 0x2160
movq %rax, %r15
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
movq %rax, %r13
subq %rsi, %r13
jmp 0x2c5c
movq %r12, %r13
xorl %r15d, %r15d
movq %r15, -0x1c0(%rbp)
movq %r15, -0x1b8(%rbp)
addq %r15, %r12
movq %r12, -0x1b0(%rbp)
cmpq %rsi, %rax
je 0x2c84
movq %r15, %rdi
movq %r13, %rdx
callq 0x2210
addq %r13, %r15
movq %r15, -0x1b8(%rbp)
leaq -0xa8(%rbp), %r12
movq %r12, %rdi
leaq -0x1d0(%rbp), %rsi
movq %rbx, %rdx
callq 0x51b3
movl %eax, %r15d
movq -0x1c0(%rbp), %rdi
testq %rdi, %rdi
je 0x2cbb
callq 0x2140
testb %r15b, %r15b
je 0x2d53
leaq -0x360(%rbp), %rdi
callq 0x534a
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x5305
cmpl $0xfe, %eax
jne 0x2c05
leaq -0x360(%rbp), %rdi
movq %r12, %rsi
leaq -0x68(%rbp), %rdx
movq %rbx, %rcx
callq 0x5382
testl %eax, %eax
js 0x2c05
cmpb $0x0, -0x35f(%rbp)
jne 0x2c05
leaq -0x360(%rbp), %rdi
callq 0x536a
cmpl 0x6445(%rip), %eax      # 0x916c
jne 0x2c05
movzbl -0x360(%rbp), %eax
cmpl $0x2, %eax
je 0x2d4a
cmpl $0x1, %eax
jne 0x2c05
incq %r14
jmp 0x2c05
incq -0x30(%rbp)
jmp 0x2c05
movq -0x30(%rbp), %rdx
cmpq $0x4, %rdx
setae %al
cmpq $0x4, %r14
setae %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x2d8f
movq %rdx, %rcx
shrq %rcx
movl $0x2, %eax
cmpq %rcx, %r14
ja 0x2d89
shrq %r14
movl $0x1, %eax
cmpq %r14, %rdx
jbe 0x2d8f
movl %eax, 0x63e1(%rip)      # 0x9170
movq %rbx, %rdi
callq 0x2150
movq -0x40(%rbp), %r14
incq %r14
movq -0x90(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rdx, %r14
jb 0x2b7f
cmpq %rax, %rcx
je 0x35eb
xorl %ebx, %ebx
leaq -0xa8(%rbp), %r12
cmpl $0x0, 0x6388(%rip)      # 0x9160
jne 0x2fec
cmpl $0x0, 0x6387(%rip)      # 0x916c
je 0x2fec
cmpl $0x0, 0x637e(%rip)      # 0x9170
je 0x2fec
leaq 0x34f6(%rip), %rdi      # 0x62f5
callq 0x21f0
xorl %r14d, %r14d
movq %rbx, -0x30(%rbp)
shlq $0x5, %rbx
movq %rbx, -0x40(%rbp)
movq -0x90(%rbp), %rdi
addq -0x40(%rbp), %rdi
movl 0x634c(%rip), %esi      # 0x9170
imull %r14d, %esi
xorl %edx, %edx
callq 0x5065
movq %rax, %rbx
testq %rax, %rax
je 0x2fcd
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x4ae8
testb %al, %al
je 0x2fc5
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
movq %r12, %rdi
callq 0x4a8c
movups -0x68(%rbp), %xmm0
movaps %xmm0, -0x1a0(%rbp)
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rsi
movq %rax, %r12
leaq -0x190(%rbp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
subq %rsi, %r12
je 0x2eb7
js 0x3b3d
movq %r12, %rdi
callq 0x2160
movq %rax, %r15
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
movq %rax, %r13
subq %rsi, %r13
jmp 0x2ebd
movq %r12, %r13
xorl %r15d, %r15d
movq %r15, -0x190(%rbp)
movq %r15, -0x188(%rbp)
addq %r15, %r12
movq %r12, -0x180(%rbp)
cmpq %rsi, %rax
je 0x2ee5
movq %r15, %rdi
movq %r13, %rdx
callq 0x2210
addq %r13, %r15
movq %r15, -0x188(%rbp)
leaq -0xa8(%rbp), %r12
movq %r12, %rdi
leaq -0x1a0(%rbp), %rsi
movq %rbx, %rdx
callq 0x51b3
movl %eax, %r15d
movq -0x190(%rbp), %rdi
testq %rdi, %rdi
je 0x2f1c
callq 0x2140
testb %r15b, %r15b
je 0x2fc5
leaq -0x360(%rbp), %rdi
callq 0x534a
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x5305
cmpl $0xfe, %eax
jne 0x2e66
leaq -0x360(%rbp), %rdi
movq %r12, %rsi
leaq -0x68(%rbp), %rdx
movq %rbx, %rcx
callq 0x5382
testl %eax, %eax
js 0x2e66
movzbl -0x360(%rbp), %eax
cmpl %eax, %r14d
jne 0x2e66
cmpb $0x0, -0x35f(%rbp)
jne 0x2e66
leaq -0x360(%rbp), %rdi
callq 0x536a
cmpl 0x61d4(%rip), %eax      # 0x916c
jne 0x2e66
movzbl -0x35e(%rbp), %eax
cmpl $0x18, %eax
ja 0x2e66
cmpl %eax, 0x61ac(%rip)      # 0x9160
jae 0x2e66
movl %eax, 0x61a0(%rip)      # 0x9160
jmp 0x2e66
movq %rbx, %rdi
callq 0x2150
incl %r14d
cmpl $0x14, %r14d
jne 0x2e13
movq -0x90(%rbp), %rax
movq -0x88(%rbp), %rcx
movq -0x30(%rbp), %rbx
incq %rbx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rdx, %rbx
jb 0x2dd1
cmpq %rax, %rcx
je 0x35eb
movl 0x614f(%rip), %edx      # 0x9160
movl 0x614d(%rip), %esi      # 0x9164
xorl %ebx, %ebx
leaq -0xa8(%rbp), %r12
testl %edx, %edx
je 0x325e
cmpl $0x0, 0x613d(%rip)      # 0x916c
je 0x325e
cmpl $0x0, 0x6134(%rip)      # 0x9170
je 0x325e
testl %esi, %esi
jne 0x325e
leaq 0x328c(%rip), %rdi      # 0x62dd
callq 0x21f0
xorl %r14d, %r14d
movq %rbx, -0x98(%rbp)
shlq $0x5, %rbx
movq %rbx, -0x40(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x90(%rbp), %rdi
addq -0x40(%rbp), %rdi
movl 0x60f0(%rip), %esi      # 0x9170
imull %r14d, %esi
movl $0x1, %edx
callq 0x5065
movq %rax, %rbx
testq %rax, %rax
je 0x3225
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x4ae8
testb %al, %al
je 0x321d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
movq %r12, %rdi
callq 0x4a8c
movups -0x68(%rbp), %xmm0
movaps %xmm0, -0x170(%rbp)
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rsi
movq %rax, %r12
leaq -0x160(%rbp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
subq %rsi, %r12
je 0x3116
js 0x3b60
movq %r12, %rdi
callq 0x2160
movq %rax, %r15
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
movq %rax, %r13
subq %rsi, %r13
jmp 0x311c
movq %r12, %r13
xorl %r15d, %r15d
movq %r15, -0x160(%rbp)
movq %r15, -0x158(%rbp)
addq %r15, %r12
movq %r12, -0x150(%rbp)
cmpq %rsi, %rax
je 0x3144
movq %r15, %rdi
movq %r13, %rdx
callq 0x2210
addq %r13, %r15
movq %r15, -0x158(%rbp)
leaq -0xa8(%rbp), %r12
movq %r12, %rdi
leaq -0x170(%rbp), %rsi
movq %rbx, %rdx
callq 0x51b3
movl %eax, %r15d
movq -0x160(%rbp), %rdi
testq %rdi, %rdi
je 0x317b
callq 0x2140
testb %r15b, %r15b
je 0x321d
leaq -0x360(%rbp), %rdi
callq 0x534a
movq %r12, %rdi
leaq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x5305
cmpl $0xfe, %eax
jne 0x30c5
leaq -0x360(%rbp), %rdi
movq %r12, %rsi
leaq -0x68(%rbp), %rdx
movq %rbx, %rcx
callq 0x5382
testl %eax, %eax
js 0x30c5
movzbl -0x360(%rbp), %eax
cmpl %eax, %r14d
jne 0x30c5
cmpb $0x1, -0x35f(%rbp)
jne 0x30c5
leaq -0x360(%rbp), %rdi
callq 0x536a
cmpl 0x5f75(%rip), %eax      # 0x916c
jne 0x30c5
movzbl -0x35e(%rbp), %eax
cmpl $0x18, %eax
ja 0x30c5
movl -0x30(%rbp), %ecx
cmpl %eax, %ecx
cmovbel %eax, %ecx
movl %ecx, -0x30(%rbp)
jmp 0x30c5
movq %rbx, %rdi
callq 0x2150
incl %r14d
cmpl $0x14, %r14d
jne 0x306f
movl 0x5f28(%rip), %edx      # 0x9160
xorl %esi, %esi
cmpl %edx, -0x30(%rbp)
sete %sil
incl %esi
movl %esi, 0x5f1b(%rip)      # 0x9164
movq -0x90(%rbp), %rax
movq -0x88(%rbp), %rcx
movq -0x98(%rbp), %rbx
incq %rbx
movq %rcx, %rdi
subq %rax, %rdi
sarq $0x5, %rdi
cmpq %rdi, %rbx
jb 0x3020
movl 0x5eee(%rip), %esi      # 0x9168
movl 0x5eef(%rip), %r9d      # 0x9170
cmpq %rax, %rcx
je 0x35f8
leaq -0xa8(%rbp), %r14
movq $0x0, -0xb0(%rbp)
cmpl $0x0, 0x5ebd(%rip)      # 0x9160
je 0x35bd
cmpl $0x0, 0x5ebc(%rip)      # 0x916c
je 0x35bd
testl %r9d, %r9d
je 0x35bd
cmpl $0x0, 0x5e9e(%rip)      # 0x9164
je 0x35bd
testl %esi, %esi
jne 0x35bd
leaq 0x2fe9(%rip), %rdi      # 0x62c4
callq 0x21f0
movl 0x5e89(%rip), %r9d      # 0x9170
cmpl $0x54, %r9d
jbe 0x32f8
movl 0x5e75(%rip), %esi      # 0x9168
jmp 0x35bd
xorl %ebx, %ebx
movq -0xb0(%rbp), %rax
shlq $0x5, %rax
movq %rax, -0x98(%rbp)
movl 0x5e52(%rip), %eax      # 0x9164
movq %rax, -0xc8(%rbp)
testq %rax, %rax
je 0x354c
xorl %r15d, %r15d
movq $0x0, -0xb8(%rbp)
movl %ebx, -0x30(%rbp)
leaq 0x2e03(%rip), %rdi      # 0x613d
movl %ebx, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2040
movq 0x5c7b(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x2180
movq -0x90(%rbp), %rdi
addq -0x98(%rbp), %rdi
movl 0x5e07(%rip), %esi      # 0x9170
imull %ebx, %esi
movl %r15d, %edx
callq 0x5065
movq %rax, %r13
testq %rax, %rax
je 0x353a
movq %r14, %rdi
leaq -0x68(%rbp), %rsi
movq %r13, %rdx
callq 0x4ae8
testb %al, %al
je 0x3532
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
movq %r14, %rdi
callq 0x4a8c
movq $0x0, -0xc0(%rbp)
movq %r15, -0x40(%rbp)
movq %r14, %r12
movups -0x68(%rbp), %xmm0
movaps %xmm0, -0x140(%rbp)
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rsi
movq %rax, %r15
leaq -0x130(%rbp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
subq %rsi, %r15
je 0x340e
js 0x3b8c
movq %r15, %rdi
callq 0x2160
movq %rax, %r14
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
movq %rax, %rbx
subq %rsi, %rbx
jmp 0x3414
movq %r15, %rbx
xorl %r14d, %r14d
movq %r14, -0x130(%rbp)
movq %r14, -0x128(%rbp)
addq %r14, %r15
movq %r15, -0x120(%rbp)
cmpq %rsi, %rax
je 0x343c
movq %r14, %rdi
movq %rbx, %rdx
callq 0x2210
addq %rbx, %r14
movq %r14, -0x128(%rbp)
movq %r12, %r14
movq %r12, %rdi
leaq -0x140(%rbp), %rsi
movq %r13, %rdx
callq 0x51b3
movq -0x40(%rbp), %r15
movl %eax, %ebx
movq -0x130(%rbp), %rdi
testq %rdi, %rdi
je 0x3472
callq 0x2140
testb %bl, %bl
je 0x352f
leaq -0x360(%rbp), %rdi
callq 0x534a
movl -0x30(%rbp), %ebx
movq %r14, %rdi
leaq -0x68(%rbp), %rsi
movq %r13, %rdx
callq 0x5305
cmpl $0xfe, %eax
jne 0x33bd
leaq -0x360(%rbp), %rdi
movq %r14, %rsi
leaq -0x68(%rbp), %rdx
movq %r13, %rcx
callq 0x5382
testl %eax, %eax
js 0x33bd
movzbl -0x360(%rbp), %eax
cmpl %eax, %ebx
jne 0x33bd
movzbl -0x35f(%rbp), %eax
cmpl %eax, %r15d
jne 0x33bd
leaq -0x360(%rbp), %rdi
callq 0x536a
cmpl 0x5c7a(%rip), %eax      # 0x916c
jne 0x33bd
movzbl -0x35e(%rbp), %eax
cmpl %eax, 0x5c5b(%rip)      # 0x9160
jb 0x33bd
incq -0xb8(%rbp)
movq -0xc0(%rbp), %rcx
incq %rcx
movq %rcx, -0xc0(%rbp)
cmpq $0x3, %rcx
jbe 0x33ba
jmp 0x3532
movl -0x30(%rbp), %ebx
movq %r13, %rdi
callq 0x2150
incl %r15d
cmpl 0x5c20(%rip), %r15d     # 0x9164
jb 0x3333
jmp 0x3557
movq $0x0, -0xb8(%rbp)
movq -0xc8(%rbp), %r15
shlq $0x2, %r15
leaq 0x2be0(%rip), %rdi      # 0x6149
xorl %eax, %eax
callq 0x2040
movq 0x5a51(%rip), %rax      # 0x8fc8
movq (%rax), %rdi
callq 0x2180
cmpq %r15, -0xb8(%rbp)
setb %al
movl 0x5bd9(%rip), %esi      # 0x9168
cmpl %ebx, %esi
seta %cl
orb %al, %cl
incl %ebx
testb %cl, %cl
jne 0x35a4
movl %ebx, 0x5bc6(%rip)      # 0x9168
movl %ebx, %esi
movl 0x5bc5(%rip), %r9d      # 0x9170
movl $0x54, %eax
xorl %edx, %edx
divl %r9d
cmpl %eax, %ebx
jb 0x330c
movq -0xb0(%rbp), %rdx
incq %rdx
movq -0x88(%rbp), %rax
subq -0x90(%rbp), %rax
sarq $0x5, %rax
movq %rdx, -0xb0(%rbp)
cmpq %rax, %rdx
jb 0x329c
jmp 0x35f8
movl 0x5b77(%rip), %esi      # 0x9168
movl 0x5b78(%rip), %r9d      # 0x9170
movl 0x5b66(%rip), %edx      # 0x9164
movl 0x5b5c(%rip), %ecx      # 0x9160
movl 0x5b61(%rip), %r8d      # 0x916c
leaq 0x2b46(%rip), %rdi      # 0x6158
xorl %eax, %eax
callq 0x2040
movl 0x5b45(%rip), %eax      # 0x9164
testl %eax, %eax
je 0x3b56
movl 0x5b33(%rip), %esi      # 0x9160
testl %esi, %esi
je 0x3b56
movl 0x5b2d(%rip), %ecx      # 0x9168
testl %ecx, %ecx
je 0x3b56
cmpl $0x0, 0x5b22(%rip)      # 0x916c
je 0x3b56
cmpl $0x0, 0x5b19(%rip)      # 0x9170
je 0x3b56
imull %eax, %esi
imull %ecx, %esi
leaq 0x9b26(%rip), %rdi      # 0xd190
xorl %edx, %edx
callq 0x3e52
movq -0x90(%rbp), %rax
movq -0x88(%rbp), %rcx
leaq 0x2b24(%rip), %rbx      # 0x61aa
leaq -0xa8(%rbp), %r15
movq %rcx, %rdi
xorl %r9d, %r9d
cmpq %rax, %rdi
je 0x3ab8
movl 0x5ac6(%rip), %edx      # 0x9168
leal (%r9,%r9), %esi
movl %esi, -0xc0(%rbp)
leal (,%r9,4), %esi
movl %esi, -0x34(%rbp)
movl %edx, %esi
xorl %r14d, %r14d
movq %r9, -0xd8(%rbp)
testl %esi, %esi
je 0x3a9b
movl $0x0, -0x40(%rbp)
movl 0x5a8c(%rip), %eax      # 0x9164
movq %r14, -0xe0(%rbp)
testl %eax, %eax
movl $0x0, %eax
je 0x3a79
xorl %r13d, %r13d
movq %rbx, %rdi
movl -0x40(%rbp), %r12d
movl %r12d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
shlq $0x5, %rdi
addq -0x90(%rbp), %rdi
movl 0x5a59(%rip), %esi      # 0x9170
imull %r12d, %esi
movl %r13d, -0x30(%rbp)
movl %r13d, %edx
callq 0x5065
movq %rax, %r13
testq %rax, %rax
je 0x397e
movq %r15, %rdi
leaq -0x68(%rbp), %rsi
movq %r13, %rdx
callq 0x4ae8
testb %al, %al
je 0x3a62
movl -0xa0(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0xb8(%rbp)
xorl %edx, %edx
movl -0x34(%rbp), %ecx
cmpl -0xc0(%rbp), %edx
movl $0x0, %eax
cmoval %ecx, %eax
movq %rdx, -0xc8(%rbp)
movl %edx, %ecx
subl %eax, %ecx
addl -0xb0(%rbp), %ecx
movl %ecx, -0x98(%rbp)
xorl %ebx, %ebx
cmpl $0x0, -0x98(%rbp)
jle 0x390b
cmpl -0xc0(%rbp), %ebx
movl $0x0, %ecx
cmoval -0x34(%rbp), %ecx
movl %ebx, %eax
subl %ecx, %eax
movl -0x98(%rbp), %ecx
movl %ecx, -0xa0(%rbp)
addl -0xb8(%rbp), %eax
jle 0x390b
movl %eax, -0x9c(%rbp)
movl 0x598e(%rip), %eax      # 0x9160
testq %rax, %rax
je 0x380f
movq 0x99b2(%rip), %rcx      # 0xd190
movl 0x5980(%rip), %edx      # 0x9164
imull -0x40(%rbp), %edx
addl -0x30(%rbp), %edx
imull %eax, %edx
xorl %esi, %esi
movq %rax, %rdi
movq %rdx, %r8
shrq $0x6, %r8
movq (%rcx,%r8,8), %r8
btq %rdx, %r8
adcl $0x0, %esi
incq %rdx
decq %rdi
jne 0x37f3
jmp 0x3811
xorl %esi, %esi
cmpl %eax, %esi
jae 0x3919
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2170
movq %r15, %rdi
callq 0x4a8c
movups -0x68(%rbp), %xmm0
movaps %xmm0, -0x110(%rbp)
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rsi
movq %rax, %r14
leaq -0x100(%rbp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
subq %rsi, %r14
je 0x387e
js 0x3b38
movq %r14, %rdi
callq 0x2160
movq %rax, %r12
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
movq %rax, %r15
subq %rsi, %r15
jmp 0x3884
movq %r14, %r15
xorl %r12d, %r12d
movq %r12, -0x100(%rbp)
movq %r12, -0xf8(%rbp)
addq %r12, %r14
movq %r14, -0xf0(%rbp)
cmpq %rsi, %rax
je 0x38ac
movq %r12, %rdi
movq %r15, %rdx
callq 0x2210
addq %r15, %r12
movq %r12, -0xf8(%rbp)
leaq -0xa8(%rbp), %r15
movq %r15, %rdi
leaq -0x110(%rbp), %rsi
movq %r13, %rdx
callq 0x51b3
movl %eax, %r14d
movq -0x100(%rbp), %rdi
testq %rdi, %rdi
je 0x38e3
callq 0x2140
testb %r14b, %r14b
je 0x390b
movq -0xd0(%rbp), %rdi
movq %r15, %rsi
leaq -0x68(%rbp), %rdx
movq %r13, %rcx
movl -0x40(%rbp), %r8d
movl -0x30(%rbp), %r9d
callq 0x24dc
jmp 0x382d
leal 0x1(%rbx), %eax
cmpl -0x34(%rbp), %ebx
movl %eax, %ebx
jne 0x378e
movq -0xc8(%rbp), %rdx
leal 0x1(%rdx), %eax
movl -0x34(%rbp), %ecx
cmpl %ecx, %edx
movl %eax, %edx
jne 0x3767
movl 0x582e(%rip), %ebx      # 0x9164
movl 0x5823(%rip), %r14d     # 0x9160
testq %r14, %r14
je 0x398f
movq 0x9847(%rip), %rax      # 0xd190
movl -0x40(%rbp), %ecx
movl %ecx, %r8d
imull %ebx, %r8d
movl -0x30(%rbp), %edx
addl %edx, %r8d
imull %r14d, %r8d
xorl %ecx, %ecx
movq %r14, %rdi
movq %r8, %rsi
shrq $0x6, %rsi
movq (%rax,%rsi,8), %rsi
btq %r8, %rsi
adcl $0x0, %ecx
incq %r8
decq %rdi
jne 0x3962
jmp 0x3994
leaq 0x2930(%rip), %rdi      # 0x62b5
callq 0x21f0
jmp 0x3a4a
xorl %ecx, %ecx
movl -0x30(%rbp), %edx
leaq 0x2835(%rip), %rdi      # 0x61d0
movl -0x40(%rbp), %esi
movl %ecx, -0x98(%rbp)
movl %r14d, %r8d
xorl %eax, %eax
callq 0x2040
cmpl $0x0, 0x57ab(%rip)      # 0x9160
leaq 0x283e(%rip), %r12      # 0x61fa
je 0x3a04
imull -0x40(%rbp), %ebx
addl -0x30(%rbp), %ebx
imull %r14d, %ebx
xorl %r14d, %r14d
leaq (%rbx,%r14), %rax
movq 0x97b9(%rip), %rcx      # 0xd190
movq %rax, %rdx
shrq $0x6, %rdx
movq (%rcx,%rdx,8), %rcx
xorl %esi, %esi
btq %rax, %rcx
setb %sil
movq %r12, %rdi
xorl %eax, %eax
callq 0x2040
incq %r14
movl 0x5761(%rip), %eax      # 0x9160
cmpq %rax, %r14
jb 0x39cc
movl $0xa, %edi
callq 0x21c0
movl 0x574b(%rip), %r8d      # 0x9160
movl -0x98(%rbp), %ecx
cmpl %r8d, %ecx
jae 0x3a34
leaq 0x27d6(%rip), %rdi      # 0x61fd
movl -0x40(%rbp), %esi
movl -0x30(%rbp), %edx
xorl %eax, %eax
callq 0x2040
movq %r13, %rdi
callq 0x2150
leaq 0x2767(%rip), %rbx      # 0x61aa
movq -0xe0(%rbp), %r14
movl -0x30(%rbp), %r13d
incl %r13d
movl 0x570d(%rip), %eax      # 0x9164
cmpl %eax, %r13d
jb 0x36ef
jmp 0x3a6c
movq %r13, %rdi
callq 0x2270
jmp 0x3a4a
movl 0x56f6(%rip), %edx      # 0x9168
movq -0xd8(%rbp), %r9
movl -0x40(%rbp), %ecx
incl %ecx
movl %ecx, -0x40(%rbp)
cmpl %edx, %ecx
jb 0x36df
movq -0x90(%rbp), %rax
movq -0x88(%rbp), %rcx
movl %edx, %esi
jmp 0x3a9d
xorl %esi, %esi
incq %r14
movq %rcx, %r8
subq %rax, %r8
sarq $0x5, %r8
movq %rcx, %rdi
cmpq %r8, %r14
jb 0x36c3
jmp 0x3abb
movq %rax, %rdi
incq %r9
cmpq $0x3, %r9
jne 0x3693
movq 0x96d1(%rip), %rdx      # 0xd1a0
movl 0x96d3(%rip), %ecx      # 0xd1a8
movq 0x96b4(%rip), %rax      # 0xd190
subq %rax, %rdx
shlq $0x3, %rdx
addq %rcx, %rdx
je 0x3b91
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorl %esi, %esi
leaq 0x3f(%rcx), %rdi
xorl %ebx, %ebx
leaq 0x3f(%rsi), %r8
testq %rsi, %rsi
cmovnsq %rsi, %r8
sarq $0x6, %r8
leaq (%rax,%r8,8), %r8
movq %rsi, %r9
andq %rdi, %r9
xorl %r10d, %r10d
cmpq %rcx, %r9
setbe %r10b
movq -0x8(%r8,%r10,8), %r8
btq %rsi, %r8
adcq $0x0, %rbx
incq %rsi
cmpq %rdx, %rsi
jb 0x3afe
jmp 0x3b93
callq 0x2080
callq 0x2080
movq %rbx, %rdi
callq 0x22c6
movl $0x1, -0x34(%rbp)
jmp 0x3ced
callq 0x22a4
jmp 0x3ced
callq 0x2080
callq 0x2080
callq 0x2080
movq 0x546a(%rip), %rax      # 0x8fe0
movq (%rax), %rdi
leaq 0x259e(%rip), %rsi      # 0x611e
movq %r14, %rdx
xorl %eax, %eax
callq 0x21e0
jmp 0x3b4a
callq 0x2080
xorl %ebx, %ebx
leaq 0x2692(%rip), %rdi      # 0x622c
movl $0x0, -0x34(%rbp)
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
movq 0x95ee(%rip), %rax      # 0xd1a0
movl 0x95f0(%rip), %ecx      # 0xd1a8
subq 0x95d1(%rip), %rax      # 0xd190
leaq (%rcx,%rax,8), %rax
cmpq %rax, %rbx
jae 0x3cb3
leaq 0x26d1(%rip), %rdi      # 0x62a4
callq 0x21f0
movq 0x95c1(%rip), %rax      # 0xd1a0
movl 0x95c3(%rip), %ecx      # 0xd1a8
movq 0x95a4(%rip), %rdx      # 0xd190
movq %rax, %rsi
subq %rdx, %rsi
shlq $0x3, %rsi
addq %rcx, %rsi
je 0x3cb3
movabsq $-0x8000000000000000, %r15 # imm = 0x8000000000000000
leaq 0x3f(%r15), %r12
leaq 0x2642(%rip), %rbx      # 0x6256
xorl %r14d, %r14d
leaq 0x3f(%r14), %rsi
testq %r14, %r14
cmovnsq %r14, %rsi
sarq $0x6, %rsi
leaq (%rdx,%rsi,8), %rsi
movq %r14, %rdi
andq %r12, %rdi
xorl %r8d, %r8d
cmpq %r15, %rdi
setbe %r8b
movq -0x8(%rsi,%r8,8), %rsi
btq %r14, %rsi
jb 0x3c9b
movl 0x5519(%rip), %ecx      # 0x9164
movq %r14, %rax
xorl %edx, %edx
divq %rcx
movl 0x5507(%rip), %esi      # 0x9160
xorl %edx, %edx
divq %rsi
movq %rax, %r9
movq %r14, %rax
xorl %edx, %edx
divq %rsi
movq %rdx, %r8
xorl %edx, %edx
divq %rcx
movq %rdx, %rcx
incq %r8
movq %rbx, %rdi
movq %r14, %rsi
movq %r9, %rdx
xorl %eax, %eax
callq 0x2040
movq 0x9512(%rip), %rax      # 0xd1a0
movl 0x9514(%rip), %ecx      # 0xd1a8
movq 0x94f5(%rip), %rdx      # 0xd190
incq %r14
movq %rax, %rsi
subq %rdx, %rsi
movl %ecx, %edi
leaq (%rdi,%rsi,8), %rsi
cmpq %rsi, %r14
jb 0x3c17
movl 0x54af(%rip), %esi      # 0x9168
movl 0x54a5(%rip), %edx      # 0x9164
movl 0x549b(%rip), %ecx      # 0x9160
movl 0x54a0(%rip), %r8d      # 0x916c
movl 0x549d(%rip), %r9d      # 0x9170
leaq 0x247e(%rip), %rdi      # 0x6158
xorl %eax, %eax
callq 0x2040
movq -0xd0(%rbp), %rdi
callq 0x2150
movq -0x220(%rbp), %rdi
leaq -0x210(%rbp), %rax
cmpq %rax, %rdi
je 0x3d05
callq 0x2140
leaq -0x90(%rbp), %rdi
callq 0x3ec6
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x3d1f
callq 0x2140
movl -0x34(%rbp), %eax
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
movq %rax, %rbx
movq -0x360(%rbp), %rdi
leaq -0x350(%rbp), %rax
cmpq %rax, %rdi
jne 0x3dee
jmp 0x3e04
jmp 0x3e01
movq %rax, %rbx
movq -0x130(%rbp), %rdi
jmp 0x3de9
jmp 0x3e01
movq %rax, %rbx
movq -0x1c0(%rbp), %rdi
jmp 0x3de9
jmp 0x3e01
jmp 0x3e01
movq %rax, %rbx
movq -0x1f0(%rbp), %rdi
jmp 0x3de9
jmp 0x3e01
jmp 0x3e01
movq %rax, %rbx
movq -0x160(%rbp), %rdi
jmp 0x3de9
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
movq %rax, %rbx
movq -0x190(%rbp), %rdi
jmp 0x3de9
jmp 0x3e01
movq %rax, %rbx
movq -0x100(%rbp), %rdi
testq %rdi, %rdi
je 0x3e04
callq 0x2140
jmp 0x3e04
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
jmp 0x3e01
movq %rax, %rbx
movq -0x220(%rbp), %rdi
leaq -0x210(%rbp), %rax
cmpq %rax, %rdi
je 0x3e1c
callq 0x2140
leaq -0x90(%rbp), %rdi
callq 0x3ec6
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x3e36
callq 0x2140
movq %rbx, %rdi
callq 0x2220