// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
testq %rdi, %rdi
je 0x8857
cmpb $0x2d, (%rdi)
jne 0x8849
cmpb $0x0, 0x1(%rdi)
je 0x8857
leaq 0x21cc5(%rip), %rsi     # 0x2a515
callq 0x22e0
jmp 0x8865
leaq 0x21cb7(%rip), %rsi     # 0x2a515
xorl %edi, %edi
callq 0x20f0
movq %rax, %rbx
testq %rax, %rax
je 0x8c8a
movl $0x1, %edi
movl $0x20, %esi
callq 0x21e0
movq %rax, %r14
movq %rbx, 0x38(%rsp)
movq %rbx, 0x10(%rax)
movl $0x40000, 0x8(%rax)     # imm = 0x40000
movl $0x10000, %edi          # imm = 0x10000
callq 0x2280
movq %rax, 0x18(%r14)
callq 0x4849
movq %rax, 0x10(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r12d, %r12d
xorl %r13d, %r13d
movq $0x0, (%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ebx, %ebx
movq $0x0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpl %eax, %ecx
jl 0x88f2
testb $0x3, 0x8(%r14)
jne 0x8c8f
movl %ebx, 0xc(%rsp)
xorl %r15d, %r15d
cmpl %eax, %ecx
jl 0x893e
movl 0x8(%r14), %ebx
testb $0x3, %bl
jne 0x89f1
movl $0x0, (%r14)
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
movl %ebx, %ebp
sarl $0x2, %ebp
movl %ebp, %edx
callq 0x2200
movl %eax, 0x4(%r14)
cmpl %ebp, %eax
jge 0x8934
orl $0x1, %ebx
movl %ebx, 0x8(%r14)
testl %eax, %eax
je 0x89f1
xorl %ecx, %ecx
movl %ecx, %ebp
cmpl %eax, %ecx
jge 0x895d
movslq %ecx, %rdx
addq 0x18(%r14), %rdx
movl %ecx, %ebp
cmpb $0xa, (%rdx)
je 0x895d
incl %ebp
incq %rdx
cmpl %ebp, %eax
jne 0x894d
movl %eax, %ebp
movq %r12, %rdx
subq %r15, %rdx
movl %ebp, %eax
subl %ecx, %eax
leal 0x1(%rax), %esi
movslq %esi, %rsi
cmpq %rsi, %rdx
jae 0x89c0
cltq
addq %r15, %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %r12
shrq $0x10, %r12
orq %rax, %r12
incq %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x22b0
movq %rax, %r13
movl (%r14), %ecx
movl %ebp, %eax
subl %ecx, %eax
leaq (%r15,%r13), %rdi
movslq %ecx, %rsi
addq 0x18(%r14), %rsi
movslq %eax, %rdx
callq 0x2230
movslq (%r14), %rax
movslq %ebp, %rcx
subq %rax, %rcx
addq %rcx, %r15
leal 0x1(%rbp), %ecx
movl %ecx, (%r14)
movl 0x4(%r14), %eax
cmpl %eax, %ebp
jge 0x88f9
testq %r13, %r13
je 0x8a0c
cmpq $0x2, %r15
jb 0x8a24
xorl %eax, %eax
cmpb $0xd, -0x1(%r13,%r15)
sete %al
subq %rax, %r15
jmp 0x8a24
movl $0x1, %r12d
movl $0x1, %edi
movl $0x1, %esi
callq 0x21e0
movq %rax, %r13
movq 0x20(%rsp), %rbp
movb $0x0, (%r13,%r15)
testl %r15d, %r15d
js 0x8c84
incq 0x30(%rsp)
testq %r15, %r15
je 0x8a87
cmpb $0x3e, (%r13)
jne 0x8a93
testq %rbp, %rbp
je 0x8b6b
movq 0x18(%rsp), %rdi
callq 0x4a43
movq %rax, 0x20(%rbp)
movq (%rsp), %rax
movl %eax, (%rbp)
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x516d
movb (%r13), %bl
testb %bl, %bl
jne 0x8b6d
xorl %eax, %eax
jmp 0x8b8e
cmpl $0x0, 0xc(%rsp)
jne 0x8ad9
jmp 0x8c02
cmpl $0x0, 0xc(%rsp)
je 0x8bfc
cmpq $0x3, %r15
jb 0x8ad9
cmpb $0x9, 0x1(%r13)
jne 0x8ad9
testq %rbp, %rbp
je 0x8ad2
movq 0x18(%rsp), %rdi
callq 0x4a43
movq %rax, 0x20(%rbp)
movq (%rsp), %rax
movl %eax, (%rbp)
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x516d
xorl %ebp, %ebp
jmp 0x8c06
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq (%rsp), %rax
addq %r15, %rax
incq %rax
cmpq 0x28(%rsp), %rax
jae 0x8af8
movq 0x18(%rsp), %rbx
jmp 0x8b3e
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq 0x18(%rsp), %rdi
movq %rsi, 0x28(%rsp)
callq 0x22b0
movq %rax, %rbx
movq (%rsp), %rbp
leaq (%rbx,%rbp), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2230
addq %r15, %rbp
movq %rbx, 0x18(%rsp)
movq %rbp, (%rsp)
movb $0x0, (%rbx,%rbp)
movl $0x1, %ebx
jmp 0x8c4f
movb $0x3e, %bl
callq 0x23a0
movq (%rax), %rcx
xorl %eax, %eax
movsbq %bl, %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x8b8e
movb 0x1(%r13,%rax), %bl
incq %rax
testb %bl, %bl
jne 0x8b77
movb $0x0, (%r13,%rax)
movq 0x10(%rsp), %rbp
movl 0x4(%rbp), %edx
incl %edx
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1f99a(%rip), %rsi     # 0x28547
xorl %eax, %eax
callq 0x2320
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x4aa4
movq 0x10(%rbp), %rbx
movslq %eax, %r15
shlq $0x6, %r15
leaq (%rbx,%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x1(%r13), %rsi
movq %rbp, %rdi
callq 0x4f76
movl %eax, 0x8(%rbx,%r15)
movq $0x0, 0xc(%rbx,%r15)
movl $0x1, %ebx
movq $0x0, (%rsp)
jmp 0x8c4f
cmpq $0x3, %r15
jae 0x8c06
xorl %ebx, %ebx
jmp 0x8c4f
xorl %ebx, %ebx
cmpb $0x9, 0x1(%r13)
movq %rbp, 0x20(%rsp)
jne 0x8c4f
movzbl (%r13), %eax
cmpl $0x4c, %eax
je 0x8c32
cmpl $0x53, %eax
jne 0x8c4f
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x8160
jmp 0x8c3f
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x83b5
testl %eax, %eax
jns 0x8c4f
leaq 0x295a6(%rip), %rcx     # 0x321f0
cmpl $0x0, (%rcx)
jg 0x8c5b
movl (%r14), %ecx
movl 0x4(%r14), %eax
jmp 0x88e3
movq 0x29396(%rip), %rcx     # 0x31ff8
movq (%rcx), %rdi
movsbl (%r13), %edx
xorl %ebx, %ebx
leaq 0x1f828(%rip), %rsi     # 0x2849b
movq 0x30(%rsp), %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x2210
jmp 0x8c4f
movl 0xc(%rsp), %ebx
jmp 0x8c94
xorl %r15d, %r15d
jmp 0x8cfb
movq 0x20(%rsp), %rbp
testl %ebx, %ebx
movq 0x38(%rsp), %rbx
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
je 0x8cca
testq %rbp, %rbp
je 0x8cca
movq %r12, %rdi
callq 0x4a43
movq %rax, 0x20(%rbp)
movq (%rsp), %rax
movl %eax, (%rbp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x516d
movq %r12, %rdi
callq 0x2040
movq %r13, %rdi
callq 0x2040
movq %r15, %rdi
callq 0x6126
movq 0x18(%r14), %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2030
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq