// File: /workspace/github_c_makefile_star2_O2/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 %rdi, 0x20(%rsp)
testl %ecx, %ecx
js 0x20d76
cmpl %r8d, %ecx
jg 0x20d76
movq 0x38(%rsp), %rax
cmpl %r8d, 0xc(%rax)
jle 0x20d76
movq 0x98(%rsp), %rax
movq 0x90(%rsp), %rdx
movl (%rax), %edi
movq (%rdx), %r9
movl %ecx, %eax
movl %r8d, %ecx
movq %rcx, 0x40(%rsp)
xorl %r13d, %r13d
leaq 0xd673(%rip), %r10      # 0x2e200
movq %rax, 0x48(%rsp)
movq %rax, %rdx
movl %r8d, 0xc(%rsp)
movq %rsi, 0x28(%rsp)
movslq %r13d, %rbx
cmpl %r8d, %edx
jg 0x20d11
xorl %r8d, %r8d
cmpq 0x48(%rsp), %rdx
jne 0x20bbd
movq 0x30(%rsp), %rax
movl (%rax), %r8d
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rax
imulq $0x14, %rdx, %rcx
movl 0x8(%rax,%rcx), %r11d
movq 0x10(%rsi), %rax
movl %r11d, %r14d
shrl %r14d
shlq $0x6, %r14
movl (%rax,%r14), %ecx
movl %ecx, %eax
cmpq 0x40(%rsp), %rdx
jne 0x20bf2
movq 0x30(%rsp), %rax
movl 0x4(%rax), %eax
testl %r8d, %r8d
js 0x20d57
movl %eax, %r15d
subl %r8d, %r15d
jl 0x20d57
movl %ecx, %r12d
subl %eax, %r12d
jb 0x20d57
leal (%r15,%r13), %ebp
cmpl %edi, %ebp
movq %rdx, 0x50(%rsp)
jge 0x20c26
movl %edi, 0x10(%rsp)
jmp 0x20c89
movl %ebp, %eax
sarl %eax
orl %ebp, %eax
movl %ecx, 0x18(%rsp)
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, 0x10(%rsp)
movslq %eax, %rdx
movq 0x20(%rsp), %rdi
movq %r9, %rsi
movl %r8d, 0x1c(%rsp)
movl %r11d, 0x14(%rsp)
callq 0x2774
movl 0x14(%rsp), %r11d
movl 0x18(%rsp), %ecx
movl 0x1c(%rsp), %r8d
leaq 0xd57f(%rip), %r10      # 0x2e200
movq 0x28(%rsp), %rsi
movq %rax, %r9
testb $0x1, %r11b
jne 0x20cc2
addq %r9, %rbx
movq 0x10(%rsi), %rax
movl %r8d, %esi
addq 0x20(%rax,%r14), %rsi
movslq %r15d, %rdx
movq %rbx, %rdi
movq %r9, %rbx
callq 0x2230
leaq 0xd54d(%rip), %r10      # 0x2e200
movq 0x28(%rsp), %rsi
movq %rbx, %r9
movl 0xc(%rsp), %r8d
jmp 0x20cfd
movq 0x10(%rsi), %rax
movq 0x20(%rax,%r14), %rax
notl %r8d
addl %r8d, %ecx
movslq %ecx, %rcx
movslq %r12d, %rdx
addq %r9, %rbx
movl 0xc(%rsp), %r8d
cmpq %rdx, %rcx
jl 0x20cfa
movzbl (%rax,%rcx), %edi
movb (%r10,%rdi), %dil
movb %dil, (%rbx)
decq %rcx
incl %r13d
incq %rbx
jmp 0x20cdf
movl %r13d, %ebp
movq 0x50(%rsp), %rdx
incq %rdx
movl %ebp, %r13d
movl 0x10(%rsp), %edi
jmp 0x20b9f
orl %edi, %r13d
jne 0x20d2c
pushq $0x8
popq %rdx
movq 0x20(%rsp), %rdi
movq %r9, %rsi
callq 0x2774
movq %rax, %r9
pushq $0x8
popq %rdi
movb $0x0, (%r9,%rbx)
movq 0x90(%rsp), %rax
movq %r9, (%rax)
movq 0x98(%rsp), %rax
movl %edi, (%rax)
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x495f(%rip), %rdi      # 0x256bd
leaq 0x48df(%rip), %rsi      # 0x25644
leaq 0x48df(%rip), %rcx      # 0x2564b
movl $0x9f, %edx
callq 0x2160
leaq 0x48a1(%rip), %rdi      # 0x2561e
leaq 0x48c0(%rip), %rsi      # 0x25644
leaq 0x48c0(%rip), %rcx      # 0x2564b
movl $0x99, %edx
callq 0x2160