// File: /workspace/github_c_makefile_star2_O2/ToniWestbrook[P]paladin/bntseq.c
// Function: bns_restore
bntseq_t *bns_restore(const char *prefix)
{  
	char ann_filename[1024], amb_filename[1024], pac_filename[1024], alt_filename[1024];
	FILE *fp;
	bntseq_t *bns;
	strcat(strcpy(ann_filename, prefix), ".ann");
	strcat(strcpy(amb_filename, prefix), ".amb");
	strcat(strcpy(pac_filename, prefix), ".pac");
	bns = bns_restore_core(ann_filename, amb_filename, pac_filename);
	if (bns == 0) return 0;
	if ((fp = fopen(strcat(strcpy(alt_filename, prefix), ".alt"), "r")) != 0) { // read .alt file if present
		char str[1024];
		khash_t(str) *h;
		int c, i, absent;
		khint_t k;
		h = kh_init(str);
		for (i = 0; i < bns->n_seqs; ++i) {
			k = kh_put(str, h, bns->anns[i].name, &absent);
			kh_val(h, k) = i;
		}
		i = 0;
		while ((c = fgetc(fp)) != EOF) {
			if (c == '\t' || c == '\n' || c == '\r') {
				str[i] = 0;
				if (str[0] != '@') {
					k = kh_get(str, h, str);
					if (k != kh_end(h))
						bns->anns[kh_val(h, k)].is_alt = 1;
				}
				while (c != '\n' && c != EOF) c = fgetc(fp);
				i = 0;
			} else str[i++] = c; // FIXME: potential segfault here
		}
		kh_destroy(str, h);
		fclose(fp);
	}
	return bns;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1448, %rsp           # imm = 0x1448
movq %rdi, %r14
leaq 0x1040(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3100
xorl %ebp, %ebp
movb %bpl, 0x1044(%rsp,%rax)
movl $0x6e6e612e, 0x1040(%rsp,%rax) # imm = 0x6E6E612E
leaq 0xc40(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x32c0
movq %r15, %rdi
callq 0x3100
movb %bpl, 0xc44(%rsp,%rax)
movl $0x626d612e, 0xc40(%rsp,%rax) # imm = 0x626D612E
leaq 0x840(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x32c0
movq %r12, %rdi
callq 0x3100
movb %bpl, 0x844(%rsp,%rax)
movl $0x6361702e, 0x840(%rsp,%rax) # imm = 0x6361702E
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xeaee
movq %rax, %r15
testq %rax, %rax
je 0xf330
leaq 0x440(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3100
movl $0x746c612e, 0x440(%rsp,%rax) # imm = 0x746C612E
movb $0x0, 0x444(%rsp,%rax)
leaq 0x12e82(%rip), %rsi     # 0x21e1e
movq %rbx, %rdi
callq 0x3380
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0xf330
leaq 0x142c7(%rip), %rdx     # 0x23280
leaq 0x144ee(%rip), %r8      # 0x234ae
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
pushq $0xf
popq %rcx
callq 0x1dfd0
movq %rax, %r14
xorl %r13d, %r13d
movq %r15, 0x18(%rsp)
movq %rax, (%rsp)
movslq 0x8(%r15), %rax
cmpq %rax, %r13
jge 0xf1b2
movq 0x10(%r15), %rax
imulq $0x28, %r13, %rcx
movq 0x18(%rax,%rcx), %rax
movq %rax, 0x10(%rsp)
movl 0x8(%r14), %eax
cmpl 0xc(%r14), %eax
jb 0xf029
movl (%r14), %esi
movl 0x4(%r14), %eax
addl %eax, %eax
cmpl %eax, %esi
jbe 0xf017
decl %esi
jmp 0xf019
incl %esi
movq %r14, %rdi
callq 0xfd6a
testl %eax, %eax
js 0xf0fd
movl (%r14), %ebx
leal -0x1(%rbx), %ebp
movq 0x10(%rsp), %rdi
callq 0x10030
movl %eax, %esi
movl %eax, %edi
andl %ebp, %edi
movq 0x10(%r14), %r12
movl %edi, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %eax
leal (%rdi,%rdi), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0xf05c
movl %edi, %ebx
jmp 0xf133
movq %r13, 0x30(%rsp)
movl %esi, %eax
shrl $0x3, %eax
shll $0x3, %esi
xorl %eax, %esi
orl $0x1, %esi
andl %ebp, %esi
movl %edi, %r15d
movq %rbx, 0x38(%rsp)
movl %ebp, 0xc(%rsp)
movq %rdi, 0x20(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %r14d
leal (%r15,%r15), %r13d
andl $0x1e, %r13d
movl %r14d, %eax
movl %r13d, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0xf105
testb $0x1, %al
jne 0xf0cd
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movl %esi, %ebp
movq 0x10(%rsp), %rsi
callq 0x34d0
movl %ebp, %esi
movq 0x20(%rsp), %rdi
movl 0xc(%rsp), %ebp
testl %eax, %eax
je 0xf105
btl %r13d, %r14d
cmovbl %r15d, %ebx
addl %esi, %r15d
andl %ebp, %r15d
cmpl %edi, %r15d
jne 0xf081
movb $0x1, %al
movq 0x38(%rsp), %rsi
movl %esi, %ecx
cmpl %esi, %ebx
movq 0x18(%rsp), %r15
movq (%rsp), %r14
movq 0x30(%rsp), %r13
je 0xf125
jmp 0xf133
movl (%r14), %ebx
jmp 0xf1a0
movl %r13d, %ecx
shrl %cl, %r14d
testb $0x2, %r14b
sete %al
movl %ebx, %ecx
movl %r15d, %edi
movq 0x18(%rsp), %r15
movq (%rsp), %r14
movq 0x30(%rsp), %r13
cmpl 0x38(%rsp), %ecx
cmovel %edi, %ecx
testb %al, %al
cmovnel %edi, %ecx
movl %ecx, %ebx
movl %ebx, %eax
shrl $0x4, %eax
movl (%r12,%rax,4), %edx
leal (%rbx,%rbx), %ecx
andl $0x1e, %ecx
shrl %cl, %edx
movl %ebx, %esi
testb $0x2, %dl
jne 0xf171
testb $0x1, %dl
je 0xf1a0
movq 0x18(%r14), %rdx
movq 0x10(%rsp), %rdi
movq %rdi, (%rdx,%rsi,8)
pushq $0x3
popq %rdx
shll %cl, %edx
notl %edx
movq 0x10(%r14), %rcx
andl %edx, (%rcx,%rax,4)
incl 0x4(%r14)
jmp 0xf1a0
movq 0x18(%r14), %rdx
movq 0x10(%rsp), %rdi
movq %rdi, (%rdx,%rsi,8)
pushq $0x3
popq %rdx
shll %cl, %edx
notl %edx
movq 0x10(%r14), %rcx
andl %edx, (%rcx,%rax,4)
movq 0x4(%r14), %xmm0
psubd 0x12f46(%rip), %xmm0    # 0x220e0
movq %xmm0, 0x4(%r14)
movq 0x20(%r14), %rax
movl %ebx, %ecx
movl %r13d, (%rax,%rcx,4)
incq %r13
jmp 0xefdd
xorl %ebx, %ebx
movq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x35c0
movl %eax, %r13d
leal -0x9(%r13), %ecx
movslq %ebx, %rax
cmpl $0x2, %ecx
jb 0xf1ea
cmpl $0xd, %r13d
je 0xf1ea
cmpl $-0x1, %r13d
je 0xf2f5
leal 0x1(%rax), %ebx
movb %r13b, 0x40(%rsp,%rax)
jmp 0xf1b9
movb $0x0, 0x40(%rsp,%rax)
cmpb $0x40, 0x40(%rsp)
je 0xf2d0
movq (%rsp), %rbx
movl (%rbx), %eax
testl %eax, %eax
je 0xf2a4
movq %rax, 0x20(%rsp)
leal -0x1(%rax), %r15d
leaq 0x40(%rsp), %rdi
callq 0x10030
movl %eax, %edi
movl %eax, %ebp
andl %r15d, %ebp
shrl $0x3, %eax
shll $0x3, %edi
xorl %eax, %edi
orl $0x1, %edi
movl %r15d, 0x10(%rsp)
andl %r15d, %edi
movq 0x10(%rbx), %r14
movl %ebp, %r12d
movl %edi, 0xc(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%r14,%rax,4), %r15d
leal (%r12,%r12), %ebx
andl $0x1e, %ebx
movl %r15d, %eax
movl %ebx, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0xf290
testb $0x1, %al
jne 0xf281
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x40(%rsp), %rsi
callq 0x34d0
movl 0xc(%rsp), %edi
testl %eax, %eax
je 0xf290
addl %edi, %r12d
andl 0x10(%rsp), %r12d
cmpl %ebp, %r12d
jne 0xf240
jmp 0xf2d0
movl %ebx, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x20(%rsp), %rax
cmovnel %eax, %r12d
jmp 0xf2a7
xorl %r12d, %r12d
cmpl %eax, %r12d
je 0xf2d0
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq (%rsp), %rcx
movq 0x20(%rcx), %rcx
movl %r12d, %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
movl $0x1, 0x14(%rax,%rcx)
movq 0x28(%rsp), %r14
cmpl $-0x1, %r13d
je 0xf2ee
cmpl $0xa, %r13d
je 0xf2ee
movq %r14, %rdi
callq 0x35c0
movl %eax, %r13d
jmp 0xf2d5
xorl %ebx, %ebx
jmp 0xf1b9
movq (%rsp), %rbx
testq %rbx, %rbx
movq 0x18(%rsp), %r15
je 0xf326
movq 0x18(%rbx), %rdi
callq 0x3390
movq 0x10(%rbx), %rdi
callq 0x3390
movq 0x20(%rbx), %rdi
callq 0x3390
movq %rbx, %rdi
callq 0x3390
movq 0x28(%rsp), %rdi
callq 0x32f0
movq %r15, %rax
addq $0x1448, %rsp           # imm = 0x1448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq