// File: /workspace/github_c_makefile_star2_O3/ToniWestbrook[P]paladin/protein.c
// Function: writeIndexTestProtein
int writeIndexTestProtein(const char * passPrefix, const char * passProName) {
	CDS currentCDS;
	gzFile  inputSeqPtr;
	FILE * outputPtr;
	char * outputBuffer;
	kseq_t * seq;
	int idx, gcCount;
	unsigned long outputSize, currentLine, frameIdx;

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

	// Iterate through each sequence
	seq = kseq_init(inputSeqPtr);
	currentLine = 0;

	while (kseq_read(seq) > 0) {

		gcCount = 0;
		for (idx = 0 ; idx < seq->seq.l ; idx++) {
			if (seq->seq.s[idx] == 'G' || seq->seq.s[idx] == 'C') gcCount++;
		}

		gcCount = gcCount * 100 / seq->seq.l;

		for (frameIdx = 0 ; frameIdx < 6 ; frameIdx++) {
			currentCDS.startIdx = (frameIdx % 3);
			currentCDS.endIdx = seq->seq.l - 1 - 3 + (frameIdx % 3);
			currentCDS.strand = (frameIdx < 3 ? 1 : -1);
			currentCDS.phase = 0;

			convertToAA(seq->seq.s, &currentCDS, 0, &outputBuffer, &outputSize);

			// Sequence ID : ORF Index per Sequence : Relative Frame per Sequence : Sequence Header
			fprintf(outputPtr, ">%lu:%lu:%d:%s\n%.*s\n", currentLine, frameIdx, gcCount, seq->name.s, (int) outputSize, outputBuffer);
			free(outputBuffer);
		}

		currentLine++;
	}

	// Close files
	fflush(outputPtr);
	err_gzclose(inputSeqPtr);
	err_fclose(outputPtr);
	kseq_destroy(seq);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2048, %rsp           # imm = 0x2048
movq %rsi, %rbx
movq %rdi, %rsi
leaq 0x1d146(%rip), %r14     # 0x271d2
leaq 0x1cdd7(%rip), %rdx     # 0x26e6a
movq %r14, %rdi
callq 0xe1c4
movq %rax, %r15
leaq 0x1f4ba(%rip), %rdx     # 0x2955f
movq %r14, %rdi
movq %rbx, %rsi
callq 0xe023
movq %rax, %r12
movq %r15, 0x10(%rsp)
movq %r15, %rdi
callq 0xd7c8
movq %rax, %r15
movq %rax, %rdi
callq 0xd8a7
testl %eax, %eax
jle 0xa1db
leaq 0x30(%rsp), %rbp
leaq 0x28(%rsp), %r14
xorl %r13d, %r13d
movq %r12, 0x8(%rsp)
movq 0x30(%r15), %rcx
testq %rcx, %rcx
je 0xa113
movq 0x40(%r15), %rax
xorl %edx, %edx
xorl %esi, %esi
movzbl (%rax,%rdx), %edi
orl $0x4, %edi
cmpl $0x47, %edi
jne 0xa104
incl %esi
incq %rdx
cmpq %rdx, %rcx
jne 0xa0f6
imull $0x64, %esi, %eax
cltq
jmp 0xa115
xorl %eax, %eax
xorl %edx, %edx
divq %rcx
movq %rax, 0x18(%rsp)
xorl %eax, %eax
movq %rax, %rbx
subq $0x3, %rbx
cmovaeq %rbx, %rax
movq %rax, 0x30(%rsp)
movq 0x30(%r15), %rcx
leaq -0x4(%rax,%rcx), %rax
movq %rax, 0x38(%rsp)
movl $0x0, %eax
adcw $-0x1, %ax
orl $0x1, %eax
movw %ax, 0x40(%rsp)
movw $0x0, 0x42(%rsp)
movq 0x40(%r15), %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r14, %rcx
leaq 0x20(%rsp), %r8
callq 0x91ea
movq 0x10(%r15), %r9
movl 0x20(%rsp), %r10d
movq %r14, %r12
movq %rbp, %r14
movq 0x28(%rsp), %rbp
leaq 0x3(%rbx), %rcx
movq 0x8(%rsp), %rdi
leaq 0x1d057(%rip), %rsi     # 0x271e8
movq %r13, %rdx
movq 0x18(%rsp), %r8
xorl %eax, %eax
pushq %rbp
pushq %r10
callq 0x3500
addq $0x10, %rsp
movq %rbp, %rdi
movq %r14, %rbp
movq %r12, %r14
callq 0x3390
leaq 0x4(%rbx), %rax
cmpq $0x6, %rax
jne 0xa121
incq %r13
movq %r15, %rdi
callq 0xd8a7
testl %eax, %eax
movq 0x8(%rsp), %r12
jg 0xa0e5
movq %r12, %rdi
callq 0x3370
movq 0x10(%rsp), %rdi
callq 0xe747
movq %r12, %rdi
callq 0xe71e
movq %r15, %rdi
callq 0xd84e
xorl %eax, %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq