// File: /workspace/github_c_makefile_star2_O2/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 $0x2038, %rsp           # imm = 0x2038
movq %rsi, %rbx
movq %rdi, %rsi
leaq 0x1977f(%rip), %r14     # 0x22182
leaq 0x19414(%rip), %rdx     # 0x21e1e
movq %r14, %rdi
callq 0xcacc
movq %rax, %r15
leaq 0x1bac3(%rip), %rdx     # 0x244df
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc931
movq %rax, (%rsp)
movq %r15, 0x8(%rsp)
movq %r15, %rdi
callq 0xc1ce
movq %rax, %r15
xorl %r12d, %r12d
movq %r15, %rdi
callq 0xc2aa
testl %eax, %eax
jle 0x8b24
movq 0x30(%r15), %rcx
xorl %eax, %eax
xorl %edx, %edx
cmpq %rax, %rcx
je 0x8a72
movq 0x40(%r15), %rsi
movzbl (%rsi,%rax), %esi
orl $0x4, %esi
cmpl $0x47, %esi
jne 0x8a6d
incl %edx
incq %rax
jmp 0x8a56
imull $0x64, %edx, %eax
cltq
xorl %edx, %edx
divq %rcx
movq %rax, %r13
pushq $0x6
popq %r14
xorl %ebp, %ebp
subq $0x1, %r14
jb 0x8b1c
movq %rbp, %rax
subq $0x3, %rax
cmovbq %rbp, %rax
movq %rax, 0x20(%rsp)
movq 0x30(%r15), %rcx
leaq -0x4(%rax,%rcx), %rax
movq %rax, 0x28(%rsp)
movl $0x0, %eax
adcw $-0x1, %ax
orl $0x1, %eax
movw %ax, 0x30(%rsp)
andw $0x0, 0x32(%rsp)
movq 0x40(%r15), %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
leaq 0x18(%rsp), %rcx
leaq 0x10(%rsp), %r8
callq 0x7f00
movq 0x10(%r15), %r9
movl 0x10(%rsp), %r10d
movq 0x18(%rsp), %rbx
movq (%rsp), %rdi
leaq 0x196a1(%rip), %rsi     # 0x22198
movq %r12, %rdx
movq %rbp, %rcx
movl %r13d, %r8d
xorl %eax, %eax
pushq %rbx
pushq %r10
callq 0x3500
popq %rcx
popq %rdx
movq %rbx, %rdi
callq 0x3390
incq %rbp
jmp 0x8a85
incq %r12
jmp 0x8a3e
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x3370
movq 0x8(%rsp), %rdi
callq 0xd044
movq %rbx, %rdi
callq 0xd01b
movq %r15, %rdi
callq 0xc251
xorl %eax, %eax
addq $0x2038, %rsp           # imm = 0x2038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq