// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/protein.c
// Function: writeIndexProtein
int writeIndexProtein(const char * passPrefix, const char * passProName, const char * passAnnName, IndexHeader passHeader) {
	CDS currentCDS;
	gzFile inputSeqPtr;
	FILE * inputAnnPtr, * outputPtr;
	char * outputBuffer;
	kseq_t * seq;
	unsigned long outputSize, currentLine, frameIdx;

	// Prepare file handles
	inputSeqPtr = xzopen(passPrefix, "r");
	inputAnnPtr = err_xopen_core(__func__, passAnnName, "r");
	outputPtr = err_xopen_core(__func__, passProName, "w");

	// Write index type header
	passHeader.nucleotide = 1;
	writeIndexHeader(outputPtr, passHeader);

	// Read in 1st sequence data
	seq = kseq_init(inputSeqPtr);
	kseq_read(seq);

	// Iterate through each CDS sequence in the annotation file
	currentLine = 0;
	while (getNextCDS(inputAnnPtr, &currentCDS, &currentLine)) {
		for (frameIdx = 0 ; frameIdx < 6 ; frameIdx++) {
			convertToAA(seq->seq.s, &currentCDS, 0, &outputBuffer, &outputSize);

			// Line ID of CDS : Frame : Sequence Header
			fprintf(outputPtr, ">%lu:%lu:%s\n%.*s\n", currentLine, frameIdx, currentCDS.description, (int) outputSize, outputBuffer);
			free(outputBuffer);

			currentCDS.startIdx++;
			currentCDS.endIdx++;
			if (frameIdx == 2) currentCDS.strand *= -1;

			if (!passHeader.multiFrame) break;
		}
	}

	// Close files
	fflush(outputPtr);
	err_gzclose(inputSeqPtr);
	err_fclose(inputAnnPtr);
	err_fclose(outputPtr);
	kseq_destroy(seq);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2090, %rsp           # imm = 0x2090
leaq 0x10(%rbp), %rax
movq %rax, -0x2078(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x2ddef(%rip), %rdi     # 0x38ffc
leaq 0x2daee(%rip), %rdx     # 0x38d02
callq 0x12990
movq %rax, -0x2038(%rbp)
movq -0x18(%rbp), %rsi
leaq 0x2ddd1(%rip), %rdi     # 0x38ffc
leaq 0x2dad0(%rip), %rdx     # 0x38d02
callq 0x12740
movq %rax, -0x2040(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x2ddb3(%rip), %rdi     # 0x38ffc
leaq 0x300c8(%rip), %rdx     # 0x3b318
callq 0x12740
movq %rax, %rcx
movq -0x2078(%rbp), %rax
movq %rcx, -0x2048(%rbp)
movl $0x1, (%rax)
movq -0x2048(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x4bf0
movq -0x2038(%rbp), %rdi
callq 0x11a10
movq %rax, -0x2058(%rbp)
movq -0x2058(%rbp), %rdi
callq 0x11b70
movq $0x0, -0x2068(%rbp)
movq -0x2040(%rbp), %rdi
leaq -0x2030(%rbp), %rsi
leaq -0x2068(%rbp), %rdx
callq 0xaf90
cmpl $0x0, %eax
je 0xb3d9
movq $0x0, -0x2070(%rbp)
cmpq $0x6, -0x2070(%rbp)
jae 0xb3d4
movq -0x2058(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x2030(%rbp), %rsi
xorl %edx, %edx
leaq -0x2050(%rbp), %rcx
leaq -0x2060(%rbp), %r8
callq 0xa4f0
movq -0x2048(%rbp), %rdi
movq -0x2068(%rbp), %rdx
movq -0x2070(%rbp), %rcx
leaq -0x2030(%rbp), %r8
addq $0x16, %r8
movq -0x2060(%rbp), %rax
movl %eax, %r9d
movq -0x2050(%rbp), %rax
leaq 0x2dcb8(%rip), %rsi     # 0x3900e
movq %rax, (%rsp)
movb $0x0, %al
callq 0x34e0
movq -0x2050(%rbp), %rdi
callq 0x3380
movq -0x2030(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2030(%rbp)
movq -0x2028(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2028(%rbp)
cmpq $0x2, -0x2070(%rbp)
jne 0xb3ac
movswl -0x2020(%rbp), %eax
imull $-0x1, %eax, %eax
movw %ax, -0x2020(%rbp)
movq -0x2078(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0xb3bb
jmp 0xb3d4
jmp 0xb3bd
movq -0x2070(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2070(%rbp)
jmp 0xb2e9
jmp 0xb2bb
movq -0x2048(%rbp), %rdi
callq 0x3360
movq -0x2038(%rbp), %rdi
callq 0x13200
movq -0x2040(%rbp), %rdi
callq 0x131b0
movq -0x2048(%rbp), %rdi
callq 0x131b0
movq -0x2058(%rbp), %rdi
callq 0x11ad0
xorl %eax, %eax
addq $0x2090, %rsp           # imm = 0x2090
popq %rbp
retq