// File: /workspace/github_c_makefile_star2_O3/rikuu[P]kermit/miniasm/asm.c
// Function: ma_ug_seq
int ma_ug_seq(ma_ug_t *g, const sdict_t *d, const ma_sub_t *sub, const char *fn)
{
	gzFile fp;
	kseq_t *ks;
	utg_intv_t *tmp;
	uint32_t i, j;

	fp = fn && strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
	if (fp == 0) return -1;
	ks = kseq_init(fp);

	tmp = (utg_intv_t*)calloc(d->n_seq, sizeof(utg_intv_t));
	for (i = 0; i < g->u.n; ++i) {
		ma_utg_t *u = &g->u.a[i];
		uint32_t l = 0;
		u->s = (char*)calloc(1, u->len + 1);
		memset(u->s, 'N', u->len);
		for (j = 0; j < u->n; ++j) {
			utg_intv_t *t = &tmp[u->a[j]>>33];
			assert(t->len == 0);
			t->utg = i, t->ori = u->a[j]>>32&1;
			t->start = l, t->len = (uint32_t)u->a[j];
			l += t->len;
		}
	}

	while (kseq_read(ks) >= 0) {
		int32_t id;
		utg_intv_t *t;
		ma_utg_t *u;
		id = sd_get(d, ks->name.s);
		if (id < 0 || tmp[id].len == 0) continue;
		t = &tmp[id];
		u = &g->u.a[t->utg];
		if (sub) {
			assert(sub[id].e - sub[id].s <= ks->seq.l);
			memmove(ks->seq.s, ks->seq.s + sub[id].s, sub[id].e - sub[id].s);
			ks->seq.l = sub[id].e - sub[id].s;
		}
		if (!t->ori) { // forward strand
			for (i = 0; i < t->len; ++i)
				u->s[t->start + i] = ks->seq.s[i];
		} else {
			for (i = 0; i < t->len; ++i) {
				int c = (uint8_t)ks->seq.s[ks->seq.l - 1 - i];
				u->s[t->start + i] = c >= 128? 'N' : comp_tab[c];
			}
		}
	}
	free(tmp);

	kseq_destroy(ks);
	gzclose(fp);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
testq %rcx, %rcx
je 0x73c4
cmpb $0x2d, (%rcx)
jne 0x73b3
cmpb $0x0, 0x1(%rcx)
je 0x73c4
leaq 0x2ca2(%rip), %rsi      # 0xa05c
movq %rcx, %rdi
callq 0x11a0
jmp 0x73e1
movq 0x6bfd(%rip), %rax      # 0xdfc8
movq (%rax), %rdi
callq 0x1150
leaq 0x2c82(%rip), %rsi      # 0xa05c
movl %eax, %edi
callq 0x1080
movq %rax, %rbx
testq %rax, %rax
je 0x7a38
movq %r14, 0x40(%rsp)
movl $0x1, %edi
movl $0x70, %esi
callq 0x10f0
movq %rax, %r14
movl $0x1, %edi
movl $0x20, %esi
callq 0x10f0
movq %rax, %r12
movq %rbx, 0x18(%rsp)
movq %rbx, 0x10(%rax)
movl $0x10000, 0x8(%rax)     # imm = 0x10000
movl $0x4000, %edi           # imm = 0x4000
callq 0x1160
movq %rax, 0x18(%r12)
movq %r14, 0x8(%rsp)
movq %r12, 0x68(%r14)
movq %r15, 0x50(%rsp)
movl (%r15), %edi
movl $0xc, %esi
callq 0x10f0
movq %rax, %rbp
movq %r13, 0x20(%rsp)
movq (%r13), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x7528
movq 0x20(%rsp), %rax
movq 0x10(%rax), %r13
xorl %r15d, %r15d
leaq (%r15,%r15,4), %r14
movl (%r13,%r14,8), %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leaq 0x1(%rbx), %rsi
movl $0x1, %edi
callq 0x10f0
movq %rax, 0x20(%r13,%r14,8)
movq %rax, %rdi
movl $0x4e, %esi
movq %rbx, %rdx
callq 0x10d0
movl 0x10(%r13,%r14,8), %eax
testq %rax, %rax
je 0x751a
leaq (,%r14,8), %rcx
addq %r13, %rcx
movq 0x18(%rcx), %rcx
movl %r15d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %esi, %esi
xorl %edi, %edi
movq (%rcx,%rsi,8), %r8
movq %r8, %r9
shrq $0x21, %r9
leaq (%r9,%r9,2), %r9
cmpl $0x0, 0x8(%rbp,%r9,4)
jne 0x7a5b
leaq (,%r9,4), %r9
addq %rbp, %r9
movq %r8, %r10
shrq %r10
andl $0x80000000, %r10d      # imm = 0x80000000
orl %edx, %r10d
movl %r10d, (%r9)
movl %edi, 0x4(%r9)
movl %r8d, 0x8(%r9)
addl %r8d, %edi
incq %rsi
cmpq %rsi, %rax
jne 0x74ce
incl %r15d
cmpq %r15, 0x10(%rsp)
ja 0x7476
movq 0x8(%rsp), %r15
leaq 0x48(%r15), %r14
leaq 0x30(%r15), %rbx
leaq 0x18(%r15), %rax
movq %rax, 0x48(%rsp)
xorl %eax, %eax
movq %rbx, 0x10(%rsp)
testl %eax, %eax
jne 0x75d3
movl 0x8(%r12), %edx
movl (%r12), %ecx
movl 0x4(%r12), %eax
testb $0x3, %dl
je 0x7568
cmpl %eax, %ecx
jge 0x79d4
movq 0x18(%r12), %rsi
cmpl %eax, %ecx
jl 0x75b4
movl $0x0, (%r12)
movq 0x10(%r12), %rdi
sarl $0x2, %edx
callq 0x1110
movl %eax, 0x4(%r12)
movl 0x8(%r12), %edx
movl %edx, %ecx
sarl $0x2, %ecx
cmpl %ecx, %eax
jge 0x75a3
andl $-0x4, %edx
incl %edx
movl %edx, 0x8(%r12)
testl %eax, %eax
je 0x79d4
movl (%r12), %ecx
movq 0x18(%r12), %rsi
movslq %ecx, %rdi
incl %ecx
movl %ecx, (%r12)
movzbl (%rsi,%rdi), %esi
movl %esi, 0x4(%rsp)
cmpl $0x40, %esi
je 0x75cf
cmpl $0x3e, %esi
jne 0x755b
movl %esi, 0x60(%r15)
xorl %eax, %eax
movq %rax, 0x48(%r15)
movq %rax, 0x30(%r15)
movq %rax, 0x18(%r15)
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
leaq 0x4(%rsp), %rcx
xorl %r8d, %r8d
callq 0x7bd6
testl %eax, %eax
js 0x7a4c
cmpl $0xa, 0x4(%rsp)
je 0x761c
movq %r12, %rdi
movl $0x2, %esi
movq 0x48(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x7bd6
cmpq $0x0, 0x40(%r15)
jne 0x7639
movq $0x100, 0x38(%r15)      # imm = 0x100
movl $0x100, %edi            # imm = 0x100
callq 0x1160
movq %rax, 0x40(%r15)
movl 0x8(%r12), %edx
testb $0x3, %dl
sete %sil
movl (%r12), %ecx
movl 0x4(%r12), %eax
cmpl %eax, %ecx
setl %dil
orb %dil, %sil
testb $0x1, %sil
movq 0x10(%rsp), %rbx
je 0x773d
movq 0x18(%r12), %rsi
testb $0x1, %dil
jne 0x76b4
movl $0x0, (%r12)
movq 0x10(%r12), %rdi
sarl $0x2, %edx
callq 0x1110
movl %eax, 0x4(%r12)
movl 0x8(%r12), %edx
movl %edx, %ecx
sarl $0x2, %ecx
cmpl %ecx, %eax
jge 0x76a3
andl $-0x4, %edx
incl %edx
movl %edx, 0x8(%r12)
testl %eax, %eax
je 0x773d
movl (%r12), %ecx
movq 0x18(%r12), %rsi
movslq %ecx, %rdi
incl %ecx
movl %ecx, (%r12)
movb (%rsi,%rdi), %sil
movzbl %sil, %edi
movl %edi, 0x4(%rsp)
cmpl $0x2a, %edi
jg 0x76d5
cmpl $0xa, %edi
je 0x7726
jmp 0x76ec
cmpl $0x2b, %edi
je 0x7745
cmpl $0x3e, %edi
je 0x7949
cmpl $0x40, %edi
je 0x7949
movq 0x30(%r15), %rax
movq 0x40(%r15), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%r15)
movb %sil, (%rcx,%rax)
movq %r12, %rdi
movl $0x2, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x7bd6
movl 0x8(%r12), %edx
movl (%r12), %ecx
movl 0x4(%r12), %eax
cmpl %eax, %ecx
setl %dil
testb $0x3, %dl
je 0x7666
cmpl %eax, %ecx
jl 0x7666
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq 0x30(%r15), %r13
movq 0x38(%r15), %rbx
leaq 0x1(%r13), %rcx
movq 0x40(%r15), %rax
cmpq %rbx, %rcx
jb 0x77a1
movq %rcx, %rdx
shrq %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x2, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x4, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x8, %rcx
orq %rdx, %rcx
movq %rcx, %rbx
shrq $0x10, %rbx
orq %rcx, %rbx
incq %rbx
movq %rbx, 0x38(%r15)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1180
movq %rax, 0x40(%r15)
movb $0x0, (%rax,%r13)
cmpl $0x2b, 0x4(%rsp)
jne 0x7885
cmpq %rbx, 0x50(%r15)
jae 0x77cb
movq %rbx, 0x50(%r15)
movq 0x58(%r15), %rdi
movq %rbx, %rsi
callq 0x1180
movq %rax, 0x58(%r15)
movl 0x8(%r12), %edx
movl (%r12), %ecx
movl 0x4(%r12), %eax
movq 0x10(%rsp), %rbx
testb $0x3, %dl
je 0x77eb
cmpl %eax, %ecx
jge 0x79d4
movq 0x18(%r12), %rsi
cmpl %eax, %ecx
jl 0x7837
movl $0x0, (%r12)
movq 0x10(%r12), %rdi
sarl $0x2, %edx
callq 0x1110
movl %eax, 0x4(%r12)
movl 0x8(%r12), %edx
movl %edx, %ecx
sarl $0x2, %ecx
cmpl %ecx, %eax
jge 0x7826
andl $-0x4, %edx
incl %edx
movl %edx, 0x8(%r12)
testl %eax, %eax
je 0x79d4
movl (%r12), %ecx
movq 0x18(%r12), %rsi
movslq %ecx, %rdi
incl %ecx
movl %ecx, (%r12)
movzbl (%rsi,%rdi), %esi
movl %esi, 0x4(%rsp)
cmpl $0xa, %esi
jne 0x77de
movq %r12, %rdi
movl $0x2, %esi
movq %r14, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x7bd6
movq (%rbx), %r13
movq (%r14), %rcx
testl %eax, %eax
js 0x7874
cmpq %r13, %rcx
jb 0x784d
movl $0x0, 0x60(%r15)
cmpq %rcx, %r13
jne 0x7a4c
testl %r13d, %r13d
js 0x7a4c
movq 0x10(%r15), %rsi
movq 0x50(%rsp), %rdi
callq 0x336b
testl %eax, %eax
js 0x79c2
movl %eax, %r15d
leaq (%r15,%r15,2), %rax
movl 0x8(%rbp,%rax,4), %ebx
testq %rbx, %rbx
je 0x79c2
movq %r14, 0x38(%rsp)
leaq (,%rax,4), %rdx
addq %rbp, %rdx
movl (%rdx), %esi
movl %esi, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rax,%rax,4), %r12
shlq $0x3, %r12
movq 0x20(%rsp), %rax
addq 0x10(%rax), %r12
movq 0x40(%rsp), %r14
testq %r14, %r14
je 0x7952
movq %rsi, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movl (%r14,%r15,8), %esi
movl 0x4(%r14,%r15,8), %edx
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
subl %esi, %edx
cmpq %rdx, %r13
jb 0x7a7a
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rdi
addq %rdi, %rsi
callq 0x1190
movl 0x4(%r14,%r15,8), %r13d
movl (%r14,%r15,8), %eax
movq 0x8(%rsp), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %eax
subl %eax, %r13d
movq %r13, 0x30(%rcx)
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rsi
jmp 0x7957
movl %edi, 0x60(%r15)
jmp 0x7745
movq 0x8(%rsp), %rcx
movq 0x40(%rcx), %rcx
testl %esi, %esi
movq 0x38(%rsp), %r14
js 0x7984
movl 0x4(%rdx), %eax
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movq 0x20(%r12), %rdi
leal (%rax,%rdx), %r8d
movb %sil, (%rdi,%r8)
incq %rdx
cmpq %rdx, %rbx
jne 0x7969
jmp 0x79c2
movl 0x4(%rdx), %eax
addq %r13, %rcx
decq %rcx
negq %rbx
xorl %edx, %edx
movsbq (%rcx,%rdx), %rsi
testq %rsi, %rsi
js 0x79a9
leaq 0x2d4d(%rip), %rdi      # 0xa6f0
movb (%rsi,%rdi), %sil
jmp 0x79ac
movb $0x4e, %sil
movq 0x20(%r12), %rdi
movl %eax, %r8d
movb %sil, (%rdi,%r8)
incl %eax
decq %rdx
cmpq %rdx, %rbx
jne 0x7992
movq 0x8(%rsp), %r15
movq 0x68(%r15), %r12
movl 0x60(%r15), %eax
jmp 0x7545
movq %rbp, %rdi
callq 0x1040
testq %r15, %r15
movq 0x18(%rsp), %r14
je 0x7a2c
movq 0x10(%r15), %rdi
callq 0x1040
movq 0x28(%r15), %rdi
callq 0x1040
movq 0x40(%r15), %rdi
callq 0x1040
movq 0x58(%r15), %rdi
callq 0x1040
movq 0x68(%r15), %rbx
testq %rbx, %rbx
je 0x7a24
movq 0x18(%rbx), %rdi
callq 0x1040
movq %rbx, %rdi
callq 0x1040
movq %r15, %rdi
callq 0x1040
movq %r14, %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x7a3d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
callq 0x1040
movq 0x18(%rsp), %r14
jmp 0x79e6
leaq 0x2c05(%rip), %rdi      # 0xa667
leaq 0x2c0a(%rip), %rsi      # 0xa673
leaq 0x2c11(%rip), %rcx      # 0xa681
movl $0xfb, %edx
callq 0x10c0
leaq 0x2c4a(%rip), %rdi      # 0xa6cb
leaq 0x2beb(%rip), %rsi      # 0xa673
leaq 0x2bf2(%rip), %rcx      # 0xa681
movl $0x10b, %edx            # imm = 0x10B
callq 0x10c0