// File: BenLangmead[P]bowtie/./bitset.h
// Function: bitsetRealloc(unsigned long&, unsigned long*, char const*)
static inline TIndexOffU*
bitsetRealloc(TIndexOffU& sz, TIndexOffU* words, const char *errmsg = NULL) {
	TIndexOffU oldsz = sz;
	if(sz > 0) {
		sz += (sz >> 1) + BITSET_MASK; // Add 50% more elements, plus a bit
		sz &= ~BITSET_MASK;            // Make sure it's 32-aligned
	} else {
		sz = 1024; // Start off at 1024 bits to avoid many expansions
	}
	assert_gt(sz, oldsz);
	assert_eq(0, (sz & BITSET_MASK));
	TIndexOffU *newwords;
	try {
		newwords = new TIndexOffU[sz / WORD_SIZE /* convert to words */];
	} catch(std::bad_alloc& ba) {
		if(errmsg != NULL) {
			// Output given error message
			std::cerr << errmsg;
		}
		throw 1;
	}
	if(oldsz > 0) {
		// Move old values into new array
		memcpy(newwords, words, oldsz >> 3 /* convert to bytes */);
	}
	// Initialize all new words to 0
	memset(newwords + (oldsz / WORD_SIZE /*convert to words*/), 0,
	       (sz - oldsz) >> 3 /* convert to bytes */);
	return newwords; // return new array
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
jbe 0x12461
movq -0x8(%rbp), %rax
movq (%rax), %rcx
shrq %rcx
addq $0x3f, %rcx
movq -0x8(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rcx
andq $-0x40, %rcx
movq %rcx, (%rax)
jmp 0x1246c
movq -0x8(%rbp), %rax
movq $0x400, (%rax)          # imm = 0x400
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpq -0x20(%rbp), %rax
ja 0x12535
movq 0x37b3c(%rip), %rdi     # 0x49fc0
leaq 0x2cc6d(%rip), %rsi     # 0x3f0f8
callq 0x5360
movq %rax, %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x2cc65(%rip), %rsi     # 0x3f10e
callq 0x5360
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x2f0f4(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x37aad(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x37ae1(%rip), %rdi     # 0x49fc0
leaq 0x2e0fd(%rip), %rsi     # 0x405e3
callq 0x5360
movq %rax, %rdi
leaq 0x2e295(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x1c, %esi
callq 0x5750
movq %rax, %rdi
movq 0x37a6f(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x2e14d(%rip), %rdi     # 0x4066a
leaq 0x2e0bf(%rip), %rsi     # 0x405e3
movl $0x1c, %edx
leaq 0x2e174(%rip), %rcx     # 0x406a4
callq 0x51e0
movq -0x8(%rbp), %rax
movq (%rax), %rcx
andq $0x3f, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x1267c
movq 0x37a6e(%rip), %rdi     # 0x49fc0
leaq 0x2cbc0(%rip), %rsi     # 0x3f119
callq 0x5360
movq %rax, %rdi
xorl %esi, %esi
callq 0x5750
movq %rax, %rdi
leaq 0x2cbbd(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x625f(%rip), %rsi      # 0x187e0
callq 0x5120
movq %rax, %rdi
xorl %esi, %esi
callq 0x5750
movq %rax, %rdi
leaq 0x6276(%rip), %rsi      # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x2cb8b(%rip), %rsi     # 0x3f134
callq 0x5360
movq %rax, %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
andq $0x3f, %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x2cb64(%rip), %rsi     # 0x3f12f
callq 0x5360
movq %rax, %rdi
leaq 0x6206(%rip), %rsi      # 0x187e0
callq 0x5120
movq %rax, %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
andq $0x3f, %rsi
callq 0x50c0
movq %rax, %rdi
leaq 0x6214(%rip), %rsi      # 0x18810
callq 0x5120
movq %rax, %rdi
leaq 0x2efad(%rip), %rsi     # 0x415b8
callq 0x5360
movq %rax, %rdi
movq 0x37966(%rip), %rsi     # 0x49f80
callq 0x53c0
movq 0x3799a(%rip), %rdi     # 0x49fc0
leaq 0x2dfb6(%rip), %rsi     # 0x405e3
callq 0x5360
movq %rax, %rdi
leaq 0x2e14e(%rip), %rsi     # 0x4078a
callq 0x5360
movq %rax, %rdi
movl $0x1d, %esi
callq 0x5750
movq %rax, %rdi
movq 0x37928(%rip), %rsi     # 0x49f80
callq 0x53c0
leaq 0x2e006(%rip), %rdi     # 0x4066a
leaq 0x2df78(%rip), %rsi     # 0x405e3
movl $0x1d, %edx
leaq 0x2e02d(%rip), %rcx     # 0x406a4
callq 0x51e0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
shrq $0x3, %rdi
andq $-0x8, %rdi
callq 0x5030
movq %rax, -0x48(%rbp)
jmp 0x12696
movq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x1271e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1276d
movq -0x30(%rbp), %rdi
callq 0x5140
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x126f7
movq -0x18(%rbp), %rsi
movq 0x37915(%rip), %rdi     # 0x49ff0
callq 0x5360
jmp 0x126e2
jmp 0x126f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x56a0
jmp 0x1271c
movl $0x4, %edi
callq 0x5180
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x3785f(%rip), %rsi     # 0x49f70
xorl %eax, %eax
movl %eax, %edx
callq 0x5720
jmp 0x1277e
jmp 0x1276d
cmpq $0x0, -0x20(%rbp)
jbe 0x1273a
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
shrq $0x3, %rdx
callq 0x5290
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
shrq $0x6, %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
subq -0x20(%rbp), %rdx
shrq $0x3, %rdx
xorl %esi, %esi
callq 0x5190
movq -0x28(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x5760
movq %rax, %rdi
callq 0x18920
nop