// File: /workspace/github_c_makefile_star2_O1/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 0x1d2f5(%rip), %r14     # 0x27167
leaq 0x1cfa5(%rip), %rdx     # 0x26e1e
movq %r14, %rdi
callq 0xdf35
movq %rax, %r15
leaq 0x1f5a4(%rip), %rdx     # 0x2942f
movq %r14, %rdi
movq %rbx, %rsi
callq 0xdd8e
movq %rax, %r12
movq %r15, 0x10(%rsp)
movq %r15, %rdi
callq 0xd53f
movq %rax, %r15
movq %rax, %rdi
callq 0xd61e
testl %eax, %eax
jle 0x9fd3
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
leaq 0x30(%rsp), %r14
xorl %r13d, %r13d
movq %r12, 0x8(%rsp)
movq 0x30(%r15), %rcx
testq %rcx, %rcx
je 0x9efe
movq 0x40(%r15), %rax
xorl %edx, %edx
xorl %esi, %esi
movzbl (%rax,%rdx), %edi
orl $0x4, %edi
cmpl $0x47, %edi
jne 0x9eef
incl %esi
incq %rdx
cmpq %rdx, %rcx
jne 0x9ee1
imull $0x64, %esi, %eax
cltq
jmp 0x9f00
xorl %eax, %eax
xorl %edx, %edx
divq %rcx
movq %rax, 0x18(%rsp)
xorl %ebp, %ebp
movq %rbp, %rax
mulq %rbx
shrq %rdx
leaq (%rdx,%rdx,2), %rax
movq %rbp, %rcx
subq %rax, %rcx
movq %rcx, 0x30(%rsp)
movq 0x30(%r15), %rax
addq %rcx, %rax
addq $-0x4, %rax
movq %rax, 0x38(%rsp)
cmpq $0x3, %rbp
movl $0x0, %eax
adcl $-0x1, %eax
orl $0x1, %eax
movw %ax, 0x40(%rsp)
movw $0x0, 0x42(%rsp)
movq 0x40(%r15), %rdi
movq %r14, %rsi
xorl %edx, %edx
leaq 0x28(%rsp), %rcx
leaq 0x20(%rsp), %r8
callq 0x9002
movq 0x10(%r15), %r9
movl 0x20(%rsp), %r10d
movq %r14, %r12
movq %rbx, %r14
movq 0x28(%rsp), %rbx
movq 0x8(%rsp), %rdi
leaq 0x1d1f6(%rip), %rsi     # 0x2717d
movq %r13, %rdx
movq %rbp, %rcx
movq 0x18(%rsp), %r8
xorl %eax, %eax
pushq %rbx
pushq %r10
callq 0x3500
addq $0x10, %rsp
movq %rbx, %rdi
movq %r14, %rbx
movq %r12, %r14
callq 0x3390
incq %rbp
cmpq $0x6, %rbp
jne 0x9f0c
incq %r13
movq %r15, %rdi
callq 0xd61e
testl %eax, %eax
movq 0x8(%rsp), %r12
jg 0x9ed0
movq %r12, %rdi
callq 0x3370
movq 0x10(%rsp), %rdi
callq 0xe4b9
movq %r12, %rdi
callq 0xe490
movq %r15, %rdi
callq 0xd5c5
xorl %eax, %eax
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq