// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/gfa-io.c
// Function: gfa_read
gfa_t *gfa_read(const char *fn)
{
	gzFile fp;
	gfa_t *g;
	kstring_t s = {0,0,0}, fa_seq = {0,0,0};
	kstream_t *ks;
	int dret, is_fa = 0;
	gfa_seg_t *fa_seg = 0;
	uint64_t lineno = 0;

	fp = fn && strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(0, "r");
	if (fp == 0) return 0;
	ks = ks_init(fp);
	g = gfa_init();
	while (ks_getuntil(ks, KS_SEP_LINE, &s, &dret) >= 0) {
		int ret = 0;
		++lineno;
		if (s.l > 0 && s.s[0] == '>') { // FASTA header
			is_fa = 1;
			if (fa_seg) gfa_update_fa_seq(g, fa_seg, fa_seq.l, fa_seq.s);
			fa_seg = gfa_parse_fa_hdr(g, s.s);
			fa_seq.l = 0;
		} else if (is_fa) { // FASTA mode
			if (s.l >= 3 && s.s[1] == '\t') { // likely a GFA line
				gfa_update_fa_seq(g, fa_seg, fa_seq.l, fa_seq.s); // finalize fa_seg
				fa_seg = 0;
				is_fa = 0;
			} else kputsn(s.s, s.l, &fa_seq); // likely a FASTA sequence line
		}
		if (is_fa) continue;
		if (s.l < 3 || s.s[1] != '\t') continue; // empty line
		if (s.s[0] == 'S') ret = gfa_parse_S(g, s.s);
		else if (s.s[0] == 'L') ret = gfa_parse_L(g, s.s);
		if (ret < 0 && gfa_verbose >= 1)
			fprintf(stderr, "[E] invalid %c-line at line %ld (error code %d)\n", s.s[0], (long)lineno, ret);
	}
	if (is_fa && fa_seg) gfa_update_fa_seq(g, fa_seg, fa_seq.l, fa_seq.s);
	free(fa_seq.s);
	free(s.s);
	gfa_finalize(g);
	ks_destroy(ks);
	gzclose(fp);
	return g;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2190
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2190
movl $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xa688
movq -0x10(%rbp), %rdi
leaq 0x31cf8(%rip), %rsi     # 0x3c360
callq 0x21f0
cmpl $0x0, %eax
je 0xa688
movq -0x10(%rbp), %rdi
leaq 0x33d40(%rip), %rsi     # 0x3e3bd
callq 0x22e0
movq %rax, -0x80(%rbp)
jmp 0xa69a
xorl %edi, %edi
leaq 0x33d2c(%rip), %rsi     # 0x3e3bd
callq 0x20f0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xa6b6
movq $0x0, -0x8(%rbp)
jmp 0xa8a1
movq -0x18(%rbp), %rdi
callq 0xa8b0
movq %rax, -0x58(%rbp)
callq 0x54a0
movq %rax, -0x20(%rbp)
movq -0x58(%rbp), %rdi
movl $0x2, %esi
leaq -0x38(%rbp), %rdx
leaq -0x5c(%rbp), %rcx
callq 0xa910
cmpl $0x0, %eax
jl 0xa848
movl $0x0, -0x74(%rbp)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x38(%rbp)
jbe 0xa751
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3e, %eax
jne 0xa751
movl $0x1, -0x60(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0xa736
movq -0x20(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %rcx
callq 0xa950
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xa9a0
movq %rax, -0x68(%rbp)
movq $0x0, -0x50(%rbp)
jmp 0xa7aa
cmpl $0x0, -0x60(%rbp)
je 0xa7a8
cmpq $0x3, -0x38(%rbp)
jb 0xa793
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x9, %eax
jne 0xa793
movq -0x20(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %rcx
callq 0xa950
movq $0x0, -0x68(%rbp)
movl $0x0, -0x60(%rbp)
jmp 0xa7a6
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %esi
leaq -0x50(%rbp), %rdx
callq 0x92f0
jmp 0xa7a8
jmp 0xa7aa
cmpl $0x0, -0x60(%rbp)
je 0xa7b5
jmp 0xa6cc
cmpq $0x3, -0x38(%rbp)
jb 0xa7c9
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x9, %eax
je 0xa7ce
jmp 0xa6cc
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x53, %eax
jne 0xa7ec
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x9a20
movl %eax, -0x74(%rbp)
jmp 0xa80a
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4c, %eax
jne 0xa808
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x9e60
movl %eax, -0x74(%rbp)
jmp 0xa80a
cmpl $0x0, -0x74(%rbp)
jge 0xa843
leaq 0x3a9c9(%rip), %rax     # 0x451e0
cmpl $0x1, (%rax)
jl 0xa843
movq 0x3a7d5(%rip), %rax     # 0x44ff8
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movsbl (%rax), %edx
movq -0x70(%rbp), %rcx
movl -0x74(%rbp), %r8d
leaq 0x31c41(%rip), %rsi     # 0x3c47d
movb $0x0, %al
callq 0x2210
jmp 0xa6cc
cmpl $0x0, -0x60(%rbp)
je 0xa86c
cmpq $0x0, -0x68(%rbp)
je 0xa86c
movq -0x20(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x50(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %rcx
callq 0xa950
movq -0x40(%rbp), %rdi
callq 0x2040
movq -0x28(%rbp), %rdi
callq 0x2040
movq -0x20(%rbp), %rdi
callq 0x73f0
movq -0x58(%rbp), %rdi
callq 0xaa90
movq -0x18(%rbp), %rdi
callq 0x2030
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nop