// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/uniprot.c
// Function: joinOnlineLists
void joinOnlineLists(UniprotList * retList, char * passUniprotOutput) {
	char * * lineIndices;
	int parseIdx, entryIdx, lineIdx;
	int lineCount, outputSize, matchValue;

	// Count number of lines in output
	outputSize = strlen(passUniprotOutput);

	for (lineCount = 0, parseIdx = 0 ; parseIdx < outputSize ; parseIdx++) {
		if (passUniprotOutput[parseIdx] == '\n') lineCount++;
	}
	if (passUniprotOutput[parseIdx - 1] != '\n') lineCount++;

	// Index each line
	lineIndices = malloc(lineCount * sizeof(char *));
	lineIndices[0] = passUniprotOutput;

	for (lineIdx = 1, parseIdx = 0 ; parseIdx < outputSize ; parseIdx++) {
		// If EOL found, change to NULL and check for next valid line
		if (passUniprotOutput[parseIdx] == '\n') {
			passUniprotOutput[parseIdx] = 0;
			if (parseIdx < outputSize - 1) {
				lineIndices[lineIdx++] = passUniprotOutput + parseIdx + 1;
			}
		}
	}

	// Sort (hopefully temporarily)
	qsort(lineIndices, lineCount, sizeof(char *), uniprotEntryCompareOnline);

	// Now cross reference/join - both are ordered, so skip in lexicographical order if match not found
	for (entryIdx = 0, lineIdx = 1 ; (entryIdx < retList->entryCount) && (lineIdx < lineCount)  ; ) {
		matchValue = strncmp(retList->entries[entryIdx].id, lineIndices[lineIdx], strlen(retList->entries[entryIdx].id));

		if (matchValue == 0) {
			// Do not free existing string - global list handles this during cleanup
			retList->entries[entryIdx++].id = lineIndices[lineIdx++];
		}
		else if (matchValue > 0) lineIdx++;
		else entryIdx++; 
	}

	free(lineIndices);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x30f0
movl %eax, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xc6a9
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0xc69c
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xc69e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc67a
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0xc6c8
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movslq -0x28(%rbp), %rdi
shlq $0x3, %rdi
callq 0x3450
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x24(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xc758
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0xc74b
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x1c(%rbp), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0xc749
movq -0x10(%rbp), %rdx
movslq -0x1c(%rbp), %rax
addq %rax, %rdx
addq $0x1, %rdx
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xc74b
jmp 0xc74d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc6f2
movq -0x18(%rbp), %rdi
movslq -0x28(%rbp), %rsi
movl $0x8, %edx
leaq 0x1b94(%rip), %rcx      # 0xe300
callq 0x3740
movl $0x0, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl 0x8(%rdx), %ecx
movb %al, -0x31(%rbp)
jge 0xc79c
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
setl %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0xc7a8
jmp 0xc85c
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x30f0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %rax, %rdx
callq 0x3110
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0xc83b
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl -0x20(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movslq %edx, %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
jmp 0xc857
cmpl $0x0, -0x30(%rbp)
jle 0xc84c
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc855
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xc857
jmp 0xc77f
movq -0x18(%rbp), %rdi
callq 0x3380
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)