// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x1440, %rsp           # imm = 0x1440
movq %rdi, -0x10(%rbp)
leaq -0x410(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x32b0
movq %rax, %rdi
leaq 0x22a7c(%rip), %rsi     # 0x39365
callq 0x3690
leaq -0x810(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x32b0
movq %rax, %rdi
leaq 0x2381f(%rip), %rsi     # 0x3a127
callq 0x3690
leaq -0xc10(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x32b0
movq %rax, %rdi
leaq 0x20add(%rip), %rsi     # 0x37404
callq 0x3690
leaq -0x410(%rbp), %rdi
leaq -0x810(%rbp), %rsi
leaq -0xc10(%rbp), %rdx
callq 0x16280
movq %rax, -0x1020(%rbp)
cmpq $0x0, -0x1020(%rbp)
jne 0x16964
movq $0x0, -0x8(%rbp)
jmp 0x16b7e
leaq -0x1010(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x32b0
movq %rax, %rdi
leaq 0x2384d(%rip), %rsi     # 0x3a1cb
callq 0x3690
movq %rax, %rdi
leaq 0x22375(%rip), %rsi     # 0x38d02
callq 0x3370
movq %rax, -0x1018(%rbp)
cmpq $0x0, %rax
je 0x16b73
callq 0x16b90
movq %rax, -0x1428(%rbp)
movl $0x0, -0x1430(%rbp)
movl -0x1430(%rbp), %eax
movq -0x1020(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x16a2c
movq -0x1428(%rbp), %rdi
movq -0x1020(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x1430(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
leaq -0x1434(%rbp), %rdx
callq 0x16bc0
movl %eax, -0x1438(%rbp)
movl -0x1430(%rbp), %edx
movq -0x1428(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x1438(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x1430(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1430(%rbp)
jmp 0x169b9
movl $0x0, -0x1430(%rbp)
movq -0x1018(%rbp), %rdi
callq 0x35a0
movl %eax, -0x142c(%rbp)
cmpl $-0x1, %eax
je 0x16b5b
cmpl $0x9, -0x142c(%rbp)
je 0x16a70
cmpl $0xa, -0x142c(%rbp)
je 0x16a70
cmpl $0xd, -0x142c(%rbp)
jne 0x16b34
movslq -0x1430(%rbp), %rax
movb $0x0, -0x1420(%rbp,%rax)
movsbl -0x1420(%rbp), %eax
cmpl $0x40, %eax
je 0x16ae5
movq -0x1428(%rbp), %rdi
leaq -0x1420(%rbp), %rsi
callq 0x16f30
movl %eax, -0x1438(%rbp)
movl -0x1438(%rbp), %eax
movq -0x1428(%rbp), %rcx
cmpl (%rcx), %eax
je 0x16ae3
movq -0x1020(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x1428(%rbp), %rcx
movq 0x20(%rcx), %rcx
movl -0x1438(%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0x14(%rax)
jmp 0x16ae5
jmp 0x16ae7
xorl %eax, %eax
cmpl $0xa, -0x142c(%rbp)
movb %al, -0x1439(%rbp)
je 0x16b08
cmpl $-0x1, -0x142c(%rbp)
setne %al
movb %al, -0x1439(%rbp)
movb -0x1439(%rbp), %al
testb $0x1, %al
jne 0x16b14
jmp 0x16b28
movq -0x1018(%rbp), %rdi
callq 0x35a0
movl %eax, -0x142c(%rbp)
jmp 0x16ae7
movl $0x0, -0x1430(%rbp)
jmp 0x16b56
movl -0x142c(%rbp), %eax
movb %al, %cl
movl -0x1430(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x1430(%rbp)
cltq
movb %cl, -0x1420(%rbp,%rax)
jmp 0x16a36
movq -0x1428(%rbp), %rdi
callq 0x17090
movq -0x1018(%rbp), %rdi
callq 0x32e0
movq -0x1020(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1440, %rsp           # imm = 0x1440
popq %rbp
retq
nopl (%rax,%rax)