// File: /workspace/github_c_makefile_star2_O1/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 0x8421
movq %rdi, %rbx
leaq 0x1ff69(%rip), %rsi     # 0x28370
callq 0x21f0
testl %eax, %eax
je 0x8421
leaq 0x22066(%rip), %rsi     # 0x2a47d
movq %rbx, %rdi
callq 0x22e0
jmp 0x842f
leaq 0x22055(%rip), %rsi     # 0x2a47d
xorl %edi, %edi
callq 0x20f0
movq %rax, %rbx
testq %rax, %rax
je 0x8901
movl $0x1, %edi
movl $0x20, %esi
callq 0x21e0
movq %rax, %r14
movq %rbx, 0x38(%rsp)
movq %rbx, 0x10(%rax)
movl 0x8(%rax), %eax
andl $0x3, %eax
orl $0x40000, %eax          # imm = 0x40000
movl %eax, 0x8(%r14)
movl $0x10000, %edi          # imm = 0x10000
callq 0x2280
movq %rax, 0x18(%r14)
callq 0x4964
movq %rax, 0x18(%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movq $0x0, 0x10(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movl (%r14), %eax
cmpl 0x4(%r14), %eax
jl 0x84d1
testb $0x3, 0x8(%r14)
je 0x84d1
xorl %ebp, %ebp
xorl %eax, %eax
jmp 0x8615
xorl %ebp, %ebp
movl (%r14), %eax
cmpl 0x4(%r14), %eax
jl 0x851e
movl 0x8(%r14), %r15d
testb $0x3, %r15b
jne 0x85d7
movl $0x0, (%r14)
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
movl %r15d, %ebx
sarl $0x2, %ebx
movl %ebx, %edx
callq 0x2200
movl %eax, 0x4(%r14)
cmpl %ebx, %eax
jge 0x8516
orl $0x1, %r15d
movl %r15d, 0x8(%r14)
testl %eax, %eax
je 0x85d7
movl (%r14), %eax
movl 0x4(%r14), %ecx
movl %eax, %ebx
cmpl %ecx, %eax
jge 0x8544
movslq %eax, %rdx
addq 0x18(%r14), %rdx
movl %eax, %ebx
cmpb $0xa, (%rdx)
je 0x8544
incl %ebx
incq %rdx
cmpl %ebx, %ecx
jne 0x8534
movl %ecx, %ebx
movq %r12, %rdx
subq %rbp, %rdx
movl %ebx, %ecx
subl %eax, %ecx
leal 0x1(%rcx), %eax
cltq
cmpq %rax, %rdx
jae 0x85a0
movslq %ecx, %rax
addq %rbp, %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
movq %r13, %rdi
addq %rbp, %rdi
movslq (%r14), %rax
movq 0x18(%r14), %rsi
addq %rax, %rsi
movslq %ebx, %r15
movq %r15, %rdx
subq %rax, %rdx
callq 0x2230
movslq (%r14), %rax
subq %rax, %r15
addq %r15, %rbp
leal 0x1(%rbx), %eax
movl %eax, (%r14)
cmpl 0x4(%r14), %ebx
jge 0x84d3
testq %r13, %r13
je 0x85f2
cmpq $0x2, %rbp
jb 0x860a
xorl %eax, %eax
cmpb $0xd, -0x1(%r13,%rbp)
sete %al
subq %rax, %rbp
jmp 0x860a
movl $0x1, %r12d
movl $0x1, %edi
movl $0x1, %esi
callq 0x21e0
movq %rax, %r13
movb $0x0, (%r13,%rbp)
testl %ebp, %ebp
setns %al
testb %al, %al
je 0x8890
testq %rbp, %rbp
je 0x868b
cmpb $0x3e, (%r13)
jne 0x868b
movq 0x20(%rsp), %rbx
testq %rbx, %rbx
je 0x8655
movq 0x8(%rsp), %rdi
callq 0x4b60
movq %rax, 0x20(%rbx)
movq 0x10(%rsp), %rax
movl %eax, (%rbx)
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x5264
movb (%r13), %bl
testb %bl, %bl
je 0x878d
callq 0x23a0
movq (%rax), %rcx
xorl %eax, %eax
movsbq %bl, %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x878f
movb 0x1(%r13,%rax), %bl
incq %rax
testb %bl, %bl
jne 0x866b
jmp 0x878f
cmpl $0x0, 0x4(%rsp)
je 0x86ff
cmpq $0x3, %rbp
jb 0x86e3
cmpb $0x9, 0x1(%r13)
jne 0x86e3
movq 0x20(%rsp), %rbx
testq %rbx, %rbx
je 0x86cb
movq 0x8(%rsp), %rdi
callq 0x4b60
movq %rax, 0x20(%rbx)
movq 0x10(%rsp), %rax
movl %eax, (%rbx)
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x5264
xorl %eax, %eax
movl $0x0, 0x4(%rsp)
movq $0x0, 0x20(%rsp)
jmp 0x8802
movslq %ebp, %rdx
movq 0x10(%rsp), %rax
addq %rdx, %rax
incq %rax
cmpq 0x28(%rsp), %rax
jae 0x870e
movq 0x8(%rsp), %rax
jmp 0x8757
xorl %eax, %eax
movl $0x0, 0x4(%rsp)
jmp 0x8802
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 0x8(%rsp), %rdi
movq %rsi, 0x28(%rsp)
movq %rdx, %rbx
callq 0x22b0
movq %rbx, %rdx
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rbx
leaq (%rax,%rbx), %rdi
movq %r13, %rsi
movq %rdx, %r15
callq 0x2230
addq %r15, %rbx
movq 0x8(%rsp), %rax
movq %rbx, 0x10(%rsp)
movb $0x0, (%rax,%rbx)
movl $0x1, 0x4(%rsp)
movb $0x1, %al
jmp 0x8802
xorl %eax, %eax
movb $0x0, (%r13,%rax)
movq 0x18(%rsp), %r15
movl 0x4(%r15), %edx
incl %edx
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1fd98(%rip), %rsi     # 0x28547
xorl %eax, %eax
callq 0x2320
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4bc1
movq 0x10(%r15), %rbx
movq %r15, %rdi
movslq %eax, %r15
shlq $0x6, %r15
leaq (%rbx,%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x1(%r13), %rsi
callq 0x506c
movl %eax, 0x8(%rbx,%r15)
movq $0x0, 0xc(%rbx,%r15)
movl $0x1, 0x4(%rsp)
movb $0x1, %al
movq $0x0, 0x10(%rsp)
incq 0x30(%rsp)
cmpq $0x3, %rbp
setb %cl
orb %al, %cl
jne 0x84b8
cmpb $0x9, 0x1(%r13)
jne 0x84b8
movzbl (%r13), %ecx
cmpl $0x4c, %ecx
je 0x8841
xorl %eax, %eax
cmpl $0x53, %ecx
jne 0x884e
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x7c1b
jmp 0x884e
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x7e95
testl %eax, %eax
jns 0x84b8
leaq 0x29993(%rip), %rcx     # 0x321f0
cmpl $0x0, (%rcx)
jle 0x84b8
movq 0x2978b(%rip), %rcx     # 0x31ff8
movq (%rcx), %rdi
movsbl (%r13), %edx
leaq 0x1fc1f(%rip), %rsi     # 0x2849b
movq 0x30(%rsp), %rcx
movl %eax, %r8d
xorl %eax, %eax
callq 0x2210
jmp 0x84b8
cmpl $0x0, 0x4(%rsp)
movq 0x18(%rsp), %rbx
movq 0x8(%rsp), %r15
movq 0x20(%rsp), %r12
je 0x88cc
testq %r12, %r12
je 0x88cc
movq %r15, %rdi
callq 0x4b60
movq %rax, 0x20(%r12)
movq 0x10(%rsp), %rax
movl %eax, (%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5264
movq %r15, %rdi
callq 0x2040
movq %r13, %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x6153
movq 0x18(%r14), %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
movq 0x38(%rsp), %rdi
callq 0x2030
jmp 0x8903
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq