// File: conchoecia[P]fasta_stats/src/fasta_stats.cc
// Function: read_file(char*, std::__cxx11::list<Scaffold, std::allocator<Scaffold>>&)
static int read_file(char *filename, std::list<Scaffold> &scaffolds) {
	int fd = open_compressed(filename);
	if (fd == -1) {
		fprintf(stderr, "Error: open_compressed %s: %s\n", filename, strerror(errno));
		return 0;
	}
	long n = 0;
	scaffolds.push_back(Scaffold());
	Contig *current = &scaffolds.back().contigs.back();
	std::string line;
	while (pfgets(fd, line) != -1) {
		if (line[0] == '>') {
			if (!scaffolds.back().empty()) {
				scaffolds.push_back(Scaffold());
			}
			current = &scaffolds.back().contigs.back();
			n = 0;
			continue;
		}
		size_t i = line.find_first_of("Nn");
		if (i != 0 && n != 0) {		// handle line carryover
			if (n == opt_N_cutoff) {
				if (!scaffolds.back().empty()) {
					scaffolds.back().total_size -= n;
					scaffolds.push_back(Scaffold());
				}
				current = &scaffolds.back().contigs.back();
			} else if (n >= opt_n_cutoff) {
				if (!current->empty()) {
					scaffolds.back().contigs.push_back(Contig());
					scaffolds.back().gaps.push_back(n);
					current = &scaffolds.back().contigs.back();
				}
			} else {
				current->n += n;
				current->total_size += n;
			}
			n = 0;
		}
		scaffolds.back().total_size += line.size();
		size_t j = 0;
		for (;;) {
			if (i == line.npos) {
				current->total_size += line.size() - j;
				break;
			}
			current->total_size += i - j;
			j = line.find_first_not_of("Nn", i + 1);
			if (j == line.npos) {
				n += line.size() - i;
				break;
			}
			n += j - i;
			if (n == opt_N_cutoff) {
				if (!scaffolds.back().empty()) {
					scaffolds.back().total_size -= n + line.size() - j;
					scaffolds.push_back(Scaffold());
				}
				current = &scaffolds.back().contigs.back();
				scaffolds.back().total_size = line.size() - j;
			} else if (n >= opt_n_cutoff) {
				if (!current->empty()) {
					scaffolds.back().contigs.push_back(Contig());
					scaffolds.back().gaps.push_back(n);
					current = &scaffolds.back().contigs.back();
				}
			} else {
				current->total_size += n;
				current->n += n;
			}
			n = 0;
			i = line.find_first_of("Nn", j + 1);
		}
	}
	close_compressed(fd);
	if (scaffolds.back().empty()) {
		scaffolds.pop_back();
	}
	std::list<Scaffold>::iterator a = scaffolds.begin();
	std::list<Scaffold>::iterator end_a = scaffolds.end();
	for (; a != end_a; ++a) {
		a->calc_contig_sizes();
	}
	scaffolds.sort();
	return 1;
}

