// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2080, %rsp           # imm = 0x2080
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x2d902(%rip), %rdi     # 0x39050
leaq 0x2d5ad(%rip), %rdx     # 0x38d02
callq 0x12990
movq %rax, -0x2030(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x2d8e4(%rip), %rdi     # 0x39050
leaq 0x2fba5(%rip), %rdx     # 0x3b318
callq 0x12740
movq %rax, -0x2038(%rbp)
movq -0x2030(%rbp), %rdi
callq 0x11a10
movq %rax, -0x2048(%rbp)
movq $0x0, -0x2060(%rbp)
movq -0x2048(%rbp), %rdi
callq 0x11b70
cmpl $0x0, %eax
jle 0xb993
movl $0x0, -0x2050(%rbp)
movl $0x0, -0x204c(%rbp)
movslq -0x204c(%rbp), %rax
movq -0x2048(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0xb832
movq -0x2048(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x204c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x47, %eax
je 0xb810
movq -0x2048(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x204c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x43, %eax
jne 0xb81f
movl -0x2050(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2050(%rbp)
jmp 0xb821
movl -0x204c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x204c(%rbp)
jmp 0xb7c6
imull $0x64, -0x2050(%rbp), %eax
cltq
movq -0x2048(%rbp), %rcx
xorl %edx, %edx
divq 0x30(%rcx)
movl %eax, -0x2050(%rbp)
movq $0x0, -0x2068(%rbp)
cmpq $0x6, -0x2068(%rbp)
jae 0xb97c
movq -0x2068(%rbp), %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
movq %rdx, -0x2028(%rbp)
movq -0x2048(%rbp), %rax
movq 0x30(%rax), %rax
subq $0x1, %rax
subq $0x3, %rax
movq %rax, -0x2070(%rbp)
movq -0x2068(%rbp), %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
movq -0x2070(%rbp), %rax
addq %rdx, %rax
movq %rax, -0x2020(%rbp)
movq -0x2068(%rbp), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpq $0x3, %rdx
cmovbl %ecx, %eax
movw %ax, -0x2018(%rbp)
movw $0x0, -0x2016(%rbp)
movq -0x2048(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x2028(%rbp), %rsi
xorl %edx, %edx
leaq -0x2040(%rbp), %rcx
leaq -0x2058(%rbp), %r8
callq 0xa4f0
movq -0x2038(%rbp), %rdi
movq -0x2060(%rbp), %rdx
movq -0x2068(%rbp), %rcx
movl -0x2050(%rbp), %r8d
movq -0x2048(%rbp), %rax
movq 0x10(%rax), %r9
movq -0x2058(%rbp), %rax
movl %eax, %r10d
movq -0x2040(%rbp), %rax
leaq 0x2d71d(%rip), %rsi     # 0x39066
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x34e0
movq -0x2040(%rbp), %rdi
callq 0x3380
movq -0x2068(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2068(%rbp)
jmp 0xb859
movq -0x2060(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2060(%rbp)
jmp 0xb79d
movq -0x2038(%rbp), %rdi
callq 0x3360
movq -0x2030(%rbp), %rdi
callq 0x13200
movq -0x2038(%rbp), %rdi
callq 0x131b0
movq -0x2048(%rbp), %rdi
callq 0x11ad0
xorl %eax, %eax
addq $0x2080, %rsp           # imm = 0x2080
popq %rbp
retq
nop