// File: /workspace/github_c_makefile_star2_O1/sc932[P]ALE/src/ssw.c
// Function: ssw_align
s_align* ssw_align (const s_profile* prof,
					const int8_t* ref,
				  	int32_t refLen,
				  	const uint8_t weight_gapO,
				  	const uint8_t weight_gapE,
					const uint8_t flag,	//  (from high to low) bit 5: return the best alignment beginning position; 6: if (ref_end1 - ref_begin1 <= filterd) && (read_end1 - read_begin1 <= filterd), return cigar; 7: if max score >= filters, return cigar; 8: always return cigar; if 6 & 7 are both setted, only return cigar when both filter fulfilled
					const uint16_t filters,
					const int32_t filterd,
					const int32_t maskLen) {

	alignment_end* bests = 0, *bests_reverse = 0;
	__m128i* vP = 0;
	int32_t word = 0, band_width = 0, readLen = prof->readLen;
	int8_t* read_reverse = 0;
	cigar* path;
	s_align* r = (s_align*)calloc(1, sizeof(s_align));
	r->ref_begin1 = -1;
	r->read_begin1 = -1;
	r->cigar = 0;
	r->cigarLen = 0;
    r->flag = 0;
	if (maskLen < 15) {
		fprintf(stderr, "When maskLen < 15, the function ssw_align doesn't return 2nd best alignment information.\n");
	}

	// Find the alignment scores and ending positions
	if (prof->profile_byte) {
		bests = sw_sse2_byte(ref, 0, refLen, readLen, weight_gapO, weight_gapE, prof->profile_byte, -1, prof->bias, maskLen);
		if (prof->profile_word && bests[0].score == 255) {
			free(bests);
			bests = sw_sse2_word(ref, 0, refLen, readLen, weight_gapO, weight_gapE, prof->profile_word, -1, maskLen);
			word = 1;
		} else if (bests[0].score == 255) {
			fprintf(stderr, "Please set 2 to the score_size parameter of the function ssw_init, otherwise the alignment results will be incorrect.\n");
			free(r);
			return NULL;
		}
	}else if (prof->profile_word) {
		bests = sw_sse2_word(ref, 0, refLen, readLen, weight_gapO, weight_gapE, prof->profile_word, -1, maskLen);
		word = 1;
	}else {
		fprintf(stderr, "Please call the function ssw_init before ssw_align.\n");
		free(r);
		return NULL;
	}
	r->score1 = bests[0].score;
	r->ref_end1 = bests[0].ref; // 0_based, always count from the input seq begin
	r->read_end1 = bests[0].read;   // 0_based, count from the alignment begin (aligned length of the read)
	if (maskLen >= 15) {
		r->score2 = bests[1].score;
		r->ref_end2 = bests[1].ref;
	} else {
		r->score2 = 0;
		r->ref_end2 = -1;
	}
	free(bests);
	if (flag == 0 || (flag == 2 && r->score1 < filters)) goto end;

	// Find the beginning position of the best alignment.
	read_reverse = seq_reverse(prof->read, r->read_end1);
	if (word == 0) {
		vP = qP_byte(read_reverse, prof->mat, r->read_end1 + 1, prof->n, prof->bias);
		bests_reverse = sw_sse2_byte(ref, 1, r->ref_end1 + 1, r->read_end1 + 1, weight_gapO, weight_gapE, vP, r->score1, prof->bias, maskLen);
	} else {
		vP = qP_word(read_reverse, prof->mat, r->read_end1 + 1, prof->n);
		bests_reverse = sw_sse2_word(ref, 1, r->ref_end1 + 1, r->read_end1 + 1, weight_gapO, weight_gapE, vP, r->score1, maskLen);
	}
	free(vP);
	free(read_reverse);
	r->ref_begin1 = bests_reverse[0].ref;
	r->read_begin1 = r->read_end1 - bests_reverse[0].read;

    if (UNLIKELY(r->score1 > bests_reverse[0].score)) { // banded_sw result will miss a small part
		fprintf(stderr, "Warning: The alignment path of one pair of sequences may miss a small part. [ssw.c ssw_align]\n");
        r->flag = 2;  
    }
    free(bests_reverse);

//    fprintf(stderr, "1: %d, ref_end: %d, read_end: %d\n 2: %d, ref_end: %d, read_end: %d\n", r->score1, r->ref_end1, r->read_end1, bests_reverse[0].score, bests_reverse[0].ref, bests_reverse[0].read);
	if ((7&flag) == 0 || ((2&flag) != 0 && r->score1 < filters) || ((4&flag) != 0 && (r->ref_end1 - r->ref_begin1 > filterd || r->read_end1 - r->read_begin1 > filterd))) goto end;

	// Generate cigar.
	refLen = r->ref_end1 - r->ref_begin1 + 1;
	readLen = r->read_end1 - r->read_begin1 + 1;
	band_width = abs(refLen - readLen) + 1;
	path = banded_sw(ref + r->ref_begin1, prof->read + r->read_begin1, refLen, readLen, r->score1, weight_gapO, weight_gapE, band_width, prof->mat, prof->n);
	
    if (path == 0) r->flag = 1;    // banded_sw is failed.
    else {
		r->cigar = path->seq;
		r->cigarLen = path->length;
		free(path);
	}

end:
	return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %r9d, %r12d
movl %r8d, %r15d
movl %ecx, (%rsp)
movl %edx, %r13d
movq %rsi, 0x48(%rsp)
movq %rdi, %r14
movl 0x150(%rsp), %ebx
movl 0x20(%rdi), %ebp
movl $0x1, %edi
movl $0x28, %esi
callq 0x3310
movq %rax, %rdi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x4(%rdi)
movl %eax, 0xc(%rdi)
movq $0x0, 0x18(%rdi)
movl $0x0, 0x20(%rdi)
movw $0x0, 0x24(%rdi)
cmpl $0xe, %ebx
movq %rdi, 0x18(%rsp)
jg 0xd235
callq 0x42f2
movq 0x18(%rsp), %rdi
movq (%r14), %rax
testq %rax, %rax
movl %r15d, 0x14(%rsp)
jne 0xd257
movq 0x8(%r14), %r15
testq %r15, %r15
jne 0xd2b4
callq 0x438e
xorl %eax, %eax
jmp 0xd358
movzbl 0x28(%r14), %r10d
movzbl (%rsp), %r8d
movzbl %r15b, %r9d
movq 0x48(%rsp), %rdi
xorl %esi, %esi
movl %r13d, %edx
movl %ebp, %ecx
pushq %rbx
pushq %r10
pushq $0xff
pushq %rax
callq 0x3a9f
addq $0x20, %rsp
movq 0x8(%r14), %r15
testq %r15, %r15
je 0xd293
cmpw $0xff, (%rax)
je 0xd2ac
movb $0x1, %cl
movl %ecx, 0x20(%rsp)
cmpw $0xff, (%rax)
jne 0xd2e9
movq 0x18(%rsp), %rdi
callq 0x430e
jmp 0xd250
movq %rax, %rdi
callq 0x3070
subq $0x8, %rsp
movzbl 0x8(%rsp), %r8d
movzbl 0x1c(%rsp), %r9d
movl $0x0, 0x28(%rsp)
movq 0x50(%rsp), %rdi
xorl %esi, %esi
movl %r13d, %edx
movl %ebp, %ecx
pushq %rbx
pushq $0xffff                 # imm = 0xFFFF
pushq %r15
callq 0x3f12
addq $0x20, %rsp
movzwl (%rax), %r13d
movq 0x18(%rsp), %rdx
movw %r13w, (%rdx)
movl 0x4(%rax), %ecx
movq %rcx, 0x8(%rsp)
movl %ecx, 0x8(%rdx)
movslq 0x8(%rax), %r15
movl %r15d, 0x10(%rdx)
cmpl $0xf, %ebx
jl 0xd31b
movzwl 0xc(%rax), %ecx
movw %cx, 0x2(%rdx)
movl 0x10(%rax), %ecx
jmp 0xd326
movw $0x0, 0x2(%rdx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, 0x14(%rdx)
movq %rax, %rdi
callq 0x3070
testb %r12b, %r12b
je 0xd353
movq %r13, 0x40(%rsp)
movzwl 0x140(%rsp), %eax
movzbl %r12b, %ebp
cmpl $0x2, %ebp
jne 0xd36a
cmpw %ax, 0x40(%rsp)
jae 0xd36a
movq 0x18(%rsp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r14), %r13
leaq 0x1(%r15), %rdi
movl $0x1, %esi
movq %rdi, 0x28(%rsp)
callq 0x3310
movq %rax, %r12
testl %r15d, %r15d
js 0xd3af
xorl %ecx, %ecx
movq %r15, %rax
movb (%r13,%rax), %dl
movb %dl, (%r12,%rcx)
movb (%r13,%rcx), %dl
movb %dl, (%r12,%rax)
leaq 0x1(%rcx), %rdx
decq %rax
cmpq %rax, %rcx
movq %rdx, %rcx
jl 0xd38e
movq 0x18(%r14), %rsi
movl 0x24(%r14), %ecx
cmpb $0x0, 0x20(%rsp)
je 0xd413
movzbl 0x28(%r14), %r8d
movq %r12, %rdi
movq 0x28(%rsp), %r13
movl %r13d, %edx
callq 0x393f
movq %rax, %r11
movq 0x8(%rsp), %rax
leal 0x1(%rax), %edx
movzbl 0x28(%r14), %eax
movzbl 0x40(%rsp), %r10d
movzbl (%rsp), %r8d
movzbl 0x14(%rsp), %r9d
movq 0x48(%rsp), %rdi
movl $0x1, %esi
movl %r13d, %ecx
pushq %rbx
pushq %rax
pushq %r10
movq %r11, 0x38(%rsp)
pushq %r11
callq 0x3a9f
jmp 0xd45c
movq %r12, %rdi
movq 0x28(%rsp), %r13
movl %r13d, %edx
callq 0x39f2
movq %rax, %r10
movq 0x8(%rsp), %rax
leal 0x1(%rax), %edx
subq $0x8, %rsp
movzbl 0x8(%rsp), %r8d
movzbl 0x1c(%rsp), %r9d
movq 0x50(%rsp), %rdi
movl $0x1, %esi
movl %r13d, %ecx
pushq %rbx
pushq 0x50(%rsp)
movq %r10, 0x38(%rsp)
pushq %r10
callq 0x3f12
addq $0x20, %rsp
movq %rax, %r13
movq 0x18(%rsp), %rbx
movq %rbx, %rax
addq $0x24, %rax
movq %rax, 0xb0(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3070
movq %r12, %rdi
callq 0x3070
movslq 0x4(%r13), %r12
movl %r12d, 0x4(%rbx)
movl 0x8(%r13), %eax
movq %rax, 0x60(%rsp)
subl %eax, %r15d
movl %r15d, 0xc(%rbx)
movq 0x40(%rsp), %rax
cmpw (%r13), %ax
ja 0xddd1
movq %r13, %rdi
callq 0x3070
testb $0x7, %bpl
je 0xd353
testb $0x2, %bpl
movq 0x18(%rsp), %rax
je 0xd4e1
movzwl 0x140(%rsp), %ecx
cmpw %cx, 0x40(%rsp)
jb 0xd358
testb $0x4, %bpl
movq 0x60(%rsp), %rsi
je 0xd50b
movl 0x148(%rsp), %edx
movq 0x8(%rsp), %rcx
subl %r12d, %ecx
cmpl %edx, %ecx
jg 0xd358
cmpl %edx, %esi
jg 0xd358
movq 0x8(%rsp), %rax
subl %r12d, %eax
leal 0x1(%rax), %ebx
leal 0x1(%rsi), %r13d
movq %rax, 0x8(%rsp)
subl %esi, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
incl %ecx
movq %rcx, 0x78(%rsp)
movslq %r15d, %rax
addq 0x10(%r14), %rax
movq %rax, 0x20(%rsp)
movzbl (%rsp), %eax
movl %eax, 0x28(%rsp)
movzbl 0x14(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0x18(%r14), %rax
movq %rax, 0x100(%rsp)
movslq 0x24(%r14), %rax
movq %rax, 0xf8(%rsp)
movl $0x40, %edi
callq 0x3420
movq %rax, 0xd0(%rsp)
cmpl %r13d, %ebx
cmovlel %r13d, %ebx
movl %ebx, 0x94(%rsp)
movl $0x10, %edi
callq 0x3420
movq %rax, 0xa8(%rsp)
movl $0x20, %edi
callq 0x3420
movq %rax, %rbp
movl $0x20, %edi
callq 0x3420
movq %rax, 0x58(%rsp)
movl $0x20, %edi
callq 0x3420
movq %rax, %rbx
movl $0x400, %r14d           # imm = 0x400
movl $0x400, %edi            # imm = 0x400
callq 0x3420
movq %r13, 0xe0(%rsp)
leal (%r13,%r13,2), %ecx
movl %ecx, 0x90(%rsp)
addq %r12, 0x48(%rsp)
movl $0x8, %ecx
xorl %r15d, %r15d
movq %r14, 0x80(%rsp)
movq %rax, 0x30(%rsp)
movq 0x78(%rsp), %rax
movl %eax, %edx
movq %rbx, %r13
movq %rdx, 0x70(%rsp)
leal 0x3(,%rdx,2), %edx
movl %edx, (%rsp)
cmpl %ecx, %edx
movl %ecx, %ebx
jl 0xd67f
movl %ebx, %edx
sarl %edx
orl %ebx, %edx
movl %edx, %ecx
sarl $0x2, %ecx
orl %edx, %ecx
movl %ecx, %edx
sarl $0x4, %edx
orl %ecx, %edx
movl %edx, %ecx
sarl $0x8, %ecx
orl %edx, %ecx
movl %ecx, %ebx
sarl $0x10, %ebx
orl %ecx, %ebx
movslq %ebx, %r14
incl %ebx
leaq 0x4(,%r14,4), %r12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3480
movq %rax, %rbp
movq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x3480
movq %rax, 0x58(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x3480
movq %rax, %r13
cmpl %r14d, (%rsp)
jg 0xd61c
movl %ebx, 0x6c(%rsp)
movq %r13, 0x50(%rsp)
movq 0x70(%rsp), %r12
leal 0x1(,%r12,2), %edx
movl 0x90(%rsp), %eax
movq %rdx, 0xb8(%rsp)
imull %edx, %eax
movslq %eax, %rbx
movq 0x80(%rsp), %r14
cmpq %rbx, %r14
movq 0x30(%rsp), %rdi
jg 0xd704
movq %r14, %rax
sarq %rax
orq %r14, %rax
movq %rax, %rcx
sarq $0x2, %rcx
orq %rax, %rcx
movq %rcx, %rax
sarq $0x4, %rax
orq %rcx, %rax
movq %rax, %rcx
sarq $0x8, %rcx
orq %rax, %rcx
movq %rcx, %r14
sarq $0x10, %r14
orq %rcx, %r14
leaq 0x1(%r14), %r13
movq %r13, %rsi
callq 0x3480
movq %rax, %rdi
cmpq %rbx, %r14
movq %r13, %r14
jl 0xd6bc
movq %rdi, 0x30(%rsp)
leal (%r12,%r12), %ebx
leaq 0x4(%rbp), %rdi
movl %ebx, %eax
leaq 0x4(,%rax,4), %rdx
movq %rdi, 0xc8(%rsp)
xorl %esi, %esi
callq 0x3260
cmpl $0x0, 0x60(%rsp)
movq %rbp, 0xc0(%rsp)
movq %rbx, 0x78(%rsp)
js 0xda1a
movq %r14, 0x80(%rsp)
leal 0x2(%rbx), %eax
movl %eax, 0x9c(%rsp)
movq 0xb8(%rsp), %rax
leal (%rax,%rax,2), %eax
movq %rax, 0x88(%rsp)
movl %r12d, %edx
notl %edx
movl %r12d, %esi
negl %esi
movq 0x50(%rsp), %rax
movq %r12, %rcx
leaq 0x4(%rax), %r12
movq 0x58(%rsp), %rax
leaq 0x4(%rax), %rbx
movq 0x30(%rsp), %rax
incq %rax
movq %rax, 0xd8(%rsp)
leal (%rcx,%rcx,2), %eax
leal 0x3(,%rax,2), %eax
movl %eax, 0x98(%rsp)
movl $0x0, 0x3c(%rsp)
xorl %r14d, %r14d
testl %esi, %esi
movl $0x0, %r10d
movl %esi, 0xa0(%rsp)
cmovgl %esi, %r10d
testl %edx, %edx
movl $0x0, %esi
movl %edx, 0xa4(%rsp)
cmovgl %edx, %esi
movl %r14d, %edx
movl %r14d, %ecx
movq 0x70(%rsp), %rax
subl %eax, %ecx
testl %ecx, %ecx
movl $0x0, %edi
cmovlel %edi, %ecx
movq %rdx, 0xe8(%rsp)
leal (%rax,%rdx), %r9d
movq 0x8(%rsp), %rax
cmpl %r9d, %eax
cmovll %eax, %r9d
leal 0x1(%r9), %edx
movl 0x9c(%rsp), %eax
cmpl %eax, %edx
cmovgel %eax, %edx
movslq %edx, %rdx
movq 0x58(%rsp), %rax
movl %edi, (%rax,%rdx,4)
movl %edi, (%rbp,%rdx,4)
movq 0x50(%rsp), %rdx
movl %edi, (%rdx)
movl %edi, (%rax)
movl %edi, (%rbp)
cmpl %r9d, %ecx
jg 0xd9d2
movq 0x48(%rsp), %rax
addq %r10, %rax
movq %rax, (%rsp)
leaq (,%r10,4), %rcx
shlq $0x2, %rsi
subq %rsi, %rcx
movq 0xc8(%rsp), %rax
leaq (%rax,%rcx), %rdi
addq %rbx, %rcx
movq %rcx, 0xf0(%rsp)
movl 0x3c(%rsp), %r8d
addq 0xd8(%rsp), %r8
movslq %r9d, %r9
xorl %esi, %esi
xorl %ebp, %ebp
movl $0x0, %edx
testq %r14, %r14
je 0xd88c
movl (%rdi,%rsi,4), %edx
movq %r10, %rcx
movl $0x0, %r11d
testq %r14, %r14
je 0xd8a6
movq 0xf0(%rsp), %rax
movl (%rax,%rsi,4), %r11d
movl 0x28(%rsp), %eax
subl %eax, %edx
movl 0x14(%rsp), %r10d
subl %r10d, %r11d
cmpl %r11d, %edx
setg %r13b
cmovgl %edx, %r11d
movl %r11d, (%rbx,%rsi,4)
orb $0x2, %r13b
movb %r13b, -0x1(%r8)
movl -0x4(%r12,%rsi,4), %edx
subl %eax, %edx
subl %r10d, %ebp
cmpl %ebp, %edx
setg %r11b
cmovgl %edx, %ebp
orb $0x4, %r11b
movb %r11b, (%r8)
movl %ebp, %r10d
testl %ebp, %ebp
jg 0xd8ef
xorl %r10d, %r10d
movl (%rbx,%rsi,4), %edx
cmpl %r10d, %edx
movl %r10d, %r11d
cmovgl %edx, %r11d
movq (%rsp), %rax
movsbq (%rax,%rsi), %r13
imulq 0xf8(%rsp), %r13
movq 0x20(%rsp), %rax
movsbq (%rax,%r14), %rax
addq %r13, %rax
movq 0x100(%rsp), %r13
movsbl (%r13,%rax), %eax
addl -0x4(%rdi,%rsi,4), %eax
cmpl %eax, %r11d
movl %eax, %r13d
cmovgl %r11d, %r13d
cmpl %r15d, %r13d
cmovgl %r13d, %r15d
movl %r13d, (%r12,%rsi,4)
movb $0x1, %r13b
cmpl %eax, %r11d
jle 0xd95b
cmpl %r10d, %edx
jg 0xd954
movq %r8, %rdx
jmp 0xd958
leaq -0x1(%r8), %rdx
movb (%rdx), %r13b
movb %r13b, 0x1(%r8)
movq %rcx, %r10
leaq (%rcx,%rsi), %rax
incq %rax
incq %rsi
decq %rax
addq $0x3, %r8
cmpq %r9, %rax
jl 0xd87f
movq 0xc0(%rsp), %rbp
testl %esi, %esi
jle 0xd99e
movl %esi, %edx
shlq $0x2, %rdx
movq 0xc8(%rsp), %rdi
movq %r12, %rsi
callq 0x33b0
incq %r14
movl 0xa0(%rsp), %esi
incl %esi
movl 0xa4(%rsp), %edx
incl %edx
movl 0x3c(%rsp), %eax
addl 0x98(%rsp), %eax
movl %eax, 0x3c(%rsp)
cmpq 0xe0(%rsp), %r14
jne 0xd7b2
jmp 0xd9d6
xorl %esi, %esi
jmp 0xd984
movq 0x88(%rsp), %rsi
imull 0xe8(%rsp), %esi
movq 0x30(%rsp), %rax
addq %rax, %rsi
movq 0x50(%rsp), %rbx
movq 0x80(%rsp), %r14
movl 0x6c(%rsp), %ecx
movq 0x78(%rsp), %rdx
cmpl 0x94(%rsp), %edx
jg 0xda29
cmpl 0x40(%rsp), %r15d
jl 0xd5f0
jmp 0xda29
movq 0x30(%rsp), %rax
movq %rax, %rsi
movq 0x50(%rsp), %rbx
jmp 0xd9fb
movq 0x60(%rsp), %rdx
testl %edx, %edx
movq 0xd0(%rsp), %r8
movq 0x70(%rsp), %r9
jle 0xddbf
movq 0xb8(%rsp), %rax
leal (%rax,%rax,2), %eax
negq %rax
movq %rax, 0x28(%rsp)
movb $0x4d, %r12b
movl $0x10, %r14d
movl $0x2, %r13d
xorl %r11d, %r11d
leaq 0x168d1(%rip), %r15     # 0x24340
xorl %r10d, %r10d
xorl %ebx, %ebx
movl %edx, %eax
subl %r9d, %eax
testl %eax, %eax
cmovlel %r11d, %eax
movq 0x8(%rsp), %rcx
subl %eax, %ecx
leal (%rcx,%rcx,2), %edi
addl %r13d, %edi
movslq %edi, %rax
movzbl (%rsi,%rax), %eax
decl %eax
cmpl $0x4, %eax
ja 0xdc55
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
decl %edx
movq 0x8(%rsp), %rax
decl %eax
movq %rax, 0x8(%rsp)
addq 0x28(%rsp), %rsi
movl $0x2, %r13d
movb $0x4d, %al
jmp 0xdb09
movq 0x8(%rsp), %rax
decl %eax
movq %rax, 0x8(%rsp)
movl $0x2, %r13d
jmp 0xdaf9
decl %edx
addq 0x28(%rsp), %rsi
movl $0x2, %r13d
jmp 0xdb07
movq 0x8(%rsp), %rax
decl %eax
movq %rax, 0x8(%rsp)
movl $0x1, %r13d
movb $0x44, %al
jmp 0xdb09
decl %edx
addq 0x28(%rsp), %rsi
xorl %r13d, %r13d
movb $0x49, %al
cmpb %r12b, %al
jne 0xdb16
incl %r10d
jmp 0xdbd2
movl %r13d, 0x20(%rsp)
movl %r12d, %r15d
movl %r10d, %r13d
movq %rsi, 0x88(%rsp)
movq %rdx, 0x60(%rsp)
leal 0x1(%rbx), %ebp
cmpl %r14d, %ebp
movb %al, (%rsp)
jl 0xdb7e
movl %r14d, %eax
sarl %eax
orl %r14d, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %r14d
sarl $0x10, %r14d
orl %ecx, %r14d
movslq %r14d, %r12
incl %r14d
leaq 0x4(,%r12,4), %rsi
movq %r8, %rdi
callq 0x3480
movq %rax, %r8
cmpl %r12d, %ebx
jge 0xdb39
shll $0x4, %r13d
movzbl %r15b, %eax
leaq 0x167d3(%rip), %rcx     # 0x24360
movzbl (%rax,%rcx), %eax
orl %r13d, %eax
movslq %ebx, %rcx
movl %eax, (%r8,%rcx,4)
movl $0x1, %r10d
movb (%rsp), %al
movl %eax, %r12d
movl %ebp, %ebx
movq 0xc0(%rsp), %rbp
movq 0x60(%rsp), %rdx
movq 0x70(%rsp), %r9
movq 0x88(%rsp), %rsi
xorl %r11d, %r11d
leaq 0x16773(%rip), %r15     # 0x24340
movl 0x20(%rsp), %r13d
testl %edx, %edx
jg 0xda74
shll $0x4, %r10d
cmpb $0x4d, %al
jne 0xdc82
movb %al, (%rsp)
movl %r10d, %r13d
leal 0x1(%rbx), %r15d
cmpl %r14d, %r15d
jl 0xdc3a
movl %r14d, %eax
sarl %eax
orl %r14d, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %r14d
sarl $0x10, %r14d
orl %ecx, %r14d
movslq %r14d, %r12
incl %r14d
leaq 0x4(,%r12,4), %rsi
movq %r8, %rdi
callq 0x3480
movq %rax, %r8
cmpl %r12d, %ebx
jge 0xdbf5
addl $0x10, %r13d
movzbl (%rsp), %eax
leaq 0x16717(%rip), %rcx     # 0x24360
movzbl (%rax,%rcx), %eax
orl %r13d, %eax
jmp 0xdcfb
movq 0x30(%rsp), %rdx
movq %r8, %rbx
callq 0x435e
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %r12
movq %rbp, %r15
movq %rbx, %rbp
movq 0xa8(%rsp), %rbx
xorl %r14d, %r14d
jmp 0xdd60
movl %eax, %r13d
movl %r10d, (%rsp)
leal 0x2(%rbx), %r15d
cmpl %r14d, %r15d
jl 0xdcd7
movl %r14d, %eax
sarl %eax
orl %r14d, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %r14d
sarl $0x10, %r14d
orl %ecx, %r14d
movslq %r14d, %r12
incl %r14d
leaq 0x4(,%r12,4), %rsi
movq %r8, %rdi
callq 0x3480
movq %rax, %r8
cmpl %r12d, %r15d
jg 0xdc92
movzbl %r13b, %eax
leaq 0x1667e(%rip), %rcx     # 0x24360
movzbl (%rax,%rcx), %eax
movl (%rsp), %r13d
orl %eax, %r13d
movslq %ebx, %rax
movl %r13d, (%r8,%rax,4)
incl %ebx
movl $0x10, %eax
movslq %ebx, %rcx
movl %eax, (%r8,%rcx,4)
movslq %r15d, %rbx
leaq (,%rbx,4), %rdi
movq %r8, %r14
callq 0x3420
movq %r14, %rdi
testl %ebx, %ebx
movq 0xa8(%rsp), %r14
jle 0xdd47
movl %r15d, %ecx
decq %rcx
xorl %edx, %edx
movl (%rdi,%rcx,4), %esi
movl %esi, (%rax,%rdx,4)
movl (%rdi,%rdx,4), %esi
movl %esi, (%rax,%rcx,4)
incq %rdx
leaq -0x1(%rcx), %rsi
cmpq %rcx, %rdx
movq %rsi, %rcx
jl 0xdd2c
movq %rax, (%r14)
movl %r15d, 0x8(%r14)
movq %rdi, %rbx
movq 0x58(%rsp), %r15
movq 0x50(%rsp), %r12
movq 0x30(%rsp), %rdi
callq 0x3070
movq %r12, %rdi
callq 0x3070
movq %r15, %rdi
callq 0x3070
movq %rbp, %rdi
callq 0x3070
movq %rbx, %rdi
callq 0x3070
testq %r14, %r14
je 0xddad
movq (%r14), %rax
movq 0x18(%rsp), %rbx
movq %rax, 0x18(%rbx)
movl 0x8(%r14), %eax
movl %eax, 0x20(%rbx)
movq %r14, %rdi
callq 0x3070
movq %rbx, %rax
jmp 0xd358
movq 0xb0(%rsp), %rax
movw $0x1, (%rax)
jmp 0xd353
movl $0x10, %r14d
xorl %ebx, %ebx
movb $0x4d, %al
xorl %r10d, %r10d
jmp 0xdbde
movq 0xb0(%rsp), %rdi
callq 0x4337
jmp 0xd4b1