// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x9780
movq -0x28(%rbp), %rdi
leaq 0x5e00(%rip), %rsi      # 0xf55d
callq 0x10f0
cmpl $0x0, %eax
je 0x9780
movq -0x28(%rbp), %rdi
leaq 0x58be(%rip), %rsi      # 0xf030
callq 0x1190
movq %rax, -0x88(%rbp)
jmp 0x97a4
movq 0x9841(%rip), %rax      # 0x12fc8
movq (%rax), %rdi
callq 0x1140
movl %eax, %edi
leaq 0x5898(%rip), %rsi      # 0xf030
callq 0x1070
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x97c2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9bac
movq -0x30(%rbp), %rdi
callq 0x9bc0
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
movl $0xc, %esi
callq 0x10e0
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x9959
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x44(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x50(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl $0x1, %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x10e0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x50(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
movl $0x4e, %esi
callq 0x10c0
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x9949
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x48(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x21, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x98a5
jmp 0x98c4
leaq 0x5da7(%rip), %rdi      # 0xf653
leaq 0x5dac(%rip), %rsi      # 0xf65f
movl $0xfb, %edx
leaq 0x5dae(%rip), %rcx      # 0xf66d
callq 0x10b0
movl -0x44(%rbp), %edx
movq -0x60(%rbp), %rax
movl (%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x48(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
andq $0x1, %rax
movl %eax, %edx
movq -0x60(%rbp), %rax
movl (%rax), %ecx
andl $0x1, %edx
shll $0x1f, %edx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl %edx, %ecx
movl %ecx, (%rax)
movl -0x54(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x48(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x60(%rbp), %rax
movl 0x8(%rax), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x9867
jmp 0x994b
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x97ec
jmp 0x995b
movq -0x38(%rbp), %rdi
callq 0x9c00
cmpl $0x0, %eax
jl 0x9b8a
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x1a60
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jl 0x999c
movq -0x40(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
jne 0x999e
jmp 0x995b
movq -0x40(%rbp), %rax
movslq -0x64(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rcx
movl (%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x9aa1
movq -0x20(%rbp), %rax
movslq -0x64(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movq -0x20(%rbp), %rcx
movslq -0x64(%rbp), %rdx
movl (%rcx,%rdx,8), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
subl %ecx, %eax
movl %eax, %eax
movq -0x38(%rbp), %rcx
cmpq 0x30(%rcx), %rax
ja 0x9a0a
jmp 0x9a29
leaq 0x5ca6(%rip), %rdi      # 0xf6b7
leaq 0x5c47(%rip), %rsi      # 0xf65f
movl $0x10b, %edx            # imm = 0x10B
leaq 0x5c49(%rip), %rcx      # 0xf66d
callq 0x10b0
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x20(%rbp), %rax
movslq -0x64(%rbp), %rcx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cltq
addq %rax, %rsi
movq -0x20(%rbp), %rax
movslq -0x64(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movq -0x20(%rbp), %rcx
movslq -0x64(%rbp), %rdx
movl (%rcx,%rdx,8), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
subl %ecx, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1180
movq -0x20(%rbp), %rax
movslq -0x64(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movq -0x20(%rbp), %rcx
movslq -0x64(%rbp), %rdx
movl (%rcx,%rdx,8), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
subl %ecx, %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x70(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x9af7
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x70(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x9af2
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x44(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x70(%rbp), %rcx
movl 0x4(%rcx), %ecx
addl -0x44(%rbp), %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x9ab6
jmp 0x9b85
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x70(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x9b83
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x30(%rcx), %rcx
subq $0x1, %rcx
movl -0x44(%rbp), %edx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x7c(%rbp)
cmpl $0x80, -0x7c(%rbp)
jl 0x9b41
movl $0x4e, %eax
movl %eax, -0x8c(%rbp)
jmp 0x9b56
movslq -0x7c(%rbp), %rcx
leaq 0x95f4(%rip), %rax      # 0x13140
movsbl (%rax,%rcx), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movb %al, %dl
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x70(%rbp), %rcx
movl 0x4(%rcx), %ecx
addl -0x44(%rbp), %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x9afe
jmp 0x9b85
jmp 0x995b
movq -0x40(%rbp), %rdi
callq 0x1040
movq -0x38(%rbp), %rdi
callq 0x9fe0
movq -0x30(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)