// File: /workspace/github_c_makefile_star2_O3/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, 0x10(%rsp)
movl %ecx, 0x8(%rsp)
movl %edx, %r13d
movq %rsi, 0x40(%rsp)
movq %rdi, %r14
movl 0x150(%rsp), %ebx
movl 0x20(%rdi), %ebp
movl $0x1, %edi
movl $0x28, %esi
callq 0x3310
movq %rax, %r15
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x4(%r15)
movl %eax, 0xc(%r15)
cmpl $0xe, %ebx
jg 0xd611
callq 0x4283
movq %r15, 0x18(%rsp)
movq (%r14), %rax
testq %rax, %rax
jne 0xd639
movq 0x8(%r14), %r15
testq %r15, %r15
jne 0xd68a
movq 0x18(%rsp), %rdi
callq 0x42ef
xorl %r15d, %r15d
jmp 0xd73a
movzbl 0x28(%r14), %r10d
movzbl 0x8(%rsp), %r8d
movzbl 0x10(%rsp), %r9d
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movl %r13d, %edx
movl %ebp, %ecx
pushq %rbx
pushq %r10
pushq $0xff
pushq %rax
callq 0x3a3d
addq $0x20, %rsp
movq 0x8(%r14), %r15
movzwl (%rax), %ecx
movb $0x1, %dl
testq %r15, %r15
je 0xd6c1
movl %edx, 0x20(%rsp)
cmpl $0xff, %ecx
jne 0xd6d1
movq %rax, %rdi
callq 0x3070
subq $0x8, %rsp
movzbl 0x10(%rsp), %r8d
movzbl 0x18(%rsp), %r9d
movl $0x0, 0x28(%rsp)
movq 0x48(%rsp), %rdi
xorl %esi, %esi
movl %r13d, %edx
movl %ebp, %ecx
pushq %rbx
pushq $0xffff                 # imm = 0xFFFF
pushq %r15
callq 0x3e9d
addq $0x20, %rsp
jmp 0xd6d1
movl %edx, 0x20(%rsp)
cmpl $0xff, %ecx
je 0xde21
movzwl (%rax), %r13d
movq 0x18(%rsp), %r15
movw %r13w, (%r15)
movl 0x4(%rax), %ecx
movq %rcx, (%rsp)
movl %ecx, 0x8(%r15)
movslq 0x8(%rax), %rbp
movl %ebp, 0x10(%r15)
cmpl $0xf, %ebx
jl 0xd6ff
movzwl 0xc(%rax), %edx
movl 0x10(%rax), %ecx
jmp 0xd706
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %edx, %edx
movw %dx, 0x2(%r15)
movl %ecx, 0x14(%r15)
movq %rax, %rdi
callq 0x3070
testb %r12b, %r12b
je 0xd73a
movq %r13, 0x38(%rsp)
movzwl 0x140(%rsp), %eax
movzbl %r12b, %r13d
cmpl $0x2, %r13d
jne 0xd74f
cmpw %ax, 0x38(%rsp)
jae 0xd74f
movq %r15, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r14), %r15
leaq 0x1(%rbp), %rdi
movl $0x1, %esi
movq %rdi, 0x28(%rsp)
callq 0x3310
movq %rax, %r12
testl %ebp, %ebp
js 0xd791
xorl %ecx, %ecx
movq %rbp, %rax
movb (%r15,%rax), %dl
movb %dl, (%r12,%rcx)
movb (%r15,%rcx), %dl
movb %dl, (%r12,%rax)
leaq 0x1(%rcx), %rdx
decq %rax
cmpq %rax, %rcx
movq %rdx, %rcx
jl 0xd772
movq 0x18(%r14), %rsi
movl 0x24(%r14), %ecx
cmpb $0x0, 0x20(%rsp)
je 0xd7f5
movzbl 0x28(%r14), %r8d
movq %r12, %rdi
movq 0x28(%rsp), %r15
movl %r15d, %edx
callq 0x38dd
movq %rax, %r11
movq (%rsp), %rax
leal 0x1(%rax), %edx
movzbl 0x28(%r14), %eax
movzbl 0x38(%rsp), %r10d
movzbl 0x8(%rsp), %r8d
movzbl 0x10(%rsp), %r9d
movq 0x40(%rsp), %rdi
movl $0x1, %esi
movl %r15d, %ecx
pushq %rbx
pushq %rax
pushq %r10
movq %r11, 0x38(%rsp)
pushq %r11
callq 0x3a3d
jmp 0xd83d
movq %r12, %rdi
movq 0x28(%rsp), %r15
movl %r15d, %edx
callq 0x3990
movq %rax, %r10
movq (%rsp), %rax
leal 0x1(%rax), %edx
subq $0x8, %rsp
movzbl 0x10(%rsp), %r8d
movzbl 0x18(%rsp), %r9d
movq 0x48(%rsp), %rdi
movl $0x1, %esi
movl %r15d, %ecx
pushq %rbx
pushq 0x48(%rsp)
movq %r10, 0x38(%rsp)
pushq %r10
callq 0x3e9d
addq $0x20, %rsp
movq %rax, %rbx
movq 0x18(%rsp), %r15
movq %r15, %rax
addq $0x24, %rax
movq %rax, 0xb0(%rsp)
movq 0x20(%rsp), %rdi
callq 0x3070
movq %r12, %rdi
callq 0x3070
movslq 0x4(%rbx), %r12
movl %r12d, 0x4(%r15)
movl 0x8(%rbx), %ecx
movq %rcx, 0x58(%rsp)
subl %ecx, %ebp
movl %ebp, 0xc(%r15)
movq 0x38(%rsp), %rax
cmpw (%rbx), %ax
ja 0xe1da
movq %rbx, %rdi
callq 0x3070
testb $0x7, %r13b
movq (%rsp), %rdx
je 0xe096
testb $0x2, %r13b
je 0xd8bd
movzwl 0x140(%rsp), %eax
cmpw %ax, 0x38(%rsp)
jb 0xe096
subl %r12d, %edx
testb $0x4, %r13b
movq 0x58(%rsp), %rcx
je 0xd8e2
movl 0x148(%rsp), %eax
cmpl %eax, %edx
jg 0xe096
cmpl %eax, %ecx
jg 0xe096
leal 0x1(%rdx), %ebx
leal 0x1(%rcx), %r15d
movq %rdx, (%rsp)
movl %edx, %eax
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
incl %ecx
movslq %ebp, %rax
addq 0x10(%r14), %rax
movq %rax, 0x20(%rsp)
movzbl 0x8(%rsp), %eax
movl %eax, 0x28(%rsp)
movzbl 0x10(%rsp), %eax
movl %eax, 0xa4(%rsp)
movq 0x18(%r14), %rax
movq %rax, 0x100(%rsp)
movslq 0x24(%r14), %rax
movq %rcx, %r14
movq %rax, 0xf8(%rsp)
movl $0x40, %edi
callq 0x3420
movq %rax, 0xa8(%rsp)
cmpl %r15d, %ebx
cmovlel %r15d, %ebx
movl %ebx, 0x8c(%rsp)
movl $0x10, %edi
callq 0x3420
movq %rax, 0x68(%rsp)
movl $0x20, %edi
callq 0x3420
movq %rax, %rbx
movl $0x20, %edi
callq 0x3420
movq %rax, 0x50(%rsp)
movl $0x20, %edi
callq 0x3420
movq %rax, 0x48(%rsp)
movl $0x400, %eax            # imm = 0x400
movq %rax, 0xc0(%rsp)
movl $0x400, %edi            # imm = 0x400
callq 0x3420
movq %rbx, %rcx
movq %rax, 0x30(%rsp)
movq %r15, 0xe0(%rsp)
leal (%r15,%r15,2), %eax
movl %eax, 0x88(%rsp)
addq %r12, 0x40(%rsp)
movl $0x8, %ebx
xorl %ebp, %ebp
movl %r14d, %eax
movq %rax, 0x70(%rsp)
leal 0x3(,%rax,2), %eax
movl %eax, 0x10(%rsp)
cmpl %ebx, %eax
movq %rcx, %r12
movq 0x48(%rsp), %r13
jl 0xda51
movl %ebx, %eax
sarl %eax
orl %ebx, %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, %ebx
sarl $0x10, %ebx
orl %ecx, %ebx
movslq %ebx, %r14
incl %ebx
leaq 0x4(,%r14,4), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x3480
movq %rax, %r12
movq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x3480
movq %rax, 0x50(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x3480
movq %rax, %r13
cmpl %r14d, 0x10(%rsp)
jg 0xd9ed
movl %ebx, 0x90(%rsp)
movq %r13, 0x48(%rsp)
movq %r12, 0x60(%rsp)
movq 0x70(%rsp), %rax
leal 0x1(,%rax,2), %edx
movl 0x88(%rsp), %eax
movq %rdx, 0xb8(%rsp)
imull %edx, %eax
movslq %eax, %rbx
movq 0xc0(%rsp), %r15
cmpq %rbx, %r15
movq 0x30(%rsp), %r13
jg 0xdadd
movq %r15, %rax
sarq %rax
orq %r15, %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), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x3480
movq %rax, %r13
cmpq %rbx, %r14
jl 0xda95
movq %r15, 0xc0(%rsp)
movq 0x70(%rsp), %r12
leal (%r12,%r12), %r14d
movq 0x60(%rsp), %rax
leaq 0x4(%rax), %rdi
movl %r14d, %eax
leaq 0x4(,%rax,4), %rdx
movq %rdi, 0xc8(%rsp)
xorl %esi, %esi
callq 0x3260
cmpl $0x0, 0x58(%rsp)
movq %r13, 0x30(%rsp)
js 0xde1c
movq %r14, 0xd0(%rsp)
leal 0x2(%r14), %eax
movl %eax, 0x98(%rsp)
movq 0xb8(%rsp), %rax
leal (%rax,%rax,2), %eax
movq %rax, 0x78(%rsp)
movl %r12d, %r11d
notl %r11d
movl %r12d, %ecx
negl %ecx
movq 0x48(%rsp), %rax
leaq 0x4(%rax), %r15
movq 0x50(%rsp), %rdi
leaq 0x4(%rdi), %rbx
leaq 0x1(%r13), %rax
movq %rax, 0xd8(%rsp)
leal (%r12,%r12,2), %eax
leal 0x3(,%rax,2), %eax
movl %eax, 0x94(%rsp)
movq $0x0, 0x80(%rsp)
xorl %r14d, %r14d
movq (%rsp), %r10
testl %ecx, %ecx
movl $0x0, %r13d
movl %ecx, 0xa0(%rsp)
cmovgl %ecx, %r13d
testl %r11d, %r11d
movl $0x0, %edx
cmovgl %r11d, %edx
movl %r14d, %ecx
movl %r14d, %eax
subl %r12d, %eax
testl %eax, %eax
movl $0x0, %r9d
cmovlel %r9d, %eax
movq %rcx, 0xe8(%rsp)
leal (%r12,%rcx), %esi
cmpl %esi, %r10d
cmovll %r10d, %esi
leal 0x1(%rsi), %ecx
movq %r10, %r8
movl 0x98(%rsp), %r10d
cmpl %r10d, %ecx
cmovgel %r10d, %ecx
movslq %ecx, %rcx
movl %r9d, (%rdi,%rcx,4)
movq 0x60(%rsp), %r10
movl %r9d, (%r10,%rcx,4)
movq 0x48(%rsp), %rcx
movl %r9d, (%rcx)
movl %r9d, (%rdi)
movl %r9d, (%r10)
cmpl %esi, %eax
jg 0xdddb
movl %r11d, 0x9c(%rsp)
movq 0x40(%rsp), %rax
addq %r13, %rax
movq %rax, 0x10(%rsp)
leaq (,%r13,4), %rcx
shlq $0x2, %rdx
subq %rdx, %rcx
movq 0xc8(%rsp), %rax
leaq (%rax,%rcx), %rdi
addq %rbx, %rcx
movq %rcx, 0xf0(%rsp)
movl 0x80(%rsp), %r8d
addq 0xd8(%rsp), %r8
movl %esi, %eax
movq %rax, 0x8(%rsp)
xorl %edx, %edx
xorl %r10d, %r10d
xorl %r12d, %r12d
movq %r13, %r9
movl $0x0, %esi
movl $0x0, %r11d
testq %r14, %r14
je 0xdc91
movl (%rdi,%r10,4), %esi
movq 0xf0(%rsp), %rax
movl (%rax,%r10,4), %r11d
movl 0x28(%rsp), %ecx
subl %ecx, %esi
movl 0xa4(%rsp), %r13d
subl %r13d, %r11d
cmpl %r11d, %esi
cmovgl %esi, %r11d
setg %al
movl %r11d, (%rbx,%r10,4)
orb $0x2, %al
movb %al, -0x1(%r8)
movl -0x4(%r15,%r10,4), %eax
subl %ecx, %eax
subl %r13d, %r12d
cmpl %r12d, %eax
setg %sil
cmovgl %eax, %r12d
orb $0x4, %sil
movb %sil, (%r8)
movl (%rbx,%r10,4), %esi
testl %esi, %esi
movl $0x0, %r13d
cmovgl %esi, %r13d
movl %r12d, %r11d
testl %r12d, %r12d
jg 0xdced
xorl %r11d, %r11d
cmpl %r11d, %r13d
cmovbel %r11d, %r13d
movq 0x10(%rsp), %rax
movsbq (%rax,%r10), %rax
imulq 0xf8(%rsp), %rax
movq 0x20(%rsp), %rcx
movsbq (%rcx,%r14), %rcx
addq %rax, %rcx
movq 0x100(%rsp), %rax
movsbl (%rax,%rcx), %ecx
addl -0x4(%rdi,%r10,4), %ecx
cmpl %ecx, %r13d
movl %ecx, %eax
cmovgl %r13d, %eax
cmpl %ebp, %eax
cmovgl %eax, %ebp
movl %eax, (%r15,%r10,4)
movb $0x1, %al
cmpl %ecx, %r13d
jle 0xdd4e
cmpl %r11d, %esi
jg 0xdd48
movq %r8, %rax
jmp 0xdd4c
leaq -0x1(%r8), %rax
movb (%rax), %al
movb %al, 0x1(%r8)
leaq (%r9,%r10), %rax
incq %rax
incq %r10
decq %rax
addq $0x3, %r8
addq $0x4, %rdx
cmpq 0x8(%rsp), %rax
jb 0xdc71
movabsq $0x3fffffffc, %rax      # imm = 0x3FFFFFFFC
andq %rax, %rdx
movq 0xc8(%rsp), %rdi
movq %r15, %rsi
callq 0x33b0
movq (%rsp), %r10
movq 0x50(%rsp), %rdi
movq 0x70(%rsp), %r12
movl 0x9c(%rsp), %r11d
incq %r14
movl 0xa0(%rsp), %ecx
incl %ecx
incl %r11d
movq 0x80(%rsp), %rax
addl 0x94(%rsp), %eax
movq %rax, 0x80(%rsp)
cmpq 0xe0(%rsp), %r14
jne 0xdb92
jmp 0xdde0
movq %r8, %r10
jmp 0xdda5
movq 0x78(%rsp), %rsi
imull 0xe8(%rsp), %esi
addq 0x30(%rsp), %rsi
movq 0xd0(%rsp), %r14
cmpl 0x8c(%rsp), %r14d
movl 0x90(%rsp), %ebx
movq 0x60(%rsp), %rcx
jg 0xde30
cmpl 0x38(%rsp), %ebp
jl 0xd9ce
jmp 0xde30
movq %r13, %rsi
jmp 0xddfa
movq 0x18(%rsp), %rdi
callq 0x429f
jmp 0xd631
movq 0x58(%rsp), %rdx
testl %edx, %edx
jle 0xe1bd
movq 0xb8(%rsp), %rax
leal (%rax,%rax,2), %eax
negq %rax
movq %rax, 0x28(%rsp)
movb $0x4d, %r15b
movl $0x10, %ebp
movl $0x2, %ebx
xorl %r10d, %r10d
leaq 0x16569(%rip), %r11     # 0x243d0
xorl %r9d, %r9d
xorl %r14d, %r14d
movq 0xa8(%rsp), %rdi
movl %edx, %eax
subl %r12d, %eax
testl %eax, %eax
cmovlel %r10d, %eax
movq (%rsp), %rcx
subl %eax, %ecx
leal (%rcx,%rcx,2), %eax
addl %ebx, %eax
cltq
movzbl (%rsi,%rax), %ecx
decl %ecx
cmpl $0x4, %ecx
ja 0xe02f
movslq (%r11,%rcx,4), %rax
addq %r11, %rax
jmpq *%rax
decl %edx
movq (%rsp), %rax
decl %eax
movq %rax, (%rsp)
addq 0x28(%rsp), %rsi
movl $0x2, %ebx
movb $0x4d, %al
movb $0x1, %cl
jmp 0xdf04
movq (%rsp), %rax
decl %eax
movq %rax, (%rsp)
movl $0x2, %ebx
jmp 0xdef1
decl %edx
addq 0x28(%rsp), %rsi
movl $0x2, %ebx
movb $0x49, %al
jmp 0xdef3
movq (%rsp), %rax
decl %eax
movq %rax, (%rsp)
movl $0x1, %ebx
movb $0x44, %al
xorl %ecx, %ecx
jmp 0xdf04
decl %edx
addq 0x28(%rsp), %rsi
xorl %ecx, %ecx
movb $0x49, %al
xorl %ebx, %ebx
cmpb %r15b, %al
jne 0xdf11
incl %r9d
jmp 0xdfbb
movl %ebx, 0x8(%rsp)
movl %r9d, %r13d
movq %rsi, 0x78(%rsp)
movq %rdx, 0x58(%rsp)
leal 0x1(%r14), %ebx
cmpl %ebp, %ebx
movb %al, 0x10(%rsp)
movl %ecx, 0x20(%rsp)
jl 0xdf6e
movl %ebp, %eax
sarl %eax
orl %ebp, %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, %ebp
sarl $0x10, %ebp
orl %ecx, %ebp
movslq %ebp, %r12
incl %ebp
leaq 0x4(,%r12,4), %rsi
callq 0x3480
movq %rax, %rdi
cmpl %r12d, %r14d
jge 0xdf32
shll $0x4, %r13d
movzbl %r15b, %eax
leaq 0x16473(%rip), %rcx     # 0x243f0
movzbl (%rax,%rcx), %eax
orl %r13d, %eax
movslq %r14d, %rcx
movl %eax, (%rdi,%rcx,4)
movl $0x1, %r9d
movb 0x10(%rsp), %al
movl %eax, %r15d
movl %ebx, %r14d
movq 0x58(%rsp), %rdx
movq 0x70(%rsp), %r12
movq 0x78(%rsp), %rsi
xorl %r10d, %r10d
leaq 0x1641d(%rip), %r11     # 0x243d0
movl 0x8(%rsp), %ebx
movl 0x20(%rsp), %ecx
testl %edx, %edx
jg 0xde75
shll $0x4, %r9d
testb %cl, %cl
je 0xe0a0
movq 0x68(%rsp), %r12
movl %r9d, 0x8(%rsp)
leal 0x1(%r14), %r15d
cmpl %ebp, %r15d
movq 0x30(%rsp), %r13
jl 0xe023
movl %ebp, %eax
sarl %eax
orl %ebp, %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, %ebp
sarl $0x10, %ebp
orl %ecx, %ebp
movslq %ebp, %rbx
incl %ebp
leaq 0x4(,%rbx,4), %rsi
callq 0x3480
movq %rax, %rdi
cmpl %ebx, %r14d
jge 0xdfe7
movl 0x8(%rsp), %ecx
addl $0x10, %ecx
jmp 0xe11d
movq 0x1dfc2(%rip), %rcx     # 0x2bff8
movq %rdi, %rbx
movq (%rcx), %rdi
movsbl -0x1(%rax,%rsi), %edx
leaq 0x1658d(%rip), %rsi     # 0x245d5
xorl %eax, %eax
callq 0x3350
movq 0x30(%rsp), %rdi
callq 0x3070
movq 0x48(%rsp), %rdi
callq 0x3070
movq 0x50(%rsp), %rdi
callq 0x3070
movq 0x60(%rsp), %rdi
callq 0x3070
movq %rbx, %rdi
callq 0x3070
movq 0x68(%rsp), %rdi
callq 0x3070
movq 0xb0(%rsp), %rax
movw $0x1, (%rax)
movq 0x18(%rsp), %r15
jmp 0xd73a
movl %eax, %r13d
movl %r9d, 0x8(%rsp)
leal 0x2(%r14), %r15d
cmpl %ebp, %r15d
movq 0x68(%rsp), %r12
jl 0xe0f2
movl %ebp, %eax
sarl %eax
orl %ebp, %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, %ebp
sarl $0x10, %ebp
orl %ecx, %ebp
movslq %ebp, %rbx
incl %ebp
leaq 0x4(,%rbx,4), %rsi
callq 0x3480
movq %rax, %rdi
cmpl %ebx, %r15d
jg 0xe0b6
movzbl %r13b, %eax
leaq 0x162f3(%rip), %rcx     # 0x243f0
movzbl (%rax,%rcx), %eax
movl 0x8(%rsp), %r13d
orl %eax, %r13d
movslq %r14d, %rax
movl %r13d, (%rdi,%rax,4)
incl %r14d
movl $0x10, %ecx
movq 0x30(%rsp), %r13
movslq %r14d, %rax
movl %ecx, (%rdi,%rax,4)
movslq %r15d, %rbx
movq %rdi, %r14
leaq (,%rbx,4), %rdi
callq 0x3420
movq %r14, %rsi
testl %ebx, %ebx
movq 0x48(%rsp), %r14
jle 0xe162
decq %rbx
xorl %ecx, %ecx
movl (%rsi,%rbx,4), %edx
movl %edx, (%rax,%rcx,4)
movl (%rsi,%rcx,4), %edx
movl %edx, (%rax,%rbx,4)
incq %rcx
leaq -0x1(%rbx), %rdx
cmpq %rbx, %rcx
movq %rdx, %rbx
jl 0xe147
movq %rax, (%r12)
movl %r15d, 0x8(%r12)
movq %rsi, %rbx
movq %r13, %rdi
callq 0x3070
movq %r14, %rdi
callq 0x3070
movq 0x50(%rsp), %rdi
callq 0x3070
movq 0x60(%rsp), %rdi
callq 0x3070
movq %rbx, %rdi
callq 0x3070
movq (%r12), %rax
movq 0x18(%rsp), %r15
movq %rax, 0x18(%r15)
movl 0x8(%r12), %eax
movl %eax, 0x20(%r15)
movq %r12, %rdi
callq 0x3070
jmp 0xd73a
movl $0x10, %ebp
xorl %r9d, %r9d
xorl %r14d, %r14d
movq 0x68(%rsp), %r12
movq 0xa8(%rsp), %rdi
jmp 0xdfd4
movq 0xb0(%rsp), %rdi
callq 0x42c8
jmp 0xd88e