// File: /workspace/github_c_makefile_star2_O0/sc932[P]ALE/src/ssw.c
// Function: banded_sw
static cigar* banded_sw (const int8_t* ref,
				 const int8_t* read,
				 int32_t refLen,
				 int32_t readLen,
				 int32_t score,
				 const uint32_t weight_gapO,  /* will be used as - */
				 const uint32_t weight_gapE,  /* will be used as - */
				 int32_t band_width,
				 const int8_t* mat,	/* pointer to the weight matrix */
				 int32_t n) {

	uint32_t *c = (uint32_t*)malloc(16 * sizeof(uint32_t)), *c1;
	int32_t i, j, e, f, temp1, temp2, s = 16, s1 = 8, l, max = 0, len;
	int64_t s2 = 1024;
	char op, prev_op;
	int32_t width, width_d, *h_b, *e_b, *h_c;
	int8_t *direction, *direction_line;
    len = refLen > readLen ? refLen : readLen;
	cigar* result = (cigar*)malloc(sizeof(cigar));
	h_b = (int32_t*)malloc(s1 * sizeof(int32_t));
	e_b = (int32_t*)malloc(s1 * sizeof(int32_t));
	h_c = (int32_t*)malloc(s1 * sizeof(int32_t));
	direction = (int8_t*)malloc(s2 * sizeof(int8_t));

	do {
		width = band_width * 2 + 3, width_d = band_width * 2 + 1;
		while (width >= s1) {
			++s1;
			kroundup32(s1);
			h_b = (int32_t*)realloc(h_b, s1 * sizeof(int32_t));
			e_b = (int32_t*)realloc(e_b, s1 * sizeof(int32_t));
			h_c = (int32_t*)realloc(h_c, s1 * sizeof(int32_t));
		}
		while (width_d * readLen * 3 >= s2) {   // width_d*readLen* overflow before s2
			++s2;
			kroundup32(s2);
			direction = (int8_t*)realloc(direction, s2 * sizeof(int8_t));
		}
		direction_line = direction;
		for (j = 1; LIKELY(j < width - 1); j ++) h_b[j] = 0;
		for (i = 0; LIKELY(i < readLen); i ++) {
			int32_t beg = 0, end = refLen - 1, u = 0, edge;
			j = i - band_width;	beg = beg > j ? beg : j; // band start
			j = i + band_width; end = end < j ? end : j; // band end
			edge = end + 1 < width - 1 ? end + 1 : width - 1;
			f = h_b[0] = e_b[0] = h_b[edge] = e_b[edge] = h_c[0] = 0;
			direction_line = direction + width_d * i * 3;

			for (j = beg; LIKELY(j <= end); j ++) {
				int32_t b, e1, f1, d, de, df, dh;
				set_u(u, band_width, i, j);	set_u(e, band_width, i - 1, j);
				set_u(b, band_width, i, j - 1); set_u(d, band_width, i - 1, j - 1);
				set_d(de, band_width, i, j, 0);
				set_d(df, band_width, i, j, 1);
				set_d(dh, band_width, i, j, 2);

				temp1 = i == 0 ? -weight_gapO : h_b[e] - weight_gapO;
				temp2 = i == 0 ? -weight_gapE : e_b[e] - weight_gapE;
                //fprintf(stderr, "e_b length: %d, u: %d\n", s1, u);
				e_b[u] = temp1 > temp2 ? temp1 : temp2;
				direction_line[de] = temp1 > temp2 ? 3 : 2;

				temp1 = h_c[b] - weight_gapO;
				temp2 = f - weight_gapE;
				f = temp1 > temp2 ? temp1 : temp2;
				direction_line[df] = temp1 > temp2 ? 5 : 4;

				e1 = e_b[u] > 0 ? e_b[u] : 0;
				f1 = f > 0 ? f : 0;
				temp1 = e1 > f1 ? e1 : f1;
				temp2 = h_b[d] + mat[ref[j] * n + read[i]];
				h_c[u] = temp1 > temp2 ? temp1 : temp2;

				if (h_c[u] > max) max = h_c[u];

				if (temp1 <= temp2) direction_line[dh] = 1;
				else direction_line[dh] = e1 > f1 ? direction_line[de] : direction_line[df];
			}
			for (j = 1; j <= u; j ++) h_b[j] = h_c[j];
		}
		band_width *= 2;
	} while (max < score && band_width <= len); // 2022-Apr-08
	band_width /= 2;

    //if (max < score)
	//	fprintf(stderr, "Warning: The alignment path of one pair of sequences may miss a small part. [ssw.c banded_sw]\n");
    
	// trace back
	i = readLen - 1;
	j = refLen - 1;
	e = 0;	// Count the number of M, D or I.
	l = 0;	// record length of current cigar
	op = prev_op = 'M';
	temp2 = 2;	// h
	while (LIKELY(i > 0)) {
		set_d(temp1, band_width, i, j, temp2);
		switch (direction_line[temp1]) {
			case 1:
				--i;
				--j;
				temp2 = 2;
				direction_line -= width_d * 3;
				op = 'M';
				break;
			case 2:
			 	--i;
				temp2 = 0;	// e
				direction_line -= width_d * 3;
				op = 'I';
				break;
			case 3:
				--i;
				temp2 = 2;
				direction_line -= width_d * 3;
				op = 'I';
				break;
			case 4:
				--j;
				temp2 = 1;
				op = 'D';
				break;
			case 5:
				--j;
				temp2 = 2;
				op = 'D';
				break;
			default:
				fprintf(stderr, "Trace back error: %d.\n", direction_line[temp1 - 1]);
				free(direction);
				free(h_c);
				free(e_b);
				free(h_b);
				free(c);
				free(result); 
				return 0;
		}
		if (op == prev_op) ++e;
		else {
			++l;
			while (l >= s) {
				++s;
				kroundup32(s);
				c = (uint32_t*)realloc(c, s * sizeof(uint32_t));
			}
			c[l - 1] = to_cigar_int(e, prev_op);
			prev_op = op;
			e = 1;
		}
	}
	if (op == 'M') {
		++l;
		while (l >= s) {
			++s;
			kroundup32(s);
			c = (uint32_t*)realloc(c, s * sizeof(uint32_t));
		}
		c[l - 1] = to_cigar_int(e + 1, op);
	}else {
		l += 2;
		while (l >= s) {
			++s;
			kroundup32(s);
			c = (uint32_t*)realloc(c, s * sizeof(uint32_t));
		}
		c[l - 2] = to_cigar_int(e, op);
		c[l - 1] = to_cigar_int(1, 'M');
	}

	// reverse cigar
	c1 = (uint32_t*)malloc(l * sizeof(uint32_t));
	s = 0;
	e = l - 1;
	while (LIKELY(s <= e)) {
		c1[s] = c[e];
		c1[e] = c[s];
		++ s;
		-- e;
	}
	result->seq = c1;
	result->length = l;

	free(direction);
	free(h_c);
	free(e_b);
	free(h_b);
	free(c);
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movl $0x40, %edi
callq 0x3420
movq %rax, -0x30(%rbp)
movl $0x10, -0x54(%rbp)
movl $0x8, -0x58(%rbp)
movl $0x0, -0x60(%rbp)
movq $0x400, -0x70(%rbp)     # imm = 0x400
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jle 0x132bc
movl -0x1c(%rbp), %eax
movl %eax, -0x100(%rbp)
jmp 0x132c5
movl -0x20(%rbp), %eax
movl %eax, -0x100(%rbp)
movl -0x100(%rbp), %eax
movl %eax, -0x64(%rbp)
movl $0x10, %edi
callq 0x3420
movq %rax, -0xb0(%rbp)
movslq -0x58(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3420
movq %rax, -0x88(%rbp)
movslq -0x58(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3420
movq %rax, -0x90(%rbp)
movslq -0x58(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3420
movq %rax, -0x98(%rbp)
movq -0x70(%rbp), %rdi
shlq $0x0, %rdi
callq 0x3420
movq %rax, -0xa0(%rbp)
movl 0x18(%rbp), %eax
shll %eax
addl $0x3, %eax
movl %eax, -0x78(%rbp)
movl 0x18(%rbp), %eax
shll %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x58(%rbp), %eax
jl 0x133fd
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
sarl %eax
orl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
sarl $0x2, %eax
orl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
sarl $0x4, %eax
orl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
sarl $0x8, %eax
orl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
sarl $0x10, %eax
orl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x88(%rbp), %rdi
movslq -0x58(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3470
movq %rax, -0x88(%rbp)
movq -0x90(%rbp), %rdi
movslq -0x58(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3470
movq %rax, -0x90(%rbp)
movq -0x98(%rbp), %rdi
movslq -0x58(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3470
movq %rax, -0x98(%rbp)
jmp 0x13345
jmp 0x133ff
movl -0x7c(%rbp), %eax
imull -0x20(%rbp), %eax
imull $0x3, %eax, %eax
cltq
cmpq -0x70(%rbp), %rax
jl 0x134a8
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
sarq %rax
orq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
sarq $0x2, %rax
orq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
sarq $0x4, %rax
orq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
sarq $0x8, %rax
orq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
sarq $0x10, %rax
orq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
movq -0xa0(%rbp), %rdi
movq -0x70(%rbp), %rsi
shlq $0x0, %rsi
callq 0x3470
movq %rax, -0xa0(%rbp)
jmp 0x133ff
movq -0xa0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl -0x78(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x134f5
movq -0x88(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x134bd
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x20(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x13bec
movl $0x0, -0xb4(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xb8(%rbp)
movl $0x0, -0xbc(%rbp)
movl -0x3c(%rbp), %eax
subl 0x18(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0x40(%rbp), %eax
jle 0x13558
movl -0xb4(%rbp), %eax
movl %eax, -0x104(%rbp)
jmp 0x13561
movl -0x40(%rbp), %eax
movl %eax, -0x104(%rbp)
movl -0x104(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0x3c(%rbp), %eax
addl 0x18(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x1358f
movl -0xb8(%rbp), %eax
movl %eax, -0x108(%rbp)
jmp 0x13598
movl -0x40(%rbp), %eax
movl %eax, -0x108(%rbp)
movl -0x108(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl -0x78(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x135c8
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0x135d4
movl -0x78(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
movl %eax, -0xc0(%rbp)
movq -0x98(%rbp), %rax
movl $0x0, (%rax)
movq -0x90(%rbp), %rax
movslq -0xc0(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x88(%rbp), %rax
movslq -0xc0(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movq -0x90(%rbp), %rax
movl $0x0, (%rax)
movq -0x88(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x48(%rbp)
movq -0xa0(%rbp), %rax
movl -0x7c(%rbp), %ecx
imull -0x3c(%rbp), %ecx
imull $0x3, %ecx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0xb8(%rbp), %eax
setle %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x13ba3
movl -0x3c(%rbp), %eax
subl 0x18(%rbp), %eax
movl %eax, -0xe0(%rbp)
cmpl $0x0, -0xe0(%rbp)
jle 0x1369f
movl -0xe0(%rbp), %eax
movl %eax, -0x110(%rbp)
jmp 0x136a9
xorl %eax, %eax
movl %eax, -0x110(%rbp)
jmp 0x136a9
movl -0x110(%rbp), %eax
movl %eax, -0xe0(%rbp)
movl -0x40(%rbp), %eax
subl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
movl -0x3c(%rbp), %eax
subl $0x1, %eax
subl 0x18(%rbp), %eax
movl %eax, -0xe4(%rbp)
cmpl $0x0, -0xe4(%rbp)
jle 0x136ed
movl -0xe4(%rbp), %eax
movl %eax, -0x114(%rbp)
jmp 0x136f7
xorl %eax, %eax
movl %eax, -0x114(%rbp)
jmp 0x136f7
movl -0x114(%rbp), %eax
movl %eax, -0xe4(%rbp)
movl -0x40(%rbp), %eax
subl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %eax
subl 0x18(%rbp), %eax
movl %eax, -0xe8(%rbp)
cmpl $0x0, -0xe8(%rbp)
jle 0x13735
movl -0xe8(%rbp), %eax
movl %eax, -0x118(%rbp)
jmp 0x1373f
xorl %eax, %eax
movl %eax, -0x118(%rbp)
jmp 0x1373f
movl -0x118(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl -0x40(%rbp), %eax
subl $0x1, %eax
subl -0xe8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
movl -0x3c(%rbp), %eax
subl $0x1, %eax
subl 0x18(%rbp), %eax
movl %eax, -0xec(%rbp)
cmpl $0x0, -0xec(%rbp)
jle 0x13786
movl -0xec(%rbp), %eax
movl %eax, -0x11c(%rbp)
jmp 0x13790
xorl %eax, %eax
movl %eax, -0x11c(%rbp)
jmp 0x13790
movl -0x11c(%rbp), %eax
movl %eax, -0xec(%rbp)
movl -0x40(%rbp), %eax
subl $0x1, %eax
subl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
movl -0x3c(%rbp), %eax
subl 0x18(%rbp), %eax
movl %eax, -0xf0(%rbp)
cmpl $0x0, -0xf0(%rbp)
jle 0x137d4
movl -0xf0(%rbp), %eax
movl %eax, -0x120(%rbp)
jmp 0x137de
xorl %eax, %eax
movl %eax, -0x120(%rbp)
jmp 0x137de
movl -0x120(%rbp), %eax
movl %eax, -0xf0(%rbp)
movl -0x40(%rbp), %eax
subl -0xf0(%rbp), %eax
movl %eax, -0xf0(%rbp)
imull $0x3, -0xf0(%rbp), %eax
addl $0x0, %eax
movl %eax, -0xd4(%rbp)
movl -0x3c(%rbp), %eax
subl 0x18(%rbp), %eax
movl %eax, -0xf4(%rbp)
cmpl $0x0, -0xf4(%rbp)
jle 0x1382c
movl -0xf4(%rbp), %eax
movl %eax, -0x124(%rbp)
jmp 0x13836
xorl %eax, %eax
movl %eax, -0x124(%rbp)
jmp 0x13836
movl -0x124(%rbp), %eax
movl %eax, -0xf4(%rbp)
movl -0x40(%rbp), %eax
subl -0xf4(%rbp), %eax
movl %eax, -0xf4(%rbp)
imull $0x3, -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd8(%rbp)
movl -0x3c(%rbp), %eax
subl 0x18(%rbp), %eax
movl %eax, -0xf8(%rbp)
cmpl $0x0, -0xf8(%rbp)
jle 0x13884
movl -0xf8(%rbp), %eax
movl %eax, -0x128(%rbp)
jmp 0x1388e
xorl %eax, %eax
movl %eax, -0x128(%rbp)
jmp 0x1388e
movl -0x128(%rbp), %eax
movl %eax, -0xf8(%rbp)
movl -0x40(%rbp), %eax
subl -0xf8(%rbp), %eax
movl %eax, -0xf8(%rbp)
imull $0x3, -0xf8(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xdc(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x138cc
xorl %eax, %eax
subl -0x28(%rbp), %eax
movl %eax, -0x12c(%rbp)
jmp 0x138e3
movq -0x88(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x12c(%rbp)
movl -0x12c(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0x138ff
xorl %eax, %eax
subl 0x10(%rbp), %eax
movl %eax, -0x130(%rbp)
jmp 0x13916
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %eax
subl 0x10(%rbp), %eax
movl %eax, -0x130(%rbp)
movl -0x130(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jle 0x13932
movl -0x4c(%rbp), %eax
movl %eax, -0x134(%rbp)
jmp 0x1393b
movl -0x50(%rbp), %eax
movl %eax, -0x134(%rbp)
movl -0x134(%rbp), %edx
movq -0x90(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x4c(%rbp), %edx
movl -0x50(%rbp), %esi
movl $0x2, %eax
movl $0x3, %ecx
cmpl %esi, %edx
cmovgl %ecx, %eax
movb %al, %dl
movq -0xa8(%rbp), %rax
movslq -0xd4(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x98(%rbp), %rax
movslq -0xc4(%rbp), %rcx
movl (%rax,%rcx,4), %eax
subl -0x28(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x48(%rbp), %eax
subl 0x10(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jle 0x139ad
movl -0x4c(%rbp), %eax
movl %eax, -0x138(%rbp)
jmp 0x139b6
movl -0x50(%rbp), %eax
movl %eax, -0x138(%rbp)
movl -0x138(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x4c(%rbp), %edx
movl -0x50(%rbp), %esi
movl $0x4, %eax
movl $0x5, %ecx
cmpl %esi, %edx
cmovgl %ecx, %eax
movb %al, %dl
movq -0xa8(%rbp), %rax
movslq -0xd8(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x90(%rbp), %rax
movslq -0xbc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0x13a14
movq -0x90(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x13c(%rbp)
jmp 0x13a1e
xorl %eax, %eax
movl %eax, -0x13c(%rbp)
jmp 0x13a1e
movl -0x13c(%rbp), %eax
movl %eax, -0xc8(%rbp)
cmpl $0x0, -0x48(%rbp)
jle 0x13a3b
movl -0x48(%rbp), %eax
movl %eax, -0x140(%rbp)
jmp 0x13a45
xorl %eax, %eax
movl %eax, -0x140(%rbp)
jmp 0x13a45
movl -0x140(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl -0xc8(%rbp), %eax
cmpl -0xcc(%rbp), %eax
jle 0x13a6d
movl -0xc8(%rbp), %eax
movl %eax, -0x144(%rbp)
jmp 0x13a79
movl -0xcc(%rbp), %eax
movl %eax, -0x144(%rbp)
movl -0x144(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x88(%rbp), %rax
movslq -0xd0(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq 0x20(%rbp), %rcx
movq -0x10(%rbp), %rdx
movslq -0x40(%rbp), %rsi
movsbl (%rdx,%rsi), %edx
imull 0x28(%rbp), %edx
movq -0x18(%rbp), %rsi
movslq -0x3c(%rbp), %rdi
movsbl (%rsi,%rdi), %esi
addl %esi, %edx
movslq %edx, %rdx
movsbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jle 0x13ad4
movl -0x4c(%rbp), %eax
movl %eax, -0x148(%rbp)
jmp 0x13add
movl -0x50(%rbp), %eax
movl %eax, -0x148(%rbp)
movl -0x148(%rbp), %edx
movq -0x98(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x98(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x60(%rbp), %eax
jle 0x13b1e
movq -0x98(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jg 0x13b3a
movq -0xa8(%rbp), %rax
movslq -0xdc(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0x13b93
movl -0xc8(%rbp), %eax
cmpl -0xcc(%rbp), %eax
jle 0x13b62
movq -0xa8(%rbp), %rax
movslq -0xd4(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x14c(%rbp)
jmp 0x13b7a
movq -0xa8(%rbp), %rax
movslq -0xd8(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x14c(%rbp)
movl -0x14c(%rbp), %eax
movb %al, %dl
movq -0xa8(%rbp), %rax
movslq -0xdc(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x13b95
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1365f
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0xbc(%rbp), %eax
jg 0x13bdc
movq -0x98(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x88(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x13baa
jmp 0x13bde
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x134fc
movl 0x18(%rbp), %eax
shll %eax
movl %eax, 0x18(%rbp)
movl -0x60(%rbp), %ecx
xorl %eax, %eax
cmpl -0x24(%rbp), %ecx
movb %al, -0x14d(%rbp)
jge 0x13c13
movl 0x18(%rbp), %eax
cmpl -0x64(%rbp), %eax
setle %al
movb %al, -0x14d(%rbp)
movb -0x14d(%rbp), %al
testb $0x1, %al
jne 0x1332f
movl 0x18(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0x18(%rbp)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x5c(%rbp)
movb $0x4d, -0x72(%rbp)
movb $0x4d, -0x71(%rbp)
movl $0x2, -0x50(%rbp)
cmpl $0x0, -0x3c(%rbp)
setg %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x13f2d
movl -0x3c(%rbp), %eax
subl 0x18(%rbp), %eax
movl %eax, -0xfc(%rbp)
cmpl $0x0, -0xfc(%rbp)
jle 0x13c99
movl -0xfc(%rbp), %eax
movl %eax, -0x154(%rbp)
jmp 0x13ca3
xorl %eax, %eax
movl %eax, -0x154(%rbp)
jmp 0x13ca3
movl -0x154(%rbp), %eax
movl %eax, -0xfc(%rbp)
movl -0x40(%rbp), %eax
movl -0xfc(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0xfc(%rbp)
movl -0xfc(%rbp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movl -0x50(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0xa8(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x160(%rbp)
subl $0x4, %eax
ja 0x13de7
movq -0x160(%rbp), %rax
leaq 0x1e23c(%rip), %rcx     # 0x31f40
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
movl $0x2, -0x50(%rbp)
imull $0x3, -0x7c(%rbp), %ecx
movq -0xa8(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movb $0x4d, -0x71(%rbp)
jmp 0x13e65
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x50(%rbp)
imull $0x3, -0x7c(%rbp), %ecx
movq -0xa8(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movb $0x49, -0x71(%rbp)
jmp 0x13e65
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movl $0x2, -0x50(%rbp)
imull $0x3, -0x7c(%rbp), %ecx
movq -0xa8(%rbp), %rax
movslq %ecx, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movb $0x49, -0x71(%rbp)
jmp 0x13e65
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
movl $0x1, -0x50(%rbp)
movb $0x44, -0x71(%rbp)
jmp 0x13e65
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
movl $0x2, -0x50(%rbp)
movb $0x44, -0x71(%rbp)
jmp 0x13e65
movq 0x2520a(%rip), %rax     # 0x38ff8
movq (%rax), %rdi
movq -0xa8(%rbp), %rax
movl -0x4c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edx
leaq 0x1e339(%rip), %rsi     # 0x32145
movb $0x0, %al
callq 0x3350
movq -0xa0(%rbp), %rdi
callq 0x3050
movq -0x98(%rbp), %rdi
callq 0x3050
movq -0x90(%rbp), %rdi
callq 0x3050
movq -0x88(%rbp), %rdi
callq 0x3050
movq -0x30(%rbp), %rdi
callq 0x3050
movq -0xb0(%rbp), %rdi
callq 0x3050
movq $0x0, -0x8(%rbp)
jmp 0x14171
movsbl -0x71(%rbp), %eax
movsbl -0x72(%rbp), %ecx
cmpl %ecx, %eax
jne 0x13e7f
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x13f28
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0x13efd
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x2, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x4, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x8, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x10, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x54(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3470
movq %rax, -0x30(%rbp)
jmp 0x13e88
movl -0x44(%rbp), %edi
movsbl -0x72(%rbp), %esi
callq 0x142a0
movl %eax, %edx
movq -0x30(%rbp), %rax
movl -0x5c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movb -0x71(%rbp), %al
movb %al, -0x72(%rbp)
movl $0x1, -0x44(%rbp)
jmp 0x13c5e
movsbl -0x71(%rbp), %eax
cmpl $0x4d, %eax
jne 0x13fde
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0x13fb8
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x2, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x4, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x8, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x10, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x54(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3470
movq %rax, -0x30(%rbp)
jmp 0x13f43
movl -0x44(%rbp), %edi
addl $0x1, %edi
movsbl -0x71(%rbp), %esi
callq 0x142a0
movl %eax, %edx
movq -0x30(%rbp), %rax
movl -0x5c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x1409b
movl -0x5c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0x1405c
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x2, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x4, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x8, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
sarl $0x10, %eax
orl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x54(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3470
movq %rax, -0x30(%rbp)
jmp 0x13fe7
movl -0x44(%rbp), %edi
movsbl -0x71(%rbp), %esi
callq 0x142a0
movl %eax, %edx
movq -0x30(%rbp), %rax
movl -0x5c(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl $0x1, %edi
movl $0x4d, %esi
callq 0x142a0
movl %eax, %edx
movq -0x30(%rbp), %rax
movl -0x5c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movslq -0x5c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x3420
movq %rax, -0x38(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x5c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x44(%rbp), %eax
setle %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x14112
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x38(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x140bc
movq -0x38(%rbp), %rcx
movq -0xb0(%rbp), %rax
movq %rcx, (%rax)
movl -0x5c(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xa0(%rbp), %rdi
callq 0x3050
movq -0x98(%rbp), %rdi
callq 0x3050
movq -0x90(%rbp), %rdi
callq 0x3050
movq -0x88(%rbp), %rdi
callq 0x3050
movq -0x30(%rbp), %rdi
callq 0x3050
movq -0xb0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nop