// Assembly:
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdi, 0x2c8(%rsp)
movq %rsi, 0x2c0(%rsp)
movq 0x2c8(%rsp), %rax
movq %rax, 0xc0(%rsp)
leaq 0x297(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
callq 0x2430
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
leaq 0x298(%rsp), %rdi
callq 0x2350
jmp 0x291b
leaq 0x298(%rsp), %rdi
callq 0xa910
movl %eax, 0xbc(%rsp)
jmp 0x2931
leaq 0x298(%rsp), %rdi
callq 0x21a0
leaq 0x297(%rsp), %rdi
callq 0x22a0
movl 0xbc(%rsp), %eax
movl %eax, 0x2bc(%rsp)
cmpl $-0x1, 0x2bc(%rsp)
jne 0x2a0f
movq 0x13662(%rip), %rax     # 0x15fd0
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
movq 0x2c8(%rsp), %rax
movq %rax, 0xb0(%rsp)
callq 0x2040
movl (%rax), %edi
callq 0x20d0
movq 0xa8(%rsp), %rdi
movq 0xb0(%rsp), %rdx
movq %rax, %rcx
leaq 0xc8d4(%rip), %rsi      # 0xf283
movb $0x0, %al
callq 0x2380
movl $0x0, 0x2d4(%rsp)
jmp 0x32e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x29fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x21a0
leaq 0x297(%rsp), %rdi
callq 0x22a0
jmp 0x32f0
movq $0x0, 0x278(%rsp)
movq 0x2c0(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x228(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x4a10
movq 0x98(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x49d0
jmp 0x2a57
leaq 0x228(%rsp), %rdi
callq 0x4ae0
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
addq $0x20, %rdi
callq 0x4b50
movq %rax, 0x220(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x2370
movl 0x2bc(%rsp), %edi
leaq 0x200(%rsp), %rsi
callq 0xaf30
movq %rax, 0x90(%rsp)
jmp 0x2ab0
movq 0x90(%rsp), %rax
cmpq $-0x1, %rax
je 0x31fc
xorl %eax, %eax
movl %eax, %esi
leaq 0x200(%rsp), %rdi
callq 0x2470
movq %rax, 0x88(%rsp)
jmp 0x2add
movq 0x88(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x2bf6
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
callq 0x4b90
movb %al, 0x87(%rsp)
jmp 0x2b0f
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0x2bc4
jmp 0x2b20
movq 0x2c0(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x4a10
jmp 0x2b3c
movq 0x78(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x49d0
jmp 0x2b50
leaq 0x1b0(%rsp), %rdi
callq 0x4ae0
jmp 0x2bc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x228(%rsp), %rdi
callq 0x4ae0
jmp 0x32f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x32d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x4ae0
jmp 0x32d2
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
addq $0x20, %rdi
callq 0x4b50
movq %rax, 0x220(%rsp)
movq $0x0, 0x278(%rsp)
jmp 0x2a92
leaq 0x200(%rsp), %rdi
leaq 0xc69d(%rip), %rsi      # 0xf2a2
xorl %eax, %eax
movl %eax, %edx
callq 0x2140
movq %rax, 0x1a8(%rsp)
cmpq $0x0, 0x1a8(%rsp)
je 0x2e4b
cmpq $0x0, 0x278(%rsp)
je 0x2e4b
movq 0x278(%rsp), %rax
cmpq 0x13625(%rip), %rax     # 0x16268
jne 0x2d25
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
callq 0x4b90
movb %al, 0x77(%rsp)
jmp 0x2c64
movb 0x77(%rsp), %al
testb $0x1, %al
jne 0x2cff
jmp 0x2c72
movq 0x278(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq 0x60(%rsp), %rdx
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movq 0x2c0(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x4a10
jmp 0x2cb6
movq 0x68(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x49d0
jmp 0x2cca
leaq 0x158(%rsp), %rdi
callq 0x4ae0
jmp 0x2cff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x4ae0
jmp 0x32d2
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
addq $0x20, %rdi
callq 0x4b50
movq %rax, 0x220(%rsp)
jmp 0x2e3f
movq 0x278(%rsp), %rax
cmpq 0x1352c(%rip), %rax     # 0x16260
jl 0x2e0f
movq 0x220(%rsp), %rdi
callq 0x4c30
movb %al, 0x5f(%rsp)
jmp 0x2d4d
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0x2e0d
jmp 0x2d5b
movq 0x2c0(%rsp), %rdi
callq 0x4b10
addq $0x20, %rax
movq %rax, 0x50(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x4cb0
jmp 0x2d80
movq 0x50(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x4c70
jmp 0x2d94
leaq 0x148(%rsp), %rdi
callq 0x4cd0
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
addq $0x38, %rdi
leaq 0x278(%rsp), %rsi
callq 0x4ce0
jmp 0x2dc4
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
addq $0x20, %rdi
callq 0x4b50
movq %rax, 0x220(%rsp)
jmp 0x2e0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x4cd0
jmp 0x32d2
jmp 0x2e3d
movq 0x278(%rsp), %rcx
movq 0x220(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x278(%rsp), %rcx
movq 0x220(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x2e3f
movq $0x0, 0x278(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x21e0
movq %rax, 0x48(%rsp)
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq 0x48(%rsp), %rcx
addq (%rax), %rcx
movq %rcx, (%rax)
movq $0x0, 0x140(%rsp)
cmpq $-0x1, 0x1a8(%rsp)
jne 0x2eb7
leaq 0x200(%rsp), %rdi
callq 0x21e0
movq %rax, %rcx
subq 0x140(%rsp), %rcx
movq 0x220(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x31f7
movq 0x1a8(%rsp), %rcx
subq 0x140(%rsp), %rcx
movq 0x220(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x1a8(%rsp), %rdx
addq $0x1, %rdx
leaq 0x200(%rsp), %rdi
leaq 0xc3b2(%rip), %rsi      # 0xf2a2
callq 0x2180
movq %rax, 0x140(%rsp)
cmpq $-0x1, 0x140(%rsp)
jne 0x2f32
leaq 0x200(%rsp), %rdi
callq 0x21e0
subq 0x1a8(%rsp), %rax
addq 0x278(%rsp), %rax
movq %rax, 0x278(%rsp)
jmp 0x31f7
movq 0x140(%rsp), %rax
subq 0x1a8(%rsp), %rax
addq 0x278(%rsp), %rax
movq %rax, 0x278(%rsp)
movq 0x278(%rsp), %rax
cmpq 0x13307(%rip), %rax     # 0x16268
jne 0x30a4
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
callq 0x4b90
movb %al, 0x47(%rsp)
jmp 0x2f82
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x304f
jmp 0x2f90
movq 0x278(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x21e0
movq %rax, %rcx
movq 0x20(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x140(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rsi
movq (%rax), %rcx
subq %rsi, %rdx
addq %rdx, %rcx
movq %rcx, (%rax)
movq 0x2c0(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x4a10
jmp 0x3006
movq 0x38(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x49d0
jmp 0x301a
leaq 0xf0(%rsp), %rdi
callq 0x4ae0
jmp 0x304f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x4ae0
jmp 0x32d2
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
addq $0x20, %rdi
callq 0x4b50
movq %rax, 0x220(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x21e0
subq 0x140(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
jmp 0x31be
movq 0x278(%rsp), %rax
cmpq 0x131ad(%rip), %rax     # 0x16260
jl 0x318e
movq 0x220(%rsp), %rdi
callq 0x4c30
movb %al, 0x17(%rsp)
jmp 0x30cc
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x318c
jmp 0x30da
movq 0x2c0(%rsp), %rdi
callq 0x4b10
addq $0x20, %rax
movq %rax, 0x8(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x4cb0
jmp 0x30ff
movq 0x8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x4c70
jmp 0x3113
leaq 0xe0(%rsp), %rdi
callq 0x4cd0
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
addq $0x38, %rdi
leaq 0x278(%rsp), %rsi
callq 0x4ce0
jmp 0x3143
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
addq $0x20, %rdi
callq 0x4b50
movq %rax, 0x220(%rsp)
jmp 0x318c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0x4cd0
jmp 0x32d2
jmp 0x31bc
movq 0x278(%rsp), %rcx
movq 0x220(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x278(%rsp), %rcx
movq 0x220(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x31be
movq $0x0, 0x278(%rsp)
movq 0x140(%rsp), %rdx
addq $0x1, %rdx
leaq 0x200(%rsp), %rdi
leaq 0xc0bd(%rip), %rsi      # 0xf2a2
callq 0x2140
movq %rax, 0x1a8(%rsp)
jmp 0x2e81
jmp 0x2a92
movl 0x2bc(%rsp), %edi
callq 0xaf10
jmp 0x320a
movq 0x2c0(%rsp), %rdi
callq 0x4b10
movq %rax, %rdi
callq 0x4b90
movb %al, 0x7(%rsp)
jmp 0x3225
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x322f
jmp 0x323c
movq 0x2c0(%rsp), %rdi
callq 0x4d20
movq 0x2c0(%rsp), %rdi
callq 0x4d60
movq %rax, 0xd8(%rsp)
movq 0x2c0(%rsp), %rdi
callq 0x4d90
movq %rax, 0xd0(%rsp)
leaq 0xd8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x4dc0
testb $0x1, %al
jne 0x3281
jmp 0x32a9
leaq 0xd8(%rsp), %rdi
callq 0x4de0
movq %rax, %rdi
callq 0x4e00
jmp 0x3298
jmp 0x329a
leaq 0xd8(%rsp), %rdi
callq 0x4f50
jmp 0x3266
movq 0x2c0(%rsp), %rdi
callq 0x4f70
jmp 0x32b8
movl $0x1, 0x2d4(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x21a0
jmp 0x32e1
leaq 0x200(%rsp), %rdi
callq 0x21a0
jmp 0x32f0
movl 0x2d4(%rsp), %eax
addq $0x2d8, %rsp            # imm = 0x2D8
retq
movq 0x288(%rsp), %rdi
callq 0x2420
nopl (%rax)