// File: /workspace/github_c_makefile_star2_O1/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, 0x40(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
testq %rcx, %rcx
je 0x7535
movq %rcx, %rbx
leaq 0x3089(%rip), %rsi      # 0xa5a1
movq %rcx, %rdi
callq 0x1100
testl %eax, %eax
je 0x7535
leaq 0x2b31(%rip), %rsi      # 0xa05c
movq %rbx, %rdi
callq 0x11a0
jmp 0x7552
movq 0x7a8c(%rip), %rax      # 0xefc8
movq (%rax), %rdi
callq 0x1150
leaq 0x2b11(%rip), %rsi      # 0xa05c
movl %eax, %edi
callq 0x1080
movq %rax, %r14
testq %rax, %rax
je 0x7b77
movl $0x1, %edi
movl $0x70, %esi
callq 0x10f0
movq %rax, %r13
movl $0x1, %edi
movl $0x20, %esi
callq 0x10f0
movq %rax, %rbx
movq %r14, 0x28(%rsp)
movq %r14, 0x10(%rax)
movl 0x8(%rax), %eax
andl $0x3, %eax
orl $0x10000, %eax          # imm = 0x10000
movl %eax, 0x8(%rbx)
movl $0x4000, %edi           # imm = 0x4000
callq 0x1160
movq %rax, 0x18(%rbx)
movq %rbx, 0x68(%r13)
movq 0x10(%rsp), %rax
movl (%rax), %edi
movl $0xc, %esi
callq 0x10f0
movq %rax, %rbp
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x768a
movq 0x18(%rsp), %rax
movq 0x10(%rax), %r15
xorl %r12d, %r12d
leaq (%r12,%r12,4), %r14
movl (%r15,%r14,8), %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leaq 0x1(%rbx), %rsi
movl $0x1, %edi
callq 0x10f0
movq %rax, 0x20(%r15,%r14,8)
movq %rax, %rdi
movl $0x4e, %esi
movq %rbx, %rdx
callq 0x10d0
movl 0x10(%r15,%r14,8), %eax
testq %rax, %rax
je 0x767c
leaq (%r15,%r14,8), %rcx
movq 0x18(%rcx), %rcx
movl %r12d, %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 0x7b8b
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
cmpl %esi, %eax
jne 0x7631
incl %r12d
cmpq %r12, 0x20(%rsp)
ja 0x75e1
leaq 0x48(%r13), %rax
movq %rax, 0x38(%rsp)
leaq 0x30(%r13), %rax
movq %rax, 0x20(%rsp)
leaq 0x18(%r13), %rax
movq %rax, 0x30(%rsp)
movq 0x10(%rsp), %rbx
movq 0x68(%r13), %r15
cmpl $0x0, 0x60(%r13)
jne 0x774e
jmp 0x76c3
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x772b
movl 0x8(%r15), %edx
testb $0x3, %dl
je 0x76db
movl (%r15), %eax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl 0x4(%r15), %eax
jge 0x772b
movl (%r15), %eax
cmpl 0x4(%r15), %eax
jl 0x7719
movl $0x0, (%r15)
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
sarl $0x2, %edx
callq 0x1110
movl %eax, 0x4(%r15)
movl 0x8(%r15), %ecx
movl %ecx, %edx
sarl $0x2, %edx
cmpl %edx, %eax
jge 0x7715
andl $-0x4, %ecx
incl %ecx
movl %ecx, 0x8(%r15)
testl %eax, %eax
je 0x76bb
movq 0x18(%r15), %rax
movslq (%r15), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%r15)
movzbl (%rax,%rcx), %r14d
movl %r14d, 0xc(%rsp)
cmpl $-0x1, %r14d
je 0x79d3
cmpl $0x40, %r14d
je 0x774a
cmpl $0x3e, %r14d
jne 0x76c3
movl %r14d, 0x60(%r13)
xorl %eax, %eax
movq %rax, 0x48(%r13)
movq %rax, 0x30(%r13)
movq %rax, 0x18(%r13)
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
leaq 0xc(%rsp), %rcx
xorl %r8d, %r8d
callq 0x7d00
testl %eax, %eax
js 0x787a
cmpl $0xa, 0xc(%rsp)
je 0x7797
movq %r15, %rdi
movl $0x2, %esi
movq 0x30(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x7d00
cmpq $0x0, 0x40(%r13)
movq 0x20(%rsp), %r12
jne 0x77b9
movq $0x100, 0x38(%r13)      # imm = 0x100
movl $0x100, %edi            # imm = 0x100
callq 0x1160
movq %rax, 0x40(%r13)
movl 0x8(%r15), %edx
testb $0x3, %dl
je 0x77d0
movl (%r15), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl 0x4(%r15), %ecx
jge 0x781f
movl (%r15), %eax
cmpl 0x4(%r15), %eax
jl 0x780e
movl $0x0, (%r15)
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
sarl $0x2, %edx
callq 0x1110
movl %eax, 0x4(%r15)
movl 0x8(%r15), %ecx
movl %ecx, %edx
sarl $0x2, %edx
cmpl %edx, %eax
jge 0x780a
andl $-0x4, %ecx
incl %ecx
movl %ecx, 0x8(%r15)
testl %eax, %eax
je 0x7873
movq 0x18(%r15), %rax
movslq (%r15), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%r15)
movzbl (%rax,%rcx), %eax
movl %eax, 0xc(%rsp)
cmpl $0x2a, %eax
jg 0x7834
cmpl $0xa, %eax
je 0x77b9
cmpl $-0x1, %eax
jne 0x7843
jmp 0x7889
cmpl $0x2b, %eax
je 0x7889
cmpl $0x3e, %eax
je 0x7885
cmpl $0x40, %eax
je 0x7885
movq 0x30(%r13), %rcx
movq 0x40(%r13), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r13)
movb %al, (%rdx,%rcx)
movq %r15, %rdi
movl $0x2, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x7d00
jmp 0x77b9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x781f
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x79d3
movl %eax, 0x60(%r13)
movq 0x30(%r13), %r14
leaq 0x1(%r14), %rax
cmpq 0x38(%r13), %rax
jb 0x78dc
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x38(%r13)
movq 0x40(%r13), %rdi
callq 0x1180
movq %rax, 0x40(%r13)
movq 0x40(%r13), %rax
movb $0x0, (%rax,%r14)
cmpl $0x2b, 0xc(%rsp)
jne 0x79d3
movq 0x38(%r13), %rsi
cmpq %rsi, 0x50(%r13)
jae 0x790b
movq %rsi, 0x50(%r13)
movq 0x58(%r13), %rdi
callq 0x1180
movq %rax, 0x58(%r13)
movq 0x38(%rsp), %r14
movl 0x8(%r15), %edx
testb $0x3, %dl
je 0x7927
movl (%r15), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl 0x4(%r15), %ecx
jge 0x7976
movl (%r15), %eax
cmpl 0x4(%r15), %eax
jl 0x7965
movl $0x0, (%r15)
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
sarl $0x2, %edx
callq 0x1110
movl %eax, 0x4(%r15)
movl 0x8(%r15), %ecx
movl %ecx, %edx
sarl $0x2, %edx
cmpl %edx, %eax
jge 0x7961
andl $-0x4, %ecx
incl %ecx
movl %ecx, 0x8(%r15)
testl %eax, %eax
je 0x7986
movq 0x18(%r15), %rax
movslq (%r15), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%r15)
movzbl (%rax,%rcx), %eax
movl %eax, 0xc(%rsp)
cmpl $-0x1, %eax
je 0x79cd
cmpl $0xa, %eax
jne 0x7910
jmp 0x798d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x7976
movq %r15, %rdi
movl $0x2, %esi
movq %r14, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x7d00
testl %eax, %eax
js 0x79b2
movq (%r14), %rax
cmpq (%r12), %rax
jb 0x798d
movl $0x0, 0x60(%r13)
movq 0x30(%r13), %r14
cmpq 0x48(%r13), %r14
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmovnel %eax, %r14d
jmp 0x79d3
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
testl %r14d, %r14d
js 0x7b13
movq 0x10(%r13), %rsi
movq %rbx, %rdi
callq 0x3428
testl %eax, %eax
js 0x76aa
movl %eax, %r12d
leaq (%r12,%r12,2), %rax
movl 0x8(%rbp,%rax,4), %r15d
testl %r15d, %r15d
je 0x76aa
leaq (,%rax,4), %rsi
addq %rbp, %rsi
movl (%rsi), %ecx
movl %ecx, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq (%rax,%rax,4), %r14
shlq $0x3, %r14
movq 0x18(%rsp), %rax
addq 0x10(%rax), %r14
movq 0x40(%rsp), %rbx
testq %rbx, %rbx
je 0x7a85
movq %rcx, 0x48(%rsp)
movq %rsi, 0x50(%rsp)
movl (%rbx,%r12,8), %esi
movl 0x4(%rbx,%r12,8), %edx
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
subl %esi, %edx
cmpq %rdx, 0x30(%r13)
jb 0x7baa
movq 0x40(%r13), %rdi
addq %rdi, %rsi
callq 0x1190
movl 0x4(%rbx,%r12,8), %eax
movl (%rbx,%r12,8), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
subl %ecx, %eax
movq %rax, 0x30(%r13)
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rcx
testl %ecx, %ecx
js 0x7abc
movq 0x40(%r13), %rax
movl 0x4(%rsi), %ecx
cmpl $0x1, %r15d
adcl $0x0, %r15d
xorl %edx, %edx
movq 0x10(%rsp), %rbx
movb (%rax,%rdx), %sil
movq 0x20(%r14), %rdi
leal (%rcx,%rdx), %r8d
movb %sil, (%rdi,%r8)
incq %rdx
cmpq %rdx, %r15
jne 0x7a9f
jmp 0x76aa
movq 0x30(%r13), %rcx
movq 0x40(%r13), %rdx
cmpl $0x1, %r15d
adcl $0x0, %r15d
movl 0x4(%rsi), %eax
addq %rdx, %rcx
decq %rcx
negq %r15
xorl %edx, %edx
movq 0x10(%rsp), %rbx
movsbq (%rcx,%rdx), %rsi
testq %rsi, %rsi
js 0x7af6
leaq 0x2c30(%rip), %rdi      # 0xa720
movb (%rsi,%rdi), %sil
jmp 0x7af9
movb $0x4e, %sil
movq 0x20(%r14), %rdi
movl %eax, %r8d
movb %sil, (%rdi,%r8)
incl %eax
decq %rdx
cmpq %rdx, %r15
jne 0x7adf
jmp 0x76aa
movq %rbp, %rdi
callq 0x1040
testq %r13, %r13
movq 0x28(%rsp), %r14
je 0x7b6b
movq 0x10(%r13), %rdi
callq 0x1040
movq 0x28(%r13), %rdi
callq 0x1040
movq 0x40(%r13), %rdi
callq 0x1040
movq 0x58(%r13), %rdi
callq 0x1040
movq 0x68(%r13), %rbx
testq %rbx, %rbx
je 0x7b63
movq 0x18(%rbx), %rdi
callq 0x1040
movq %rbx, %rdi
callq 0x1040
movq %r13, %rdi
callq 0x1040
movq %r14, %rdi
callq 0x1030
xorl %eax, %eax
jmp 0x7b7c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b05(%rip), %rdi      # 0xa697
leaq 0x2b0a(%rip), %rsi      # 0xa6a3
leaq 0x2b11(%rip), %rcx      # 0xa6b1
movl $0xfb, %edx
callq 0x10c0
leaq 0x2b4a(%rip), %rdi      # 0xa6fb
leaq 0x2aeb(%rip), %rsi      # 0xa6a3
leaq 0x2af2(%rip), %rcx      # 0xa6b1
movl $0x10b, %edx            # imm = 0x10B
callq 0x10c0