// File: /workspace/github_c_makefile_star2_O1/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 0x2507b
cmpl %r8d, %ecx
jg 0x2507b
movq 0x38(%rsp), %rax
cmpl %r8d, 0xc(%rax)
jle 0x2507b
movq 0x98(%rsp), %rax
movq 0x90(%rsp), %rdx
movq (%rdx), %r9
movl (%rax), %esi
xorl %edi, %edi
cmpl %r8d, %ecx
jg 0x2500c
movl %ecx, %r15d
movl %r8d, %eax
movq %rax, 0x48(%rsp)
xorl %r11d, %r11d
movq %r15, 0x50(%rsp)
movl %r8d, 0x10(%rsp)
movl $0x0, %r14d
cmpq 0x50(%rsp), %r15
jne 0x24eb4
movq 0x30(%rsp), %rax
movl (%rax), %r14d
movq 0x38(%rsp), %rax
movq 0x20(%rax), %rax
leaq (%r15,%r15,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), %r13d
movl %r13d, %eax
cmpq 0x48(%rsp), %r15
jne 0x24eee
movq 0x30(%rsp), %rax
movl 0x4(%rax), %eax
testl %r14d, %r14d
js 0x2505c
movl %eax, %ebp
subl %r14d, %ebp
jl 0x2505c
movl %r13d, %ebx
subl %eax, %ebx
jb 0x2505c
leal (%r11,%rbp), %ecx
cmpl %esi, %ecx
movl %ecx, 0x14(%rsp)
jge 0x24f1f
movl %esi, 0xc(%rsp)
jmp 0x24f6c
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 0x28(%rsp), %rdi
movq %r9, %rsi
movq %r11, 0x40(%rsp)
callq 0x32c4
movl 0x24(%rsp), %edx
movq 0x40(%rsp), %r11
movq %rax, %r9
testb $0x1, %dl
jne 0x24f9d
movslq %r11d, %rdi
addq %r9, %rdi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl %r14d, %esi
addq 0x20(%rax,%r12), %rsi
movslq %ebp, %rdx
movq %r9, %rbx
callq 0x2230
movq %rbx, %r9
movl 0x10(%rsp), %r8d
jmp 0x24ff1
notl %r14d
addl %r14d, %r13d
cmpl %ebx, %r13d
movl 0x10(%rsp), %r8d
leaq 0xd24e(%rip), %r10      # 0x32200
jge 0x24fbd
movl %r11d, %edi
movl 0xc(%rsp), %esi
jmp 0x24ff9
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax,%r12), %rax
movslq %r13d, %rcx
movslq %ebx, %rdx
movslq %r11d, %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 0x24fda
movl 0xc(%rsp), %esi
movl 0x14(%rsp), %edi
leaq 0x1(%r15), %rax
movl %edi, %r11d
cmpl %r8d, %r15d
movq %rax, %r15
jl 0x24e9f
movl %edi, %eax
orl %esi, %eax
jne 0x25030
movl $0x8, %edx
movl %edi, %ebx
movq 0x28(%rsp), %rdi
movq %r9, %rsi
callq 0x32c4
movl %ebx, %edi
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 0x55e2(%rip), %rdi      # 0x2a645
leaq 0x5562(%rip), %rsi      # 0x2a5cc
leaq 0x5562(%rip), %rcx      # 0x2a5d3
movl $0x9f, %edx
callq 0x2160
leaq 0x5524(%rip), %rdi      # 0x2a5a6
leaq 0x5543(%rip), %rsi      # 0x2a5cc
leaq 0x5543(%rip), %rcx      # 0x2a5d3
movl $0x99, %edx
callq 0x2160