// File: /workspace/github_c_makefile_star2_O2/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 $0x68, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x69d5
cmpb $0x2d, (%rdi)
jne 0x69c7
cmpb $0x0, 0x1(%rdi)
je 0x69d5
leaq 0x1eb27(%rip), %rsi     # 0x254f5
callq 0x22e0
jmp 0x69e3
leaq 0x1eb19(%rip), %rsi     # 0x254f5
xorl %edi, %edi
callq 0x20f0
movq %rax, %rbx
testq %rax, %rax
je 0x6d8d
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0x21e0
movq %rax, %r14
movq %rbx, 0x48(%rsp)
movq %rbx, 0x10(%rax)
movl $0x40000, 0x8(%rax)     # imm = 0x40000
movl $0x10000, %edi          # imm = 0x10000
callq 0x2280
movq %rax, 0x18(%r14)
callq 0x3d71
movq %rax, 0x10(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %ebx, %ebx
movq $0x0, 0x18(%rsp)
movq $0x0, 0x40(%rsp)
cmpl %eax, %ecx
jl 0x6a52
testb $0x3, 0x8(%r14)
jne 0x6d2c
movl %ebx, 0xc(%rsp)
xorl %ebx, %ebx
cmpl %eax, %ecx
jl 0x6a9f
movl 0x8(%r14), %ebp
testb $0x3, %bpl
jne 0x6b5c
andl $0x0, (%r14)
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
movl %ebp, %r15d
sarl $0x2, %r15d
movl %r15d, %edx
callq 0x2200
movl %eax, 0x4(%r14)
cmpl %r15d, %eax
jge 0x6a95
orl $0x1, %ebp
movl %ebp, 0x8(%r14)
testl %eax, %eax
je 0x6b5c
xorl %ecx, %ecx
movslq %ecx, %rsi
cltq
cmpl %esi, %eax
movl %esi, %r15d
cmovgl %eax, %r15d
movq %rsi, %rdx
cmpq %rax, %rdx
jge 0x6ac7
movq 0x18(%r14), %rdi
cmpb $0xa, (%rdi,%rdx)
je 0x6ac4
incq %rdx
jmp 0x6ab0
movl %edx, %r15d
movq %r12, %rdx
subq %rbx, %rdx
movl %r15d, %eax
subl %ecx, %eax
leal 0x1(%rax), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rdx
jae 0x6b2c
cltq
addq %rbx, %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
movslq (%r14), %rsi
movl %r15d, %eax
subl %esi, %eax
leaq (%rbx,%r13), %rdi
addq 0x18(%r14), %rsi
movslq %eax, %rdx
callq 0x2230
movslq (%r14), %rax
movslq %r15d, %rcx
subq %rax, %rcx
addq %rcx, %rbx
leal 0x1(%r15), %ecx
movl %ecx, (%r14)
movl 0x4(%r14), %eax
cmpl %eax, %r15d
jge 0x6a58
testq %r13, %r13
je 0x6b77
cmpq $0x2, %rbx
jb 0x6b89
xorl %eax, %eax
cmpb $0xd, -0x1(%r13,%rbx)
sete %al
subq %rax, %rbx
jmp 0x6b89
pushq $0x1
popq %r12
movq %r12, %rdi
movq %r12, %rsi
callq 0x21e0
movq %rax, %r13
movb $0x0, (%r13,%rbx)
testl %ebx, %ebx
js 0x6d28
incq 0x40(%rsp)
testq %rbx, %rbx
je 0x6c51
cmpb $0x3e, (%r13)
jne 0x6c5a
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x6bcd
movl 0x20(%rsp), %edx
movq 0x30(%rsp), %rcx
movq 0x10(%rsp), %rdi
callq 0x6da2
movq %r13, %rax
movq %rax, %rbx
movsbq (%rax), %r15
testq %r15, %r15
je 0x6bf0
callq 0x23a0
movq (%rax), %rcx
leaq 0x1(%rbx), %rax
testb $0x20, 0x1(%rcx,%r15,2)
je 0x6bd0
movb $0x0, (%rbx)
movq 0x10(%rsp), %rbp
movl 0x4(%rbp), %edx
incl %edx
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1c944(%rip), %rsi     # 0x23550
xorl %eax, %eax
callq 0x2320
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3f7f
movq 0x10(%rbp), %rbx
movslq %eax, %r15
shlq $0x6, %r15
leaq (%rbx,%r15), %rax
movq %rax, 0x18(%rsp)
leaq 0x1(%r13), %rsi
movq %rbp, %rdi
callq 0x43e8
movl %eax, 0x8(%rbx,%r15)
andq $0x0, 0xc(%rbx,%r15)
andq $0x0, 0x20(%rsp)
jmp 0x6ca0
cmpl $0x0, 0xc(%rsp)
jne 0x6c91
jmp 0x6cd2
cmpl $0x0, 0xc(%rsp)
je 0x6ca5
cmpq $0x3, %rbx
jb 0x6c91
cmpb $0x9, 0x1(%r13)
jne 0x6c91
movl 0x20(%rsp), %edx
movq 0x30(%rsp), %rcx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x6da2
movq $0x0, 0x18(%rsp)
jmp 0x6cab
movq %r13, %rdi
movl %ebx, %esi
leaq 0x20(%rsp), %rdx
callq 0x600a
pushq $0x1
popq %rbx
jmp 0x6cd4
cmpq $0x3, %rbx
jb 0x6cd2
cmpb $0x9, 0x1(%r13)
jne 0x6cd2
movzbl (%r13), %ecx
cmpl $0x4c, %ecx
je 0x6ce0
xorl %eax, %eax
cmpl $0x53, %ecx
jne 0x6ced
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x62b7
jmp 0x6ced
xorl %ebx, %ebx
movl (%r14), %ecx
movl 0x4(%r14), %eax
jmp 0x6a43
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x64f9
xorl %ebx, %ebx
testl %eax, %eax
jns 0x6cd4
leaq 0x274f6(%rip), %rcx     # 0x2e1f0
cmpl $0x0, (%rcx)
jle 0x6cd4
movq 0x272f2(%rip), %rcx     # 0x2dff8
movq (%rcx), %rdi
movsbl (%r13), %edx
xorl %ebx, %ebx
leaq 0x1c78d(%rip), %rsi     # 0x234a4
movq 0x40(%rsp), %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x2210
jmp 0x6cd4
movl 0xc(%rsp), %ebx
movq 0x30(%rsp), %rcx
testl %ebx, %ebx
movq 0x48(%rsp), %rbx
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %rsi
je 0x6d5a
testq %rsi, %rsi
je 0x6d5a
movl 0x20(%rsp), %edx
movq %r15, %rdi
callq 0x6da2
movq 0x30(%rsp), %rcx
movq %rcx, %rdi
callq 0x2040
movq %r13, %rdi
callq 0x2040
movq %r15, %rdi
callq 0x5344
movq 0x18(%r14), %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2030
jmp 0x6d90
xorl %r15d, %r15d
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq