// File: /workspace/github_c_makefile_star2_O3/lh3[P]minigraph/ggen.c
// Function: mg_path2seq
int32_t mg_path2seq(void *km, const gfa_t *g, const mg_gchains_t *gcs, int32_t ls, int32_t le, int32_t voff[2], char **seq_, int32_t *cap_) // NB: [ls,le] is a CLOSED interval
{
	extern unsigned char gfa_comp_table[256];
	int32_t i, k, l = 0, cap = *cap_;
	char *seq = *seq_;
	assert(0 <= ls && ls <= le && le < gcs->n_lc);
	for (k = ls; k <= le; ++k) {
		uint32_t v = gcs->lc[k].v, len = g->seg[v>>1].len;
		int32_t st = 0, en = len, tmp;
		if (k == ls) st = voff[0];
		if (k == le) en = voff[1];
		assert(0 <= st && st <= en && en <= len);
		if (en - st + l + 1 > cap) {
			cap = en - st + l + 1;
			kroundup32(cap);
			KREALLOC(km, seq, cap);
		}
		if (v&1) {
			uint8_t *ss = (uint8_t*)g->seg[v>>1].seq;
			tmp = st, st = len - en, en = len - tmp;
			for (i = en - 1; i >= st; --i)
				seq[l++] = gfa_comp_table[ss[i]];
		} else {
			memcpy(&seq[l], &g->seg[v>>1].seq[st], en - st);
			l += en - st;
		}
	}
	if (l == 0 && cap == 0) {
		cap = 8;
		KREALLOC(km, seq, cap);
	}
	seq[l] = 0;
	*seq_ = seq, *cap_ = cap;
	return l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdi, 0x28(%rsp)
testl %ecx, %ecx
js 0x24eed
cmpl %r8d, %ecx
jg 0x24eed
movq 0x38(%rsp), %rax
cmpl %r8d, 0xc(%rax)
jle 0x24eed
movq 0x98(%rsp), %rax
movq 0x90(%rsp), %rdx
movl (%rax), %esi
movq (%rdx), %r9
movl %ecx, %r14d
movl %r8d, %eax
movq %rax, 0x48(%rsp)
xorl %edi, %edi
movq %r14, 0x50(%rsp)
movl %r8d, 0x10(%rsp)
movl $0x0, %r13d
cmpq 0x50(%rsp), %r14
jne 0x24d29
movq 0x30(%rsp), %rax
movl (%rax), %r13d
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rax
leaq (%r14,%r14,4), %rcx
movl 0x8(%rax,%rcx,4), %edx
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl %edx, %r12d
shrl %r12d
shlq $0x6, %r12
movl (%rax,%r12), %r15d
movl %r15d, %eax
cmpq 0x48(%rsp), %r14
jne 0x24d63
movq 0x30(%rsp), %rax
movl 0x4(%rax), %eax
testl %r13d, %r13d
js 0x24ece
movl %eax, %ebx
subl %r13d, %ebx
jl 0x24ece
movl %r15d, %ebp
subl %eax, %ebp
jb 0x24ece
leal (%rbx,%rdi), %ecx
cmpl %esi, %ecx
movl %ecx, 0x14(%rsp)
jge 0x24d93
movl %esi, 0xc(%rsp)
jmp 0x24de0
movl %ecx, %eax
sarl %eax
orl %ecx, %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, %eax
sarl $0x10, %eax
orl %ecx, %eax
incl %eax
movl %eax, 0xc(%rsp)
movl %edx, 0x24(%rsp)
movslq %eax, %rdx
movq %rdi, 0x40(%rsp)
movq 0x28(%rsp), %rdi
movq %r9, %rsi
callq 0x31ed
movl 0x24(%rsp), %edx
movq 0x40(%rsp), %rdi
movq %rax, %r9
testb $0x1, %dl
jne 0x24e17
movslq %edi, %rdi
addq %r9, %rdi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl %r13d, %esi
addq 0x20(%rax,%r12), %rsi
movslq %ebx, %rdx
movq %r9, %rbx
callq 0x2230
movq %rbx, %r9
movl 0x14(%rsp), %eax
movl %eax, %edi
movl 0x10(%rsp), %r8d
jmp 0x24e68
notl %r13d
addl %r13d, %r15d
cmpl %ebp, %r15d
movl 0x10(%rsp), %r8d
leaq 0xd3d4(%rip), %r10      # 0x32200
jl 0x24e68
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax,%r12), %rax
movslq %r15d, %rcx
movslq %ebp, %rdx
movslq %edi, %rsi
addq %r9, %rsi
incq %rcx
movzbl -0x1(%rax,%rcx), %edi
movb (%r10,%rdi), %dil
movb %dil, (%rsi)
incq %rsi
decq %rcx
cmpq %rdx, %rcx
jg 0x24e4b
movl 0x14(%rsp), %eax
movl %eax, %edi
movl 0xc(%rsp), %esi
leaq 0x1(%r14), %rax
cmpl %r8d, %r14d
movq %rax, %r14
jl 0x24d14
movl %edi, %eax
orl %esi, %eax
jne 0x24ea2
movl $0x8, %edx
movq %rdi, %rbx
movq 0x28(%rsp), %rdi
movq %r9, %rsi
callq 0x31ed
movq %rbx, %rdi
movq %rax, %r9
movl $0x8, %esi
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %rdx
movslq %edi, %rax
movb $0x0, (%r9,%rax)
movq %r9, (%rdx)
movl %esi, (%rcx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5808(%rip), %rdi      # 0x2a6dd
leaq 0x5788(%rip), %rsi      # 0x2a664
leaq 0x5788(%rip), %rcx      # 0x2a66b
movl $0x9f, %edx
callq 0x2160
leaq 0x574a(%rip), %rdi      # 0x2a63e
leaq 0x5769(%rip), %rsi      # 0x2a664
leaq 0x5769(%rip), %rcx      # 0x2a66b
movl $0x99, %edx
callq 0x2160