// File: /workspace/github_cpp_makefile_star2_O2/CK7[P]abawaca/src/ReadMappingReader.cpp
// Function: Bio::SAMReader::next_mapping()
ReadMapping* SAMReader::next_mapping()
{
	// The following loop should have an effect just once - at the beginning. Otherwise it should result with an entry 
	// every time it reads a line 
	static char* 	next_line = (char*)calloc(1024, sizeof(char));
	static size_t	next_line_size = 1024;
	next_line[0] = 0;
	do {
		// We do the following because we don't know whether the size of next_line is sufficient for storing the next line. 
		// If not we will increase the size of next_line until we have enough space. Eventually next_line will be able to 
		// store the longest line in the file.
		char 	*p = next_line;
		size_t	s = next_line_size;
		while(fgets(p, s, m_fp)) {
			if((*(p+strlen(p)-1) == '\n') || !this->good())
				break;
			if(strlen(p) != s-1) {
				// This is weird!
			}
			// Else - we did not read the whole line, need to increase next_line's size and continue reading
			next_line_size *= 2;
			next_line = (char*)realloc(next_line, next_line_size);
			p = next_line+strlen(next_line); 
			s = next_line_size - strlen(next_line);
		}
		if(next_line[0] == '@')
			m_total_to_read -= strlen(next_line);		
	} while(this->good() && ((next_line[0] == 0) || (next_line[0] == '@')));
	if(next_line[0] == 0) {
		return NULL;
	}
//		return new ReadMapping(SAMReader::_end);
	m_total_read += strlen(next_line);
	chomp(next_line);

	return new ReadMapping(next_line);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0xf2fd(%rip), %al       # 0x15308
testb %al, %al
je 0x610e
movq 0xf2e6(%rip), %r14      # 0x15300
movb $0x0, (%r14)
movq 0xf2ab(%rip), %r15      # 0x152d0
movq 0x8(%rbx), %rdx
movq %r14, %rdi
movl %r15d, %esi
callq 0x4440
testq %rax, %rax
je 0x6090
movq %r14, %rdi
callq 0x4110
cmpb $0xa, -0x1(%r14,%rax)
je 0x6090
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
testb %al, %al
je 0x6090
movq 0xf273(%rip), %r15      # 0x152d0
addq %r15, %r15
movq %r15, 0xf269(%rip)      # 0x152d0
movq 0xf292(%rip), %rdi      # 0x15300
movq %r15, %rsi
callq 0x4480
movq %rax, %r14
movq %rax, 0xf280(%rip)      # 0x15300
movq %rax, %rdi
callq 0x4110
addq %rax, %r14
subq %rax, %r15
jmp 0x6025
movq 0xf269(%rip), %rdi      # 0x15300
cmpb $0x40, (%rdi)
jne 0x60a5
callq 0x4110
subq %rax, 0x30(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movq 0xf24b(%rip), %r14      # 0x15300
movzbl (%r14), %ecx
testb %al, %al
je 0x60c8
testb $-0x41, %cl
je 0x601e
jmp 0x60cc
testl %ecx, %ecx
je 0x60fe
movq %r14, %rdi
callq 0x4110
addq %rax, 0x38(%rbx)
movq %r14, %rdi
callq 0xca45
movl $0xe8, %edi
callq 0x4280
movq %rax, %rbx
movq 0xf20c(%rip), %rsi      # 0x15300
movq %rax, %rdi
callq 0x511e
jmp 0x6100
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf1f3(%rip), %rdi      # 0x15308
callq 0x44c0
testl %eax, %eax
je 0x6013
pushq $0x1
popq %rsi
movl $0x400, %edi            # imm = 0x400
callq 0x41a0
movq %rax, 0xf1ca(%rip)      # 0x15300
leaq 0xf1cb(%rip), %rdi      # 0x15308
callq 0x4190
jmp 0x6013
movq %rax, %r14
movq %rbx, %rdi
callq 0x4250
movq %r14, %rdi
callq 0x44b0