// File: /workspace/github_c_makefile_star2_O1/lh3[P]bgt/fmf.c
// Function: fmf_read
fmf_t *fmf_read(const char *fn)
{
	kstream_t *ks;
	gzFile fp;
	fmf_t *fmf = 0;
	kstring_t s = {0,0,0};
	int dret;
	khash_t(s2i) *kh, *vh;

	fp = fn && strcmp(fn, "-")? gzopen(fn, "r") : gzdopen(fileno(stdin), "r");
	if (fp == 0) return 0;
	ks = ks_init(fp);
	fmf = (fmf_t*)calloc(1, sizeof(fmf_t));
	kh = kh_init(s2i);
	vh = kh_init(s2i);
	while (ks_getuntil(ks, KS_SEP_LINE, &s, &dret) >= 0) {
		char *p, *q, *r;
		int i, absent, n_meta;
		khint_t k;
		fmf1_t *u = 0;
		if (s.l == 0) continue;
		for (p = s.s, n_meta = 0; *p; ++p)
			if (*p == '\t') ++n_meta;
		for (p = q = s.s, i = 0;; ++p) {
			if (*p == 0 || *p == '\t') {
				int c = *p, c2;
				*p = 0;
				if (i == 0) { // row name
					if (fmf->n_rows == fmf->m_rows) {
						fmf->m_rows = fmf->m_rows? fmf->m_rows<<1 : 16;
						fmf->rows = (fmf1_t*)realloc(fmf->rows, fmf->m_rows * sizeof(fmf1_t));
					}
					u = &fmf->rows[fmf->n_rows++];
					u->name = strdup(q);
					u->m_meta = n_meta, u->n_meta = 0;
					u->meta = (fmf_meta_t*)calloc(u->m_meta, sizeof(fmf_meta_t));
				} else { // metadata
					fmf_meta_t *m;
					for (r = q; *r && *r != ':'; ++r);
					c2 = *r; *r = 0;
					k = kh_put(s2i, kh, q, &absent);
					if (absent) {
						if (fmf->n_keys == fmf->m_keys) {
							fmf->m_keys = fmf->m_keys? fmf->m_keys<<1 : 8;
							fmf->keys = (char**)realloc(fmf->keys, fmf->m_keys * sizeof(char*));
						}
						kh_val(kh, k) = fmf->n_keys;
						kh_key(kh, k) = fmf->keys[fmf->n_keys++] = strdup(q);
					}
					m = &u->meta[u->n_meta++];
					m->key = kh_val(kh, k), m->v.i = 0;
					if (c2 == ':' && p - r >= 3) {
						if (r[1] == 'i') m->type = FMF_INT, m->v.i = strtol(r + 3, &r, 0);
						else if (r[1] == 'f') m->type = FMF_REAL, m->v.r = strtod(r + 3, &r);
						else {
							char *s = r + 3;
							m->type = FMF_STR;
							k = kh_put(s2i, vh, s, &absent);
							if (absent) {
								if (fmf->n_vals == fmf->m_vals) {
									fmf->m_vals = fmf->m_vals? fmf->m_vals<<1 : 8;
									fmf->vals = (char**)realloc(fmf->vals, fmf->m_vals * sizeof(char*));
								}
								kh_val(vh, k) = fmf->n_vals;
								kh_key(vh, k) = fmf->vals[fmf->n_vals++] = strdup(s);
							}
							m->v.s = kh_val(vh, k);
						}
					} else m->type = FMF_FLAG;
				}
				q = p + 1; ++i;
				if (c == 0) break; // end-of-line
			}
		}
	}
	free(s.s);
	ks_destroy(ks);
	gzclose(fp);
	kh_destroy(s2i, kh);
	kh_destroy(s2i, vh);
	return fmf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
testq %rdi, %rdi
je 0x9a53
movq %rdi, %rbx
leaq 0x14a7b(%rip), %rsi     # 0x1e4b4
callq 0x2230
testl %eax, %eax
je 0x9a53
leaq 0x157f2(%rip), %rsi     # 0x1f23b
movq %rbx, %rdi
callq 0x2370
jmp 0x9a70
movq 0x1c52e(%rip), %rax     # 0x25f88
movq (%rax), %rdi
callq 0x22a0
leaq 0x157d2(%rip), %rsi     # 0x1f23b
movl %eax, %edi
callq 0x2140
testq %rax, %rax
je 0x9eaa
movq %rax, 0x70(%rsp)
movq %rax, %rdi
callq 0x5b18
movq %rax, %rbx
movl $0x1, %edi
movl $0x30, %esi
callq 0x2220
movq %rax, %r14
xorl %eax, %eax
callq 0x5e1f
movq %rax, %r12
xorl %eax, %eax
callq 0x5e1f
movq %rax, %r15
leaq 0x50(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
movq %rbx, 0x40(%rsp)
movq %rbx, %rdi
movl $0x2, %esi
xorl %r8d, %r8d
callq 0x5b79
testl %eax, %eax
js 0x9e77
movq %r12, 0x18(%rsp)
movq %r14, 0x8(%rsp)
movq %r15, 0x10(%rsp)
cmpq $0x0, 0x50(%rsp)
movq %r14, %rsi
je 0x9e50
xorl %edx, %edx
movq 0x60(%rsp), %r8
movq %r8, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x9b0c
testl %ecx, %ecx
jne 0x9b0e
jmp 0x9b13
incl %edx
incq %rax
jmp 0x9afe
movl %edx, 0x34(%rsp)
movslq %edx, %rax
movq %rax, 0x78(%rsp)
xorl %ecx, %ecx
movq $0x0, 0x48(%rsp)
movq %r8, %rbx
movzbl (%rbx), %eax
cmpl $0x9, %eax
je 0x9b3d
testl %eax, %eax
jne 0x9d4c
movl %eax, 0x38(%rsp)
movb $0x0, (%rbx)
movq %r8, %rax
testl %ecx, %ecx
movq %rsi, %rbp
movq %rcx, 0x80(%rsp)
je 0x9cad
movq %rax, 0x28(%rsp)
movzbl (%rax), %r13d
testl %r13d, %r13d
je 0x9b73
cmpl $0x3a, %r13d
je 0x9b73
incq %rax
jmp 0x9b5a
movb $0x0, (%rax)
movq %r12, %rdi
movq %r8, 0x20(%rsp)
movq %r8, %rsi
leaq 0x4(%rsp), %rdx
callq 0x61f9
cmpl $0x0, 0x4(%rsp)
movl %eax, %r15d
je 0x9bf8
movq %rbp, %rsi
movslq (%rbp), %r14
movl 0x4(%rbp), %eax
cmpl %eax, %r14d
jne 0x9bc8
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x8, %eax
cmovel %eax, %ecx
movl %ecx, 0x4(%rsi)
movq 0x8(%rsi), %rdi
movslq %ecx, %rsi
shlq $0x3, %rsi
callq 0x2330
movq %rax, 0x8(%rbp)
movq 0x18(%rsp), %r12
movq 0x20(%r12), %rax
movq %r14, (%rax,%r15,8)
movq 0x20(%rsp), %rdi
callq 0x2420
movq 0x8(%rbp), %rcx
leal 0x1(%r14), %edx
movl %edx, (%rbp)
movq %rax, (%rcx,%r14,8)
movq 0x18(%r12), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x48(%rsp), %rcx
movq 0x10(%rcx), %rbp
movslq 0x8(%rcx), %r14
leal 0x1(%r14), %eax
movl %eax, 0x8(%rcx)
movq 0x20(%r12), %rax
movl (%rax,%r15,8), %eax
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
andl %ecx, %eax
movl (%rbp,%r14,8), %ecx
movl $0xf0000000, %edx       # imm = 0xF0000000
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, (%rbp,%r14,8)
movl $0x0, 0x4(%rbp,%r14,8)
cmpb $0x3a, %r13b
jne 0x9c94
movq 0x28(%rsp), %r15
movq %rbx, %rcx
subq %r15, %rcx
cmpq $0x3, %rcx
jl 0x9c94
movzbl 0x1(%r15), %ecx
cmpl $0x66, %ecx
je 0x9d54
cmpl $0x69, %ecx
movq 0x18(%rsp), %r12
jne 0x9d7f
orl $0x10000000, %eax       # imm = 0x10000000
movl %eax, (%rbp,%r14,8)
addq $0x3, %r15
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x2270
movl %eax, 0x4(%rbp,%r14,8)
movq 0x8(%rsp), %rsi
jmp 0x9ca3
movl %eax, (%rbp,%r14,8)
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %r15
jmp 0x9d33
movslq 0x20(%rsi), %r14
movl 0x24(%rsi), %eax
cmpl %eax, %r14d
jne 0x9cea
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, 0x24(%rsi)
movq 0x28(%rsi), %rdi
movslq %ecx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
movq %r8, %r13
callq 0x2330
movq %r13, %r8
movq %rbp, %rsi
movq %rax, 0x28(%rbp)
movq 0x28(%rsi), %rax
leal 0x1(%r14), %ecx
movl %ecx, 0x20(%rsi)
leaq (%r14,%r14,2), %rcx
leaq (%rax,%rcx,8), %r14
movq %r8, %rdi
callq 0x2420
movq %rax, (%r14)
movl 0x34(%rsp), %eax
movl %eax, 0xc(%r14)
movl $0x0, 0x8(%r14)
movl $0x8, %esi
movq 0x78(%rsp), %rdi
callq 0x2220
movq %rbp, %rsi
movq %r14, 0x48(%rsp)
movq %rax, 0x10(%r14)
cmpb $0x0, 0x38(%rsp)
movq 0x80(%rsp), %rcx
je 0x9e50
leaq 0x1(%rbx), %r8
incl %ecx
incq %rbx
jmp 0x9b2d
orl $0x20000000, %eax       # imm = 0x20000000
movl %eax, (%rbp,%r14,8)
addq $0x3, %r15
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x2100
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rbp,%r14,8)
jmp 0x9c99
addq $0x3, %r15
orl $0x30000000, %eax       # imm = 0x30000000
movl %eax, (%rbp,%r14,8)
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
leaq 0x4(%rsp), %rdx
callq 0x61f9
cmpl $0x0, 0x4(%rsp)
movl %eax, %ecx
je 0x9e37
movq 0x8(%rsp), %r12
movslq 0x10(%r12), %rdx
movl 0x14(%r12), %eax
movq %rdx, 0x20(%rsp)
cmpl %eax, %edx
jne 0x9df5
movq %rcx, %r13
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x8, %eax
cmovel %eax, %ecx
movl %ecx, 0x14(%r12)
movq 0x18(%r12), %rdi
movslq %ecx, %rsi
shlq $0x3, %rsi
callq 0x2330
movq %r13, %rcx
movq %rax, 0x18(%r12)
movq 0x10(%rsp), %r13
movq 0x20(%r13), %rax
movq 0x20(%rsp), %r12
movq %r12, (%rax,%rcx,8)
movq %r15, %rdi
movq %rcx, %r15
callq 0x2420
movq 0x8(%rsp), %rsi
movq 0x18(%rsi), %rcx
leal 0x1(%r12), %edx
movl %edx, 0x10(%rsi)
movq %rax, (%rcx,%r12,8)
movq 0x18(%r13), %rcx
movq %rax, (%rcx,%r15,8)
movq %r15, %rcx
movq 0x18(%rsp), %r12
movq 0x20(%r13), %rax
movl (%rax,%rcx,8), %eax
movl %eax, 0x4(%rbp,%r14,8)
movq 0x8(%rsp), %rsi
movq %r13, %r15
jmp 0x9d33
movq %rsi, %r14
movq 0x40(%rsp), %rdi
movl $0x2, %esi
leaq 0x50(%rsp), %rdx
leaq 0x3c(%rsp), %rcx
xorl %r8d, %r8d
callq 0x5b79
testl %eax, %eax
jns 0x9ae5
movq 0x60(%rsp), %rdi
callq 0x2050
movq 0x40(%rsp), %rdi
callq 0x5b5d
movq 0x70(%rsp), %rdi
callq 0x2040
movq %r12, %rdi
callq 0x5e2e
movq %r15, %rdi
callq 0x5e2e
movq %r14, %rax
jmp 0x9eac
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq