// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x14040, %rsp          # imm = 0x14040
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq -0x2030(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x2000, %esi           # imm = 0x2000
callq 0x35b0
cmpq $0x0, %rax
je 0xb1bf
movq -0x20(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movsbl -0x2030(%rbp), %eax
cmpl $0x23, %eax
jne 0xafe2
jmp 0xafa7
movsbl -0x2030(%rbp), %eax
cmpl $0xa, %eax
je 0xaffa
movsbl -0x2030(%rbp), %eax
cmpl $0xd, %eax
jne 0xaffc
jmp 0xafa7
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x9, -0x24(%rbp)
jge 0xb059
leaq -0x2030(%rbp), %rdi
movslq -0x28(%rbp), %rax
addq %rax, %rdi
movslq -0x24(%rbp), %rax
leaq -0x14030(%rbp), %rdx
shlq $0xd, %rax
addq %rax, %rdx
leaq 0x2dfb9(%rip), %rsi     # 0x38ff0
leaq -0x2c(%rbp), %rcx
movb $0x0, %al
callq 0x32d0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xb00a
leaq -0x14030(%rbp), %rdi
addq $0x4000, %rdi           # imm = 0x4000
leaq 0x2df8a(%rip), %rsi     # 0x38ff8
callq 0x34b0
cmpl $0x0, %eax
jne 0xb1ba
leaq -0x14030(%rbp), %rdi
addq $0x6000, %rdi           # imm = 0x6000
callq 0x3390
movq %rax, %rcx
subq $0x1, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0x14030(%rbp), %rdi
addq $0x8000, %rdi           # imm = 0x8000
callq 0x3390
movq %rax, %rcx
subq $0x1, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movsbl -0x8030(%rbp), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0x2b, %edx
cmovel %ecx, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x10(%rax)
leaq -0x14030(%rbp), %rdi
addq $0xe000, %rdi           # imm = 0xE000
callq 0x3590
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x12(%rax)
movq -0x18(%rbp), %rdi
addq $0x16, %rdi
leaq -0x14030(%rbp), %rdx
addq $0x10000, %rdx          # imm = 0x10000
leaq 0x2ee0e(%rip), %rsi     # 0x39f2a
movb $0x0, %al
callq 0x3070
movl $0x0, -0x28(%rbp)
movslq -0x28(%rbp), %rax
movq %rax, -0x14038(%rbp)
movq -0x18(%rbp), %rdi
addq $0x16, %rdi
callq 0x30f0
movq %rax, %rcx
movq -0x14038(%rbp), %rax
cmpq %rcx, %rax
jae 0xb1b1
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl 0x16(%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0xb170
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb $0x5f, 0x16(%rax,%rcx)
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl 0x16(%rax,%rcx), %eax
cmpl $0xa, %eax
je 0xb194
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl 0x16(%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0xb1a1
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
movb $0x0, 0x16(%rax,%rcx)
jmp 0xb1a3
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xb12a
movl $0x1, -0x4(%rbp)
jmp 0xb1c6
jmp 0xafa7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x14040, %rsp          # imm = 0x14040
popq %rbp
retq
nopw %cs:(%rax,%rax)