// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwa.c
// Function: index_load_from_disk
bwaidx_t *index_load_from_disk(const char *hint, int which)
{
	bwaidx_t *idx;
	char *prefix, * proName;

	prefix = index_infer_prefix(hint);

	if (prefix == 0) {
		logMessage(__func__, LOG_LEVEL_ERROR, "Failed to locate the index files\n");
		return 0;
	}

	proName = malloc(strlen(prefix) + 5);
	sprintf(proName, "%s.pro", prefix);

	idx = calloc(1, sizeof(bwaidx_t));
	if (which & BWA_IDX_BWT) idx->bwt = index_load_bwt(hint);
	if (which & BWA_IDX_BNS) {
		int i, c;
		idx->bns = bns_restore(hint);
		for (i = c = 0; i < idx->bns->n_seqs; ++i)
			if (idx->bns->anns[i].is_alt) ++c;

		logMessage(__func__, LOG_LEVEL_MESSAGE, "Read %d ALT contigs\n", c);

		if (which & BWA_IDX_PAC) {
			idx->pac = calloc(idx->bns->l_pac+1, 1);
			err_fread_noeof(idx->pac, 1, idx->bns->l_pac+1, idx->bns->fp_pac); // concatenated 2-bit encoded sequence
			err_fclose(idx->bns->fp_pac);
			idx->bns->fp_pac = 0;
		}
	}
	free(prefix);
	free(proName);
	return idx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x19c50
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x19e4a
leaq 0x20673(%rip), %rdi     # 0x3a49d
movl $0x1, %esi
leaq 0x20645(%rip), %rdx     # 0x3a47b
movb $0x0, %al
callq 0x12510
movq $0x0, -0x8(%rbp)
jmp 0x1a011
movq -0x28(%rbp), %rdi
callq 0x30f0
movq %rax, %rdi
addq $0x5, %rdi
leaq 0x20564(%rip), %rsi     # 0x3a3c5
movl $0x10c, %edx            # imm = 0x10C
leaq 0x20630(%rip), %rcx     # 0x3a49d
callq 0x31ca0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x1d576(%rip), %rsi     # 0x373fb
movb $0x0, %al
callq 0x3070
movl $0x1, %edi
movl $0x30, %esi
leaq 0x20528(%rip), %rdx     # 0x3a3c5
movl $0x10f, %ecx            # imm = 0x10F
leaq 0x205f4(%rip), %r8      # 0x3a49d
callq 0x31bf0
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x19ed0
movq -0x10(%rbp), %rdi
callq 0x19d10
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x19ff7
movq -0x10(%rbp), %rdi
callq 0x168c0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x19f44
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x14(%rax)
je 0x19f37
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x19f39
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x19f01
movl -0x38(%rbp), %ecx
leaq 0x2054f(%rip), %rdi     # 0x3a49d
movl $0x3, %esi
leaq 0x20558(%rip), %rdx     # 0x3a4b2
movb $0x0, %al
callq 0x12510
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x19ff5
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
addq $0x1, %rdi
movl $0x1, %esi
leaq 0x2043a(%rip), %rdx     # 0x3a3c5
movl $0x11a, %ecx            # imm = 0x11A
leaq 0x20506(%rip), %r8      # 0x3a49d
callq 0x31bf0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rcx
movl $0x1, %esi
callq 0x12c70
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x28(%rax), %rdi
callq 0x131b0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq $0x0, 0x28(%rax)
jmp 0x19ff7
movq -0x28(%rbp), %rdi
callq 0x3380
movq -0x30(%rbp), %rdi
callq 0x3380
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)