// File: /workspace/github_c_makefile_star2_O1/ToniWestbrook[P]paladin/protein.c
// Function: getNextCDS
int getNextCDS(FILE * passFile, CDS * retCDS, unsigned long * retLine) {
	int fieldIdx, scanIdx;
	int readCount;
	char readBuffer[GFF_MAX_FIELD], field[9][GFF_MAX_FIELD];

	// Iterate through each annotation line until CDS or EOF
	while (fgets(readBuffer, GFF_MAX_FIELD, passFile)) {
		// Skip comments and blank lines
		(*retLine)++;
		if (readBuffer[0] == '#') continue;
		if ((readBuffer[0] == '\n') || (readBuffer[0] == '\r')) continue;

		// Parse all fields from GFF entry
		for (fieldIdx = 0, scanIdx = 0 ; fieldIdx < 9 ; fieldIdx++) {
			sscanf(readBuffer + scanIdx, "%[^\t]%n", field[fieldIdx], &readCount);
			scanIdx += readCount + 1;
		}

		// Check for CDS entry, assign to record and return
		if (strcmp(field[2], "CDS") == 0) {
			retCDS->startIdx = atol(field[3]) - 1;
			retCDS->endIdx = atol(field[4]) - 1;
			retCDS->strand = (field[6][0] == '+') ? 1 : -1;
			retCDS->phase = atoi(field[7]);

			// Fixup description
			sprintf(retCDS->description, "%s", field[8]);
			for (scanIdx = 0 ; scanIdx < strlen(retCDS->description) ; scanIdx++) {
				if (retCDS->description[scanIdx] == ' ') retCDS->description[scanIdx] = '_';
				if (retCDS->description[scanIdx] == 0x0A || retCDS->description[scanIdx] == 0x0D) retCDS->description[scanIdx] = 0;
			}

			return 1;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x14018, %rsp          # imm = 0x14018
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x10(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r15, %rdx
callq 0x35d0
testq %rax, %rax
je 0x9961
movq %rbx, 0x8(%rsp)
leaq 0x1d846(%rip), %r12     # 0x2710b
leaq 0x4(%rsp), %r13
leaq 0x10(%rsp), %rbx
movabsq $0x800002400, %rbp      # imm = 0x800002400
incq (%r14)
movzbl 0x10(%rsp), %eax
cmpq $0x23, %rax
ja 0x98ed
btq %rax, %rbp
jb 0x9948
xorl %ebx, %ebx
xorl %eax, %eax
movslq %eax, %rbp
leaq (%rsp,%rbp), %rdi
addq $0x10, %rdi
leaq (%rsp,%rbx), %rdx
addq $0x2010, %rdx           # imm = 0x2010
movq %r12, %rsi
movq %r13, %rcx
xorl %eax, %eax
callq 0x32e0
movl 0x4(%rsp), %eax
addl %ebp, %eax
incl %eax
addq $0x2000, %rbx           # imm = 0x2000
cmpq $0x12000, %rbx          # imm = 0x12000
jne 0x98f1
cmpl $0x534443, 0x6010(%rsp) # imm = 0x534443
leaq 0x10(%rsp), %rbx
movabsq $0x800002400, %rbp      # imm = 0x800002400
je 0x9977
movq %rbx, %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r15, %rdx
callq 0x35d0
testq %rax, %rax
jne 0x98d9
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x14018, %rsp          # imm = 0x14018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8010(%rsp), %rdi
callq 0x33a0
decq %rax
movq 0x8(%rsp), %rbx
movq %rax, (%rbx)
leaq 0xa010(%rsp), %r14
movq %r14, %rdi
callq 0x33a0
decq %rax
movq %rax, 0x8(%rbx)
xorl %eax, %eax
cmpb $0x2b, 0x4000(%r14)
sete %al
leal -0x1(,%rax,2), %eax
movw %ax, 0x10(%rbx)
leaq 0x10010(%rsp), %rdi
callq 0x35b0
movw %ax, 0x12(%rbx)
leaq 0x16(%rbx), %r14
leaq 0x12010(%rsp), %rsi
movq %r14, %rdi
callq 0x32c0
movl $0x1, %ebp
cmpb $0x0, 0x16(%rbx)
je 0x9963
xorl %ebx, %ebx
cmpb $0x20, (%r14,%rbx)
jne 0x9a00
movb $0x5f, (%r14,%rbx)
movzbl (%r14,%rbx), %eax
cmpl $0xd, %eax
je 0x9a0f
cmpl $0xa, %eax
jne 0x9a14
movb $0x0, (%r14,%rbx)
incq %rbx
movq %r14, %rdi
callq 0x3100
cmpq %rbx, %rax
ja 0x99f4
jmp 0x9963