// File: /workspace/github_c_makefile_star2_O3/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, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
testq %rdi, %rdi
je 0x9cdc
cmpb $0x2d, (%rdi)
jne 0x9cce
cmpb $0x0, 0x1(%rdi)
je 0x9cdc
leaq 0x15573(%rip), %rsi     # 0x1f248
callq 0x2370
jmp 0x9cf9
movq 0x1c2a5(%rip), %rax     # 0x25f88
movq (%rax), %rdi
callq 0x22a0
leaq 0x15556(%rip), %rsi     # 0x1f248
movl %eax, %edi
callq 0x2140
testq %rax, %rax
je 0xa13a
movq %rax, 0x78(%rsp)
movq %rax, %rdi
callq 0x5c48
movq %rax, %rbx
movl $0x1, %edi
movl $0x30, %esi
callq 0x2220
movq %rax, %r13
xorl %eax, %eax
callq 0x5f54
movq %rax, %r12
xorl %eax, %eax
callq 0x5f54
movq %rax, 0x20(%rsp)
leaq 0x60(%rsp), %rdx
leaq 0x44(%rsp), %rcx
movq %rbx, 0x48(%rsp)
movq %rbx, %rdi
movl $0x2, %esi
xorl %r8d, %r8d
callq 0x5ca1
testl %eax, %eax
js 0xa108
movq %r13, 0x8(%rsp)
movq %r12, 0x10(%rsp)
cmpq $0x0, 0x60(%rsp)
je 0xa0e4
xorl %ebx, %ebx
movq 0x70(%rsp), %rsi
movq %rsi, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x9d8f
testl %ecx, %ecx
jne 0x9d91
jmp 0x9d96
incl %ebx
incq %rax
jmp 0x9d81
movslq %ebx, %rax
movq %rax, 0x80(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x58(%rsp)
movq %rsi, %r15
movl %ebx, 0x1c(%rsp)
movzbl (%r15), %ecx
cmpl $0x9, %ecx
je 0x9dc4
testl %ecx, %ecx
jne 0x9fd1
movq %r15, 0x30(%rsp)
movb $0x0, (%r15)
movq %rsi, %rax
testl %ebp, %ebp
movl %ecx, (%rsp)
je 0x9e87
movq %rax, 0x38(%rsp)
movzbl (%rax), %r15d
testl %r15d, %r15d
je 0x9df4
cmpl $0x3a, %r15d
je 0x9df4
incq %rax
jmp 0x9ddb
movq %rbp, 0x28(%rsp)
movb $0x0, (%rax)
movq %r12, %rdi
movq %r12, %r14
movq %rsi, %r12
leaq 0x4(%rsp), %rdx
callq 0x6320
cmpl $0x0, 0x4(%rsp)
movl %eax, %ebp
je 0x9f11
movslq (%r13), %r14
movq 0x8(%r13), %rbx
cmpl 0x4(%r13), %r14d
jne 0x9e53
leal (%r14,%r14), %eax
testl %r14d, %r14d
movl $0x8, %ecx
cmovel %ecx, %eax
movl %eax, 0x4(%r13)
movslq %eax, %rsi
shlq $0x3, %rsi
movq %rbx, %rdi
callq 0x2330
movq %rax, %rbx
movq %rax, 0x8(%r13)
movq %r12, %rdi
movq 0x10(%rsp), %r12
movq 0x20(%r12), %rax
movq %r14, (%rax,%rbp,8)
callq 0x2420
leal 0x1(%r14), %ecx
movl %ecx, (%r13)
movq %rax, (%rbx,%r14,8)
movq 0x18(%r12), %rcx
movq %rax, (%rcx,%rbp,8)
movl 0x1c(%rsp), %ebx
jmp 0x9f14
movslq 0x20(%r13), %r14
movq 0x28(%r13), %rax
cmpl 0x24(%r13), %r14d
jne 0x9ec5
leal (%r14,%r14), %ecx
testl %r14d, %r14d
movl $0x10, %edx
cmovel %edx, %ecx
movl %ecx, 0x24(%r13)
movslq %ecx, %rcx
shlq $0x3, %rcx
movq %rsi, %r15
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0x2330
movq %r15, %rsi
movq %rax, 0x28(%r13)
leal 0x1(%r14), %ecx
movl %ecx, 0x20(%r13)
leaq (%r14,%r14,2), %rcx
leaq (%rax,%rcx,8), %r14
movq %rsi, %rdi
callq 0x2420
movq %rax, (%r14)
movl %ebx, 0xc(%r14)
movl $0x0, 0x8(%r14)
movl $0x8, %esi
movq 0x80(%rsp), %rdi
callq 0x2220
movq %r14, 0x58(%rsp)
movq %rax, 0x10(%r14)
movq 0x30(%rsp), %r15
jmp 0x9fc0
movq %r14, %r12
movq 0x58(%rsp), %rcx
movq 0x10(%rcx), %r13
movslq 0x8(%rcx), %r14
leal 0x1(%r14), %eax
movl %eax, 0x8(%rcx)
movq 0x20(%r12), %rax
movl (%rax,%rbp,8), %eax
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
andl %ecx, %eax
movl (%r13,%r14,8), %ecx
movl $0xf0000000, %edx       # imm = 0xF0000000
andl %edx, %ecx
orl %eax, %ecx
movl %ecx, (%r13,%r14,8)
movl $0x0, 0x4(%r13,%r14,8)
cmpb $0x3a, %r15b
movq 0x30(%rsp), %r15
jne 0x9fac
movq 0x38(%rsp), %r12
movq %r15, %rcx
subq %r12, %rcx
cmpq $0x3, %rcx
jl 0x9fac
movzbl 0x1(%r12), %ecx
cmpl $0x66, %ecx
movq 0x28(%rsp), %rbp
je 0x9fd9
cmpl $0x69, %ecx
jne 0xa00b
orl $0x10000000, %eax       # imm = 0x10000000
movl %eax, (%r13,%r14,8)
addq $0x3, %r12
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
xorl %edx, %edx
callq 0x2270
movl %eax, 0x4(%r13,%r14,8)
jmp 0x9fff
movl %eax, (%r13,%r14,8)
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %r12
movq 0x28(%rsp), %rbp
movl (%rsp), %ecx
testb %cl, %cl
je 0xa0e4
leaq 0x1(%r15), %rsi
incl %ebp
incq %r15
jmp 0x9db3
orl $0x20000000, %eax       # imm = 0x20000000
movl %eax, (%r13,%r14,8)
addq $0x3, %r12
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
callq 0x2100
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%r13,%r14,8)
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %r12
jmp 0x9fc0
addq $0x3, %r12
orl $0x30000000, %eax       # imm = 0x30000000
movl %eax, (%r13,%r14,8)
movq 0x20(%rsp), %rdi
movq %r12, %rsi
leaq 0x4(%rsp), %rdx
callq 0x6320
cmpl $0x0, 0x4(%rsp)
movl %eax, %edx
je 0xa079
movq 0x8(%rsp), %r15
movslq 0x10(%r15), %rbp
movq 0x18(%r15), %rdi
cmpl 0x14(%r15), %ebp
jne 0xa080
leal (,%rbp,2), %eax
testl %ebp, %ebp
movl $0x8, %ecx
cmovel %ecx, %eax
movl %eax, 0x14(%r15)
movslq %eax, %rsi
shlq $0x3, %rsi
movq %rdx, %rbx
callq 0x2330
movq %rbx, %rdx
movq %rax, 0x50(%rsp)
movq %rax, 0x18(%r15)
jmp 0xa085
movq 0x20(%rsp), %rbx
jmp 0xa0c2
movq %rdi, 0x50(%rsp)
movq 0x20(%rsp), %rbx
movq 0x20(%rbx), %rax
movq %rbp, (%rax,%rdx,8)
movq %r12, %rdi
movq %rdx, %r12
callq 0x2420
movq %r12, %rdx
leal 0x1(%rbp), %ecx
movl %ecx, 0x10(%r15)
movq 0x50(%rsp), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0x18(%rbx), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x28(%rsp), %rbp
movq 0x30(%rsp), %r15
movl (%rsp), %ecx
movq 0x20(%rbx), %rax
movl (%rax,%rdx,8), %eax
movl %eax, 0x4(%r13,%r14,8)
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %r12
movl 0x1c(%rsp), %ebx
jmp 0x9fc3
movq 0x48(%rsp), %rdi
movl $0x2, %esi
leaq 0x60(%rsp), %rdx
leaq 0x44(%rsp), %rcx
xorl %r8d, %r8d
callq 0x5ca1
testl %eax, %eax
jns 0x9d6b
movq 0x70(%rsp), %rdi
callq 0x2050
movq 0x48(%rsp), %rdi
callq 0x5c85
movq 0x78(%rsp), %rdi
callq 0x2040
movq %r12, %rdi
callq 0x5f63
movq 0x20(%rsp), %rdi
callq 0x5f63
jmp 0xa13d
xorl %r13d, %r13d
movq %r13, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq