// File: chhylp123[P]hifiasm/anchor.cpp
// Function: recalu_minimizer_bd(unsigned long, anchor1_t*, asg16_v*, long*, long*, long*, long*, long*, unsigned long, unsigned long, tiny_queue_t*, All_reads*, UC_Read*, char*, unsigned long, unsigned long)
uint64_t recalu_minimizer_bd(uint64_t rid, anchor1_t *z, asg16_v *sc, int64_t *iok, int64_t *ink, int64_t *ick, int64_t *str_s, int64_t *str_e, uint64_t mz_k, uint64_t mz_h, tiny_queue_t *tq, All_reads *rref, UC_Read *tu, char *qstr, uint64_t qs, uint64_t qe)
{
	int64_t id = z->srt>>33; char *str = NULL; uint64_t rpos, rspan;
	int64_t ok = *iok, nk = *ink, ck = *ick, cn = sc->n, s0, e0, s1, e1, si, ei, os, oe, ots, ote, ol, wo[2], wn[2], weo[2], wen[2], ovlp, len = Get_READ_LENGTH((*rref), id); uint16_t op, bq, bt; uint32_t cl;
	e0 = ((uint32_t)z->srt) + 1; s0 = e0 - z->other_off; s1 = e1 = si = ei = -1; weo[0] = weo[1] = wen[0] = wen[1] = -1; 
	if(e0 <= s0) return 0;

	///debug
	// ok = nk = ck = 0;

	if((ck < 0) || (ck > cn)) {//(*ck) == cn is allowed
        ck = ok = nk = 0;
    }

	// if(id == 1/**s0 == 10260 && e0 == 10334**/) {
	// 	fprintf(stderr, "\n\n-0-qk::%ld,\ttk::%ld,\tck::%ld,\ts0::%ld,\te0::%ld\n", ok, nk, ck, s0, e0);
	// }

	while (ck > 0 && ok >= s0) {///x -> t; y -> p; first insertion and then match/mismatch
        --ck;
        op = sc->a[ck]>>14;
        // ol = (((op == 1) || (op == 2))?(sc->a[ck]&(0xfff)):(sc->a[ck]&(0x3fff)));
		if((op == 2) || (op == 3)) {
            ol = sc->a[ck]&(0xfff);
        } else if(op == 1) {
            ol = sc->a[ck]&(0x3ff);
        } else {
            ol = sc->a[ck]&(0x3fff);
        }
        if(op != 2) ok -= ol;
        if(op != 3) nk -= ol;
    }

	// char cm[4]; cm[0] = 'M'; cm[1] = 'S'; cm[2] = 'I'; cm[3] = 'D';  
	// if(id == 1/**s0 == 10260 && e0 == 10334**/) {
	// 	fprintf(stderr, "-1-qk::%ld,\ttk::%ld,\tck::%ld\n", ok, nk, ck);
	// }
	while (ck < cn && ok < e0) { ///[s0, e0)
        wo[0] = ok; wn[0] = nk; 
        // ck = pop_trace_bp(sc, ck, &op, &b, &cl);
		ck = pop_trace_bp_f(sc, ck, &op, &bq, &bt, &cl);
        if(op != 2) ok += cl;
        if(op != 3) nk += cl;
        wo[1] = ok; wn[1] = nk;  

		os = ((s0 >= wo[0])? s0 : wo[0]);
		oe = ((e0 <= wo[1])? e0 : wo[1]);
		// os = MAX(s0, wo[0]); oe = MIN(e0, wo[1]);
        ovlp = ((oe>os)? (oe-os):0);
		// if(id == 1/**s0 == 10260 && e0 == 10334**/) {
		// 	fprintf(stderr, "%u%c(q::[%ld,%ld))(t::[%ld,%ld))(ck::%ld)\n", cl, cm[op], wo[0], wo[1], wn[0], wn[1], ck);
		// }

		if(op != 2) {
			if(!ovlp) continue;
		} else {///wo[0] == wo[1]
			if(wo[0] < s0 || wo[0] >= e0) continue;
		}

		if(op < 2) {
            ots = os - wo[0] + wn[0]; ote = oe - wo[0] + wn[0];
        } else {///op == 2: more y; p == 3: more x
            ots = wn[0]; ote = wn[1];
        } 

		if(s1 == -1) {
			s1 = ots;
			// if((op == 0) && (wn[1] > ots) && ((wn[0] < ots) || (ots == 0))) si = 1;
			if((op == 0) && (wo[1] > s0) && ((wo[0] < s0) || (s1 == 0))) si = 1;
		}
		
		e1 = ote;
		if((op == 0) && (wo[0] < e0) && ((wo[1] > e0) || (e1 == len))) ei = 1;

        if((op == 0) && (ovlp > 0) && (ovlp > weo[1] - weo[0])) {
			weo[0] = os; weo[1] = oe;
			wen[0] = ots; wen[1] = ote;
        }
    }

	while (ck < cn && ok <= e0) { ///[s0, e0)
        wo[0] = ok; wn[0] = nk; 
        // pop_trace_bp(sc, ck, &op, &b, &cl);
		pop_trace_bp_f(sc, ck, &op, &bq, &bt, &cl);
		if(op != 2) break;
		// ck = pop_trace_bp(sc, ck, &op, &b, &cl);
		ck = pop_trace_bp_f(sc, ck, &op, &bq, &bt, &cl);
        // if(op != 2) ok += cl;
        // if(op != 3) nk += cl;
		nk += cl;
        wo[1] = ok; wn[1] = nk;  

		// if(id == 1/**s0 == 10260 && e0 == 10334**/) {
		// 	fprintf(stderr, "%u%c(q::[%ld,%ld))(t::[%ld,%ld))(ck::%ld)\n", cl, cm[op], wo[0], wo[1], wn[0], wn[1], ck);
		// }

		if(wo[0] >= s0 && wo[0] <= e0) {
			ots = wn[0]; ote = wn[1];
			if(s1 == -1) s1 = ots;
			e1 = ote;
		}
    }

	assert(wen[1] <= len);
	assert(e1 <= len);

	*iok = ok; *ink = nk; *ick = ck; 
	if(e1 <= s1) return 0;
	rpos = rspan = ((uint64_t)-1);

	if(weo[0] == s0 && weo[1] == e0) {
		rpos = wen[1]-1; rspan = e0 - s0;
		/** 
		if(si == 1 && ei == 1) {
			z->srt >>= 32; z->srt <<= 32; z->srt |= ((uint64_t)(wen[1]-1));
			///debug
			// char sstr[256]; recover_UC_Read_sub_region(sstr, wen[0], wen[1] - wen[0], 0, rref, id);
			// if(recalu_minimizer0(sstr, wen[1] - wen[0], !(asm_opt.flag & HA_F_NO_HPC), mz_k, mz_h, tq, &rpos, &rspan) && (rpos + 1 == ((uint64_t)(wen[1] - wen[0]))) && (((uint64_t)(wen[1] - wen[0])) == rspan)) {
			// 	// fprintf(stderr, "-0-[M::%s]\n", __func__);
			// } else {
			// 	// if(((z->srt>>32)&1) == 0) {
			// 		fprintf(stderr, "-1-[M::%s]\trid::%lu\ttid::%ld\t%c\trg1::[%ld,%ld)\trg0::[%ld,%ld)\tspan::%ld\n", __func__, rid, id, "+-"[(z->srt>>32)&1], wen[0], wen[1], s0, e0, e0 - s0);
			// 		fprintf(stderr, "tstr::%.*s\n", ((uint32_t)(wen[1] - wen[0])), sstr);
			// 		fprintf(stderr, "qstr::%.*s\n", ((uint32_t)(qe - qs)), qstr + qs);
			// 		exit(1);
			// 	// }
			// }
			// if(rid == 3196 && id == 3199) fprintf(stderr, "-full-[M::%s]\n", __func__);
			return 1;
		} 
		**/
	} else {
		if(s1 >= (*str_s) && e1 <= (*str_e)) {
			str = tu->seq + s1 - (*str_s);
		} else {
			if(s1 >= (*str_s) && (s1 < (*str_e)) && (e1 > (*str_e))) {
				UC_Read_resize((*tu), (e1 - (*str_s))); 
				recover_UC_Read_sub_region(tu->seq + (*str_e) - (*str_s), (*str_e), e1 - (*str_e), 0, rref, id);
				str = tu->seq + s1 - (*str_s); (*str_e) = e1;
			} else {
				UC_Read_resize((*tu), (e1 - s1)); 
				recover_UC_Read_sub_region(tu->seq, s1, e1 - s1, 0, rref, id);
				str = tu->seq; (*str_s) = s1; (*str_e) = e1;
			}
		}

		if(recalu_minimizer0(str, e1 - s1, !(asm_opt.flag & HA_F_NO_HPC), mz_k, mz_h, tq, &rpos, &rspan)) {
			rpos += s1;
		}
	}

	if(rpos != ((uint64_t)-1) && rspan != ((uint64_t)-1)) {
        e0 = rpos + 1; s0 = e0 - rspan;
        if(!(asm_opt.flag & HA_F_NO_HPC)) {
			if(si == -1) {
				s0 -= hpc_minimizer_test(id, rref, tu, *str_s, *str_e, s0, len, 1, 8);
				assert(s0 >= 0 && s0 < len && s0 < e0);
			}

			if(ei == -1) {
				e0 += hpc_minimizer_test(id, rref, tu, *str_s, *str_e, e0-1, len, 0, 8);
				assert(e0 >= 0 && e0 < len && s0 < e0);
			}
        }
        
        rpos = e0 - 1; rspan = e0 - s0;
        if(rspan < 256) {
            z->srt >>= 32; z->srt <<= 32; z->srt |= rpos; z->other_off = rspan;
            return 1;
        }
    }
	/**
	if(recalu_minimizer0(str, e1 - s1, !(asm_opt.flag & HA_F_NO_HPC), mz_k, mz_h, tq, &rpos, &rspan)) {
		rpos += s1;
		z->srt >>= 32; z->srt <<= 32; z->srt |= rpos; z->other_off = rspan;
		// fprintf(stderr, "-1-[M::%s]\trid::%lu\ttid::%ld\t%c\trg1::[%ld,%ld)\trg0::[%ld,%ld)\tspan::%ld\n", __func__, rid, id, "+-"[(z->srt>>32)&1], s1, e1, s0, e0, e0 - s0);
		// if(rid == 3196 && id == 3199) fprintf(stderr, "-part-[M::%s]\n", __func__);
		return 1;
	}
	// fprintf(stderr, "-0-[M::%s]\trid::%lu\ttid::%ld\t%c\trg1::[%ld,%ld)\trg0::[%ld,%ld)\tspan::%ld\n", __func__, rid, id, "+-"[(z->srt>>32)&1], s1, e1, s0, e0, e0 - s0);
	**/

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
shrq $0x21, %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq 0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x120(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0xc(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0x80(%rbp)
movq $-0x1, -0xa8(%rbp)
movq $-0x1, -0xa0(%rbp)
movq $-0x1, -0x98(%rbp)
movq $-0x1, -0x90(%rbp)
movq $-0x1, -0x108(%rbp)
movq $-0x1, -0x110(%rbp)
movq $-0x1, -0xf8(%rbp)
movq $-0x1, -0x100(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x80(%rbp), %rax
jg 0x1af4bf
movq $0x0, -0x8(%rbp)
jmp 0x1b0020
cmpq $0x0, -0x70(%rbp)
jl 0x1af4d0
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jle 0x1af4e8
movq $0x0, -0x68(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x70(%rbp)
jmp 0x1af4ea
xorl %eax, %eax
cmpq $0x0, -0x70(%rbp)
movb %al, -0x12d(%rbp)
jle 0x1af50a
movq -0x60(%rbp), %rax
cmpq -0x80(%rbp), %rax
setge %al
movb %al, -0x12d(%rbp)
movb -0x12d(%rbp), %al
testb $0x1, %al
jne 0x1af519
jmp 0x1af604
movq -0x70(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
sarl $0xe, %eax
movw %ax, -0x122(%rbp)
movzwl -0x122(%rbp), %eax
cmpl $0x2, %eax
je 0x1af557
movzwl -0x122(%rbp), %eax
cmpl $0x3, %eax
jne 0x1af577
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0xfff, %eax            # imm = 0xFFF
cltq
movq %rax, -0xd0(%rbp)
jmp 0x1af5c3
movzwl -0x122(%rbp), %eax
cmpl $0x1, %eax
jne 0x1af5a3
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x3ff, %eax            # imm = 0x3FF
cltq
movq %rax, -0xd0(%rbp)
jmp 0x1af5c1
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x3fff, %eax           # imm = 0x3FFF
cltq
movq %rax, -0xd0(%rbp)
jmp 0x1af5c3
movzwl -0x122(%rbp), %eax
cmpl $0x2, %eax
je 0x1af5e1
movq -0xd0(%rbp), %rcx
movq -0x60(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x60(%rbp)
movzwl -0x122(%rbp), %eax
cmpl $0x3, %eax
je 0x1af5ff
movq -0xd0(%rbp), %rcx
movq -0x68(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x68(%rbp)
jmp 0x1af4ea
jmp 0x1af606
movq -0x70(%rbp), %rcx
xorl %eax, %eax
cmpq -0x78(%rbp), %rcx
movb %al, -0x12e(%rbp)
jge 0x1af62c
movq -0x60(%rbp), %rax
cmpq -0x88(%rbp), %rax
setl %al
movb %al, -0x12e(%rbp)
movb -0x12e(%rbp), %al
testb $0x1, %al
jne 0x1af63b
jmp 0x1af938
movq -0x60(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rdi
movq -0x70(%rbp), %rax
movl %eax, %esi
leaq -0x122(%rbp), %rdx
leaq -0x124(%rbp), %rcx
leaq -0x126(%rbp), %r8
leaq -0x12c(%rbp), %r9
callq 0x1b53f0
movl %eax, %eax
movq %rax, -0x70(%rbp)
movzwl -0x122(%rbp), %eax
cmpl $0x2, %eax
je 0x1af69c
movl -0x12c(%rbp), %eax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movzwl -0x122(%rbp), %eax
cmpl $0x3, %eax
je 0x1af6b6
movl -0x12c(%rbp), %eax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x80(%rbp), %rax
cmpq -0xe0(%rbp), %rax
jl 0x1af6e6
movq -0x80(%rbp), %rax
movq %rax, -0x138(%rbp)
jmp 0x1af6f4
movq -0xe0(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x88(%rbp), %rax
cmpq -0xd8(%rbp), %rax
jg 0x1af722
movq -0x88(%rbp), %rax
movq %rax, -0x140(%rbp)
jmp 0x1af730
movq -0xd8(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpq -0xb0(%rbp), %rax
jle 0x1af765
movq -0xb8(%rbp), %rax
subq -0xb0(%rbp), %rax
movq %rax, -0x148(%rbp)
jmp 0x1af770
xorl %eax, %eax
movq %rax, -0x148(%rbp)
jmp 0x1af770
movq -0x148(%rbp), %rax
movq %rax, -0x118(%rbp)
movzwl -0x122(%rbp), %eax
cmpl $0x2, %eax
je 0x1af79b
cmpq $0x0, -0x118(%rbp)
jne 0x1af799
jmp 0x1af606
jmp 0x1af7bf
movq -0xe0(%rbp), %rax
cmpq -0x80(%rbp), %rax
jl 0x1af7b8
movq -0xe0(%rbp), %rax
cmpq -0x88(%rbp), %rax
jl 0x1af7bd
jmp 0x1af606
jmp 0x1af7bf
movzwl -0x122(%rbp), %eax
cmpl $0x2, %eax
jge 0x1af805
movq -0xb0(%rbp), %rax
subq -0xe0(%rbp), %rax
addq -0xf0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rax
subq -0xe0(%rbp), %rax
addq -0xf0(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x1af821
movq -0xf0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $-0x1, -0x90(%rbp)
jne 0x1af876
movq -0xc0(%rbp), %rax
movq %rax, -0x90(%rbp)
movzwl -0x122(%rbp), %eax
cmpl $0x0, %eax
jne 0x1af874
movq -0xd8(%rbp), %rax
cmpq -0x80(%rbp), %rax
jle 0x1af874
movq -0xe0(%rbp), %rax
cmpq -0x80(%rbp), %rax
jl 0x1af869
cmpq $0x0, -0x90(%rbp)
jne 0x1af874
movq $0x1, -0xa0(%rbp)
jmp 0x1af876
movq -0xc8(%rbp), %rax
movq %rax, -0x98(%rbp)
movzwl -0x122(%rbp), %eax
cmpl $0x0, %eax
jne 0x1af8cb
movq -0xe0(%rbp), %rax
cmpq -0x88(%rbp), %rax
jge 0x1af8cb
movq -0xd8(%rbp), %rax
cmpq -0x88(%rbp), %rax
jg 0x1af8c0
movq -0x98(%rbp), %rax
cmpq -0x120(%rbp), %rax
jne 0x1af8cb
movq $0x1, -0xa8(%rbp)
movzwl -0x122(%rbp), %eax
cmpl $0x0, %eax
jne 0x1af933
cmpq $0x0, -0x118(%rbp)
jle 0x1af933
movq -0x118(%rbp), %rax
movq -0xf8(%rbp), %rcx
subq -0x100(%rbp), %rcx
cmpq %rcx, %rax
jle 0x1af933
movq -0xb0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x108(%rbp)
jmp 0x1af606
jmp 0x1af93a
movq -0x70(%rbp), %rcx
xorl %eax, %eax
cmpq -0x78(%rbp), %rcx
movb %al, -0x149(%rbp)
jge 0x1af960
movq -0x60(%rbp), %rax
cmpq -0x88(%rbp), %rax
setle %al
movb %al, -0x149(%rbp)
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0x1af96f
jmp 0x1afa7a
movq -0x60(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rdi
movq -0x70(%rbp), %rax
movl %eax, %esi
leaq -0x122(%rbp), %rdx
leaq -0x124(%rbp), %rcx
leaq -0x126(%rbp), %r8
leaq -0x12c(%rbp), %r9
callq 0x1b53f0
movzwl -0x122(%rbp), %eax
cmpl $0x2, %eax
je 0x1af9c1
jmp 0x1afa7a
movq -0x20(%rbp), %rdi
movq -0x70(%rbp), %rax
movl %eax, %esi
leaq -0x122(%rbp), %rdx
leaq -0x124(%rbp), %rcx
leaq -0x126(%rbp), %r8
leaq -0x12c(%rbp), %r9
callq 0x1b53f0
movl %eax, %eax
movq %rax, -0x70(%rbp)
movl -0x12c(%rbp), %eax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0x80(%rbp), %rax
jl 0x1afa75
movq -0xe0(%rbp), %rax
cmpq -0x88(%rbp), %rax
jg 0x1afa75
movq -0xf0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $-0x1, -0x90(%rbp)
jne 0x1afa67
movq -0xc0(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x1af93a
movq -0x108(%rbp), %rax
cmpq -0x120(%rbp), %rax
jg 0x1afa8c
jmp 0x1afaab
leaq 0x1dc0d4(%rip), %rdi    # 0x38bb67
leaq 0x1dbe05(%rip), %rsi    # 0x38b89f
movl $0xb18, %edx            # imm = 0xB18
leaq 0x1dc1a4(%rip), %rcx    # 0x38bc4a
callq 0x2130
movq -0x98(%rbp), %rax
cmpq -0x120(%rbp), %rax
jg 0x1afabd
jmp 0x1afadc
leaq 0x1dc17c(%rip), %rdi    # 0x38bc40
leaq 0x1dbdd4(%rip), %rsi    # 0x38b89f
movl $0xb19, %edx            # imm = 0xB19
leaq 0x1dc173(%rip), %rcx    # 0x38bc4a
callq 0x2130
movq -0x60(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x70(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rax
cmpq -0x90(%rbp), %rax
jg 0x1afb1a
movq $0x0, -0x8(%rbp)
jmp 0x1b0020
movq $-0x1, -0x58(%rbp)
movq $-0x1, -0x50(%rbp)
movq -0x100(%rbp), %rax
cmpq -0x80(%rbp), %rax
jne 0x1afb6a
movq -0xf8(%rbp), %rax
cmpq -0x88(%rbp), %rax
jne 0x1afb6a
movq -0x108(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x88(%rbp), %rax
subq -0x80(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x1afdcc
movq -0x90(%rbp), %rax
movq 0x10(%rbp), %rcx
cmpq (%rcx), %rax
jl 0x1afbad
movq -0x98(%rbp), %rax
movq 0x18(%rbp), %rcx
cmpq (%rcx), %rax
jg 0x1afbad
movq 0x40(%rbp), %rax
movq (%rax), %rax
addq -0x90(%rbp), %rax
movq 0x10(%rbp), %rdx
xorl %ecx, %ecx
subq (%rdx), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x1afd66
movq -0x90(%rbp), %rax
movq 0x10(%rbp), %rcx
cmpq (%rcx), %rax
jl 0x1afcb5
movq -0x90(%rbp), %rax
movq 0x18(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x1afcb5
movq -0x98(%rbp), %rax
movq 0x18(%rbp), %rcx
cmpq (%rcx), %rax
jle 0x1afcb5
jmp 0x1afbeb
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x98(%rbp), %rcx
movq 0x10(%rbp), %rdx
subq (%rdx), %rcx
cmpq %rcx, %rax
jge 0x1afc44
movq 0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x98(%rbp), %rsi
movq 0x10(%rbp), %rax
subq (%rax), %rsi
shlq $0x0, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rcx
movq 0x10(%rbp), %rax
subq (%rax), %rcx
movq 0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1afc46
movq 0x40(%rbp), %rax
movq (%rax), %rdi
movq 0x18(%rbp), %rax
addq (%rax), %rdi
movq 0x10(%rbp), %rcx
xorl %eax, %eax
subq (%rcx), %rax
addq %rax, %rdi
movq 0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x98(%rbp), %rdx
movq 0x18(%rbp), %rax
subq (%rax), %rdx
movq 0x38(%rbp), %r8
movq -0x40(%rbp), %r9
xorl %ecx, %ecx
callq 0x9a30
movq 0x40(%rbp), %rax
movq (%rax), %rax
addq -0x90(%rbp), %rax
movq 0x10(%rbp), %rdx
xorl %ecx, %ecx
subq (%rdx), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x98(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1afd64
jmp 0x1afcb7
movq 0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x98(%rbp), %rcx
subq -0x90(%rbp), %rcx
cmpq %rcx, %rax
jge 0x1afd10
movq 0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x98(%rbp), %rsi
subq -0x90(%rbp), %rsi
shlq $0x0, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rcx
subq -0x90(%rbp), %rcx
movq 0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1afd12
movq 0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdx
subq -0x90(%rbp), %rdx
movq 0x38(%rbp), %r8
movq -0x40(%rbp), %r9
xorl %ecx, %ecx
callq 0x9a30
movq 0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x90(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x98(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1afd66
movq -0x48(%rbp), %rdi
movq -0x98(%rbp), %rsi
subq -0x90(%rbp), %rsi
leaq 0x214a79(%rip), %rax    # 0x3c47f8
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, %edx
movq 0x20(%rbp), %rcx
movq 0x28(%rbp), %r8
movq 0x30(%rbp), %r9
leaq -0x50(%rbp), %r10
leaq -0x58(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1ad1c0
cmpq $0x0, %rax
je 0x1afdca
movq -0x90(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x1afdcc
cmpq $-0x1, -0x50(%rbp)
je 0x1b0018
cmpq $-0x1, -0x58(%rbp)
je 0x1b0018
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
subq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq 0x2149f1(%rip), %rax    # 0x3c47f8
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x1affad
cmpq $-0x1, -0xa0(%rbp)
jne 0x1afed8
movq -0x40(%rbp), %rdi
movq 0x38(%rbp), %rsi
movq 0x40(%rbp), %rdx
movq 0x10(%rbp), %rax
movq (%rax), %rcx
movq 0x18(%rbp), %rax
movq (%rax), %r8
movq -0x80(%rbp), %r9
movq -0x120(%rbp), %rax
movq %rax, (%rsp)
movq $0x1, 0x8(%rsp)
movq $0x8, 0x10(%rsp)
callq 0x1aed20
movq %rax, %rcx
movq -0x80(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x80(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x80(%rbp)
movb %al, -0x14a(%rbp)
jl 0x1afea9
movq -0x80(%rbp), %rcx
xorl %eax, %eax
cmpq -0x120(%rbp), %rcx
movb %al, -0x14a(%rbp)
jge 0x1afea9
movq -0x80(%rbp), %rax
cmpq -0x88(%rbp), %rax
setl %al
movb %al, -0x14a(%rbp)
movb -0x14a(%rbp), %al
testb $0x1, %al
jne 0x1afeb5
jmp 0x1afeb7
jmp 0x1afed6
leaq 0x1dbe5a(%rip), %rdi    # 0x38bd18
leaq 0x1db9da(%rip), %rsi    # 0x38b89f
movl $0xb4d, %edx            # imm = 0xB4D
leaq 0x1dbd79(%rip), %rcx    # 0x38bc4a
callq 0x2130
jmp 0x1afed8
cmpq $-0x1, -0xa8(%rbp)
jne 0x1affab
movq -0x40(%rbp), %rdi
movq 0x38(%rbp), %rsi
movq 0x40(%rbp), %rdx
movq 0x10(%rbp), %rax
movq (%rax), %rcx
movq 0x18(%rbp), %rax
movq (%rax), %r8
movq -0x88(%rbp), %r9
subq $0x1, %r9
movq -0x120(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x8, 0x10(%rsp)
callq 0x1aed20
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x88(%rbp)
movb %al, -0x14b(%rbp)
jl 0x1aff7c
movq -0x88(%rbp), %rcx
xorl %eax, %eax
cmpq -0x120(%rbp), %rcx
movb %al, -0x14b(%rbp)
jge 0x1aff7c
movq -0x80(%rbp), %rax
cmpq -0x88(%rbp), %rax
setl %al
movb %al, -0x14b(%rbp)
movb -0x14b(%rbp), %al
testb $0x1, %al
jne 0x1aff88
jmp 0x1aff8a
jmp 0x1affa9
leaq 0x1dbda6(%rip), %rdi    # 0x38bd37
leaq 0x1db907(%rip), %rsi    # 0x38b89f
movl $0xb52, %edx            # imm = 0xB52
leaq 0x1dbca6(%rip), %rcx    # 0x38bc4a
callq 0x2130
jmp 0x1affab
jmp 0x1affad
movq -0x88(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x88(%rbp), %rax
subq -0x80(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x100, -0x58(%rbp)     # imm = 0x100
jae 0x1b0016
movq -0x18(%rbp), %rax
movq (%rax), %rcx
shrq $0x20, %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq $0x1, -0x8(%rbp)
jmp 0x1b0020
jmp 0x1b0018
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax)