// File: /workspace/github_c_makefile_star2_O1/lh3[P]bgt/bgt.c
// Function: bgt_parse_fields
kexpr_t **bgt_parse_fields(const char *str, int *_n)
{
	int m = 0, n = 0, n_par = 0, i;
	char **s = 0;
	const char *q, *p;
	kexpr_t **e = 0;
	*_n = 0;
	for (q = p = str;; ++p) {
		if (*p == '(') ++n_par;
		else if (*p == ')') --n_par;
		else if (*p == 0 || (*p == ',' && n_par == 0)) {
			if (m == n) {
				m = m? m<<1 : 16;
				s = (char**)realloc(s, m * sizeof(void*));
			}
			s[n] = (char*)calloc(p - q + 1, 1);
			strncpy(s[n++], q, p - q);
			q = p + 1;
			if (*p == 0) break;
		}
	}
	if (n_par == 0) {
		e = (kexpr_t**)calloc(n, sizeof(kexpr_t*));
		for (i = m = 0; i < n; ++i) {
			int err, j;
			e[i] = ke_parse(s[i], &err);
			if (err) {
				for (j = 0; j <= i; ++j)
					ke_destroy(e[j]);
				break;
			}
		}
		if (i < n) {
			free(e);
			e = 0, *_n = 0;
		} else *_n = n;
	}
	for (i = 0; i < n; ++i) free(s[i]);
	free(s);
	return e;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r15
movq %rsi, 0x30(%rsp)
movl $0x0, (%rsi)
leaq 0x1(%rdi), %r12
xorl %esi, %esi
xorl %ebp, %ebp
xorl %edx, %edx
movq $0x0, 0x10(%rsp)
movq %rdi, %rbx
movzbl -0x1(%r12), %eax
testl %eax, %eax
je 0x18205
cmpl $0x29, %eax
je 0x181e9
cmpl $0x28, %eax
jne 0x181f0
incl %edx
jmp 0x18290
decl %edx
jmp 0x18290
cmpb $0x2c, %al
sete %al
testl %edx, %edx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x18290
movl %edx, 0x18(%rsp)
cmpl %ebp, %esi
jne 0x1823d
movq %rbp, %r13
leal (%rsi,%rsi), %ebp
testl %esi, %esi
movl $0x10, %eax
cmovel %eax, %ebp
movslq %ebp, %rsi
shlq $0x3, %rsi
movq 0x10(%rsp), %rdi
callq 0x2330
movq %rax, %r14
movl %ebp, %eax
movq %rax, 0x8(%rsp)
movq %r13, %rbp
jmp 0x18247
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %r14
movq %r15, %r13
subq %rbx, %r13
leaq 0x1(%r13), %rdi
movl $0x1, %esi
callq 0x2220
movslq %ebp, %rcx
movq %r14, 0x10(%rsp)
movq %rax, (%r14,%rcx,8)
leal 0x1(%rbp), %r14d
movq %rax, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2080
cmpb $0x0, -0x1(%r12)
je 0x1829b
movl %r14d, %ebp
movq %r12, %rbx
movl 0x18(%rsp), %edx
movq 0x8(%rsp), %rsi
incq %r12
incq %r15
jmp 0x181ce
movq %rbp, 0x8(%rsp)
cmpl $0x0, 0x18(%rsp)
je 0x182b4
xorl %r15d, %r15d
movq 0x10(%rsp), %rbp
jmp 0x18346
movslq %r14d, %rdi
movl $0x8, %esi
callq 0x2220
movq %rax, %r15
movq 0x8(%rsp), %rax
testl %eax, %eax
movq 0x10(%rsp), %rbp
js 0x1833e
movq %r14, 0x28(%rsp)
incl %eax
movq %rax, 0x18(%rsp)
movl $0x1, %r14d
xorl %r13d, %r13d
movq (%rbp,%r13,8), %rdi
leaq 0x24(%rsp), %rsi
callq 0x1b574
movq %rax, (%r15,%r13,8)
movl 0x24(%rsp), %r12d
testl %r12d, %r12d
je 0x1831c
xorl %ebx, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x1ced4
incq %rbx
cmpq %rbx, %r14
jne 0x18306
testl %r12d, %r12d
jne 0x18330
incq %r13
incq %r14
cmpq 0x18(%rsp), %r13
jne 0x182e7
movq 0x28(%rsp), %r14
jmp 0x1833e
movq %r15, %rdi
callq 0x2050
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x30(%rsp), %rax
movl %r14d, (%rax)
movq 0x8(%rsp), %r14
testl %r14d, %r14d
js 0x18367
incl %r14d
xorl %ebx, %ebx
movq (%rbp,%rbx,8), %rdi
callq 0x2050
incq %rbx
cmpq %rbx, %r14
jne 0x18355
movq %rbp, %rdi
callq 0x2050
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq