// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/uniprot.c
// Function: prepareUniprotLists
void prepareUniprotLists(UniprotList * retLists, int passPrimary) {
	UniprotList * globalLists;
	int listIdx, entryIdx, localIdx;
	int maxEntries, totalSize;

	globalLists = getGlobalLists(passPrimary);

	// Calculate maximum number of UniProt entries
	for (maxEntries = 0, listIdx = 0 ; listIdx < *getGlobalCount(passPrimary) ; listIdx++) {
		maxEntries += globalLists[listIdx].entryCount;
	}

	logMessage(__func__, LOG_LEVEL_MESSAGE, "Aggregating %d entries for UniProt report\n", maxEntries);

	// Stop processing if no entries, but ensure a list exists for easier post-processing
	if (maxEntries == 0) {
		if (globalLists == NULL) {
			if (passPrimary) uniprotPriEntryLists = malloc(sizeof(UniprotList));
			else uniprotSecEntryLists = malloc(sizeof(UniprotList));

			globalLists = getGlobalLists(passPrimary);
			globalLists[0].entries = NULL;
			globalLists[0].entryCount = 0;
			globalLists[0].unalignedCount = 0;
			*getGlobalCount(passPrimary) = 1;
		}

		return;
	}

	// Join each pipeline's individual list into one master list (at first list)
	for (listIdx = 0, totalSize = 0 ; listIdx < *getGlobalCount(passPrimary) ; listIdx++) {
		totalSize += globalLists[listIdx].entryCount;
	}

	globalLists[0].entries = realloc(globalLists[0].entries, sizeof(UniprotEntry) * totalSize);

	for (listIdx = 1, entryIdx = globalLists[0].entryCount ; listIdx < *getGlobalCount(passPrimary) ; listIdx++) {
		memcpy(globalLists[0].entries + entryIdx, globalLists[listIdx].entries, sizeof(UniprotEntry) * globalLists[listIdx].entryCount);
		entryIdx += globalLists[listIdx].entryCount;
		free(globalLists[listIdx].entries);
		globalLists[listIdx].entryCount = 0;
	}

	globalLists[0].entryCount = totalSize;

	// Aggregate each local list
	for (localIdx = 0 ; localIdx < 3 ; localIdx++) {
		aggregateUniprotList(retLists + localIdx, localIdx, passPrimary);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %edi
callq 0xbdc0
movq %rax, -0x18(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0xc(%rbp), %edi
callq 0xbdf0
movq %rax, %rcx
movl -0x30(%rbp), %eax
cmpl (%rcx), %eax
jge 0xbf54
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbf19
movl -0x28(%rbp), %ecx
leaq 0x2d7e4(%rip), %rdi     # 0x39742
movl $0x3, %esi
leaq 0x2d7ec(%rip), %rdx     # 0x39756
movb $0x0, %al
callq 0x12510
cmpl $0x0, -0x28(%rbp)
jne 0xbfe8
cmpq $0x0, -0x18(%rbp)
jne 0xbfe3
cmpl $0x0, -0xc(%rbp)
je 0xbf97
movl $0x10, %edi
callq 0x3450
movq %rax, 0x34eb3(%rip)     # 0x40e48
jmp 0xbfa8
movl $0x10, %edi
callq 0x3450
movq %rax, 0x34ea8(%rip)     # 0x40e50
movl -0xc(%rbp), %edi
callq 0xbdc0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0xc(%rax)
movl -0xc(%rbp), %edi
callq 0xbdf0
movl $0x1, (%rax)
jmp 0xc14b
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0xc(%rbp), %edi
callq 0xbdf0
movq %rax, %rcx
movl -0x34(%rbp), %eax
cmpl (%rcx), %eax
jge 0xc031
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xbff6
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movslq -0x2c(%rbp), %rax
imulq $0x28, %rax, %rsi
callq 0x35f0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0xc(%rbp), %edi
callq 0xbdf0
movq %rax, %rcx
movl -0x38(%rbp), %eax
cmpl (%rcx), %eax
jge 0xc10f
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movslq -0x20(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
imulq $0x28, %rax, %rdx
callq 0x3250
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x3380
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc060
movl -0x2c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0x0, -0x24(%rbp)
cmpl $0x3, -0x24(%rbp)
jge 0xc14b
movq -0x8(%rbp), %rdi
movslq -0x24(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movl -0x24(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0xe060
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc120
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)