// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwa.c
// Function: bwa_idx2mem
int bwa_idx2mem(bwaidx_t *idx)
{
	int i;
	int64_t k, x, tmp;
	uint8_t *mem;

	// copy idx->bwt
	x = idx->bwt->bwt_size * 4;
	mem = realloc(idx->bwt->bwt, sizeof(bwt_t) + x); idx->bwt->bwt = 0;
	memmove(mem + sizeof(bwt_t), mem, x);
	memcpy(mem, idx->bwt, sizeof(bwt_t)); k = sizeof(bwt_t) + x;
	x = idx->bwt->n_sa * sizeof(bwtint_t); mem = realloc(mem, k + x); memcpy(mem + k, idx->bwt->sa, x); k += x;
	free(idx->bwt->sa);
	free(idx->bwt); idx->bwt = 0;

	// copy idx->bns
	tmp = idx->bns->n_seqs * sizeof(bntann1_t) + idx->bns->n_holes * sizeof(bntamb1_t);
	for (i = 0; i < idx->bns->n_seqs; ++i) // compute the size of heap-allocated memory
		tmp += strlen(idx->bns->anns[i].name) + strlen(idx->bns->anns[i].anno) + 2;
	mem = realloc(mem, k + sizeof(bntseq_t) + tmp);
	x = sizeof(bntseq_t); memcpy(mem + k, idx->bns, x); k += x;
	x = idx->bns->n_holes * sizeof(bntamb1_t); memcpy(mem + k, idx->bns->ambs, x); k += x;
	free(idx->bns->ambs);
	x = idx->bns->n_seqs * sizeof(bntann1_t); memcpy(mem + k, idx->bns->anns, x); k += x;
	for (i = 0; i < idx->bns->n_seqs; ++i) {
		x = strlen(idx->bns->anns[i].name) + 1; memcpy(mem + k, idx->bns->anns[i].name, x); k += x;
		x = strlen(idx->bns->anns[i].anno) + 1; memcpy(mem + k, idx->bns->anns[i].anno, x); k += x;
		free(idx->bns->anns[i].name); free(idx->bns->anns[i].anno);
	}
	free(idx->bns->anns);

	// copy idx->pac
	//x = idx->bns->l_pac/4+1;
	x = idx->bns->l_pac+1;
	mem = realloc(mem, k + x);
	memcpy(mem + k, idx->pac, x); k += x;
	free(idx->bns); idx->bns = 0;
	free(idx->pac); idx->pac = 0;

	return bwa_mem2idx(k, mem, idx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x118(%rax), %rax
shlq $0x2, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x120(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x140, %rsi            # imm = 0x140
leaq 0x1ff63(%rip), %rdx     # 0x3a3c5
movl $0x15a, %ecx            # imm = 0x15A
leaq 0x200a0(%rip), %r8      # 0x3a50e
callq 0x31d40
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq $0x0, 0x120(%rax)
movq -0x30(%rbp), %rdi
addq $0x140, %rdi            # imm = 0x140
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x35e0
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movl $0x140, %edx            # imm = 0x140
callq 0x3250
movq -0x20(%rbp), %rax
addq $0x140, %rax            # imm = 0x140
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x130(%rax), %rax
shlq $0x3, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq -0x20(%rbp), %rsi
leaq 0x1fed8(%rip), %rdx     # 0x3a3c5
movl $0x15d, %ecx            # imm = 0x15D
leaq 0x20015(%rip), %r8      # 0x3a50e
callq 0x31d40
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x138(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x3250
movq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x138(%rax), %rdi
callq 0x3380
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x3380
movq -0x8(%rbp), %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
imulq $0x28, %rax, %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
movslq 0x18(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x1a5fa
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
callq 0x30f0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rdi
callq 0x30f0
movq %rax, %rcx
movq -0x38(%rbp), %rax
addq %rcx, %rax
addq $0x2, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1a585
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x30, %rsi
addq -0x28(%rbp), %rsi
leaq 0x1fdb4(%rip), %rdx     # 0x3a3c5
movl $0x165, %ecx            # imm = 0x165
leaq 0x1fef1(%rip), %r8      # 0x3a50e
callq 0x31d40
movq %rax, -0x30(%rbp)
movq $0x30, -0x20(%rbp)
movq -0x30(%rbp), %rdi
addq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x3250
movq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq 0x18(%rax), %rax
shlq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
addq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x3250
movq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rdi
callq 0x3380
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq 0x8(%rax), %rax
imulq $0x28, %rax, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
addq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x3250
movq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x1a807
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
callq 0x30f0
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
addq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x3250
movq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rdi
callq 0x30f0
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
addq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x3250
movq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
callq 0x3380
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rdi
callq 0x3380
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1a6e5
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rdi
callq 0x3380
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq -0x20(%rbp), %rsi
leaq 0x1fb87(%rip), %rdx     # 0x3a3c5
movl $0x174, %ecx            # imm = 0x174
leaq 0x1fcc4(%rip), %r8      # 0x3a50e
callq 0x31d40
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x3250
movq -0x20(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3380
movq -0x8(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3380
movq -0x8(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x8(%rbp), %rdx
callq 0x1a110
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)