// File: /workspace/github_c_makefile_star2_O2/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 $0x98, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
testq %rdi, %rdi
je 0x8aad
cmpb $0x2d, (%rdi)
jne 0x8a9f
cmpb $0x0, 0x1(%rdi)
je 0x8aad
leaq 0x10752(%rip), %rsi     # 0x191f8
callq 0x2380
jmp 0x8aca
movq 0x184d4(%rip), %rax     # 0x20f88
movq (%rax), %rdi
callq 0x22a0
leaq 0x10735(%rip), %rsi     # 0x191f8
movl %eax, %edi
callq 0x2140
testq %rax, %rax
je 0x8ed2
movq %rax, 0x80(%rsp)
movq %rax, %rdi
callq 0x5584
movq %rax, 0x48(%rsp)
pushq $0x1
popq %rdi
pushq $0x30
popq %rsi
callq 0x2220
movq %rax, %r15
xorl %eax, %eax
callq 0x5876
movq %rax, %r12
xorl %eax, %eax
callq 0x5876
movq %rax, 0x28(%rsp)
movq %r15, 0x8(%rsp)
movq %r12, 0x18(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x94(%rsp), %rdx
callq 0x8eea
testl %eax, %eax
js 0x8e9d
cmpq $0x0, 0x60(%rsp)
je 0x8b16
xorl %edx, %edx
movq 0x70(%rsp), %rsi
movq %rsi, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x8b55
testl %ecx, %ecx
jne 0x8b57
jmp 0x8b5c
incl %edx
incq %rax
jmp 0x8b47
movslq %edx, %rax
movq %rax, 0x88(%rsp)
xorl %ecx, %ecx
movq $0x0, 0x58(%rsp)
movl %edx, 0x44(%rsp)
movq %rsi, %rbx
movzbl (%rbx), %r13d
cmpl $0x9, %r13d
je 0x8b8c
testl %r13d, %r13d
jne 0x8d90
movb $0x0, (%rbx)
movq %rsi, %rax
testl %ecx, %ecx
movq %rbx, 0x30(%rsp)
je 0x8cf3
movq %rax, 0x38(%rsp)
movzbl (%rax), %r14d
testl %r14d, %r14d
je 0x8bb8
cmpl $0x3a, %r14d
je 0x8bb8
incq %rax
jmp 0x8b9f
movq %rcx, 0x20(%rsp)
movb $0x0, (%rax)
movq %r12, %rdi
movq %rsi, 0x10(%rsp)
leaq 0x4(%rsp), %rdx
callq 0x5c2d
cmpl $0x0, 0x4(%rsp)
movl %eax, %ebx
je 0x8c46
movslq (%r15), %r12
movq 0x8(%r15), %rbp
cmpl 0x4(%r15), %r12d
movl %r13d, (%rsp)
jne 0x8c13
leal (%r12,%r12), %eax
testl %r12d, %r12d
pushq $0x8
popq %rcx
cmovel %ecx, %eax
movl %eax, 0x4(%r15)
movslq %eax, %rsi
shlq $0x3, %rsi
movq %rbp, %rdi
callq 0x2340
movq %rax, %rbp
movq %rax, 0x8(%r15)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r13
movq 0x20(%r13), %rax
movq %r12, (%rax,%rbx,8)
callq 0x2430
leal 0x1(%r12), %ecx
movl %ecx, (%r15)
movq %rax, (%rbp,%r12,8)
movq %r13, %r12
movq 0x18(%r13), %rcx
movq %rax, (%rcx,%rbx,8)
movl (%rsp), %r13d
movq 0x58(%rsp), %rcx
movq 0x10(%rcx), %rbp
movslq 0x8(%rcx), %r15
leal 0x1(%r15), %eax
movl %eax, 0x8(%rcx)
movq 0x20(%r12), %rax
movl (%rax,%rbx,8), %eax
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
andl %ecx, %eax
movl (%rbp,%r15,8), %ecx
movl $0xf0000000, %edx       # imm = 0xF0000000
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, (%rbp,%r15,8)
andl $0x0, 0x4(%rbp,%r15,8)
cmpb $0x3a, %r14b
movq 0x30(%rsp), %rbx
jne 0x8cda
movq 0x38(%rsp), %r12
movq %rbx, %rcx
subq %r12, %rcx
cmpq $0x3, %rcx
jl 0x8cda
movzbl 0x1(%r12), %ecx
cmpl $0x66, %ecx
je 0x8d98
cmpl $0x69, %ecx
jne 0x8dc3
orl $0x10000000, %eax       # imm = 0x10000000
movl %eax, (%rbp,%r15,8)
addq $0x3, %r12
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
xorl %edx, %edx
callq 0x2270
movl %eax, 0x4(%rbp,%r15,8)
jmp 0x8cdf
movl %eax, (%rbp,%r15,8)
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %r12
movq 0x20(%rsp), %rcx
jmp 0x8d81
movl %r13d, (%rsp)
movq %rcx, %r14
movslq 0x20(%r15), %rbx
movq 0x28(%r15), %rbp
cmpl 0x24(%r15), %ebx
jne 0x8d32
leal (%rbx,%rbx), %eax
testl %ebx, %ebx
pushq $0x10
popq %rcx
cmovel %ecx, %eax
movl %eax, 0x24(%r15)
cltq
movq %rsi, %r13
imulq $0x18, %rax, %rsi
movq %rbp, %rdi
callq 0x2340
movq %r13, %rsi
movq %rax, %rbp
movq %rax, 0x28(%r15)
leal 0x1(%rbx), %eax
movl %eax, 0x20(%r15)
imulq $0x18, %rbx, %rbx
leaq (%rbx,%rbp), %rax
movq %rax, 0x58(%rsp)
movq %rsi, %rdi
callq 0x2430
movq %rax, (%rbp,%rbx)
movl 0x44(%rsp), %eax
movl %eax, 0xc(%rbp,%rbx)
andl $0x0, 0x8(%rbp,%rbx)
movq 0x88(%rsp), %rdi
pushq $0x8
popq %rsi
callq 0x2220
movq %rax, 0x10(%rbp,%rbx)
movq %r14, %rcx
movq 0x30(%rsp), %rbx
movl (%rsp), %r13d
testb %r13b, %r13b
je 0x8b16
leaq 0x1(%rbx), %rsi
incl %ecx
incq %rbx
jmp 0x8b79
orl $0x20000000, %eax       # imm = 0x20000000
movl %eax, (%rbp,%r15,8)
addq $0x3, %r12
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
callq 0x2100
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rbp,%r15,8)
jmp 0x8cdf
addq $0x3, %r12
orl $0x30000000, %eax       # imm = 0x30000000
movl %eax, (%rbp,%r15,8)
movq 0x28(%rsp), %rdi
movq %r12, %rsi
leaq 0x4(%rsp), %rdx
callq 0x5c2d
cmpl $0x0, 0x4(%rsp)
movl %eax, %edx
je 0x8e30
movq 0x8(%rsp), %rbx
movslq 0x10(%rbx), %r14
movq 0x18(%rbx), %rdi
cmpl 0x14(%rbx), %r14d
movq %rdx, 0x10(%rsp)
jne 0x8e3c
leal (%r14,%r14), %eax
testl %r14d, %r14d
pushq $0x8
popq %rcx
cmovel %ecx, %eax
movl %eax, 0x14(%rbx)
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x2340
movq 0x10(%rsp), %rdx
movq %rax, 0x50(%rsp)
movq %rax, 0x18(%rbx)
jmp 0x8e41
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %rcx
jmp 0x8e81
movq %rdi, 0x50(%rsp)
movq 0x28(%rsp), %rcx
movq 0x20(%rcx), %rax
movq %r14, (%rax,%rdx,8)
movq %r12, %rdi
movq %rcx, %r12
callq 0x2430
movq 0x10(%rsp), %rdx
leal 0x1(%r14), %ecx
movl %ecx, 0x10(%rbx)
movq 0x50(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x18(%r12), %rcx
movq %rax, (%rcx,%rdx,8)
movq 0x20(%rsp), %rcx
movq 0x30(%rsp), %rbx
movq 0x20(%r12), %rax
movl (%rax,%rdx,8), %eax
movl %eax, 0x4(%rbp,%r15,8)
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %r12
jmp 0x8d81
movq 0x70(%rsp), %rdi
callq 0x2050
movq 0x48(%rsp), %rdi
callq 0x55bd
movq 0x80(%rsp), %rdi
callq 0x2040
movq %r12, %rdi
callq 0x5881
movq 0x28(%rsp), %rdi
callq 0x5881
jmp 0x8ed5
xorl %r15d, %r15d
movq %r15, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq