// File: /workspace/github_c_makefile_star2_O3/esheldon[P]xshear/src/config.c
// Function: cfg_parse
static struct cfg *cfg_parse(const struct cfg_string *str, size_t *current, enum cfg_status *status) 
{
    struct cfg *cfg=NULL;
    //int beg_found=0;

    struct cfg_field *field=NULL;
    size_t end=0;
    if (!str) {
        *status = CFG_READ_ERROR;
        goto _cfg_parse_bail;
    }

    // beginning { is optional for overall config, but not sub-configs
    if (CFG_CFG_BEG == str->data[*current]) {
        (*current) += 1;
    }
    cfg = cfg_new();
    while (1) {
        *current = find_nonwhite(str, *current, status);
        if (*status) { // EOF OK here
            *status=CFG_SUCCESS;
            break;
        }
        if (str->data[*current] == CFG_CFG_END) {
            break;
        }

        field=cfg_get_field(str, (*current), &end, status);
        if (CFG_FOUND_END == (*status)) {
            // just found end of config, break out
            *status=CFG_SUCCESS;
            break;
        }
        if (*status) {
            // an error occured
            break;
        }
        if (!field) {
            // probably natural end of file found
            break;
        }


        cfg_append(cfg,field);

        if (str->data[end] == CFG_CFG_END) {
            *current = end;
            break;
        }

        // skip past either the last letter, end quote, end array delim, etc.
        (*current) = end+1;
    }

_cfg_parse_bail:
    if (*status) {
        cfg=cfg_free(cfg);
    }
    return cfg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r12
movq 0x8(%rdi), %rax
movq (%rsi), %r15
cmpb $0x7b, (%rax,%r15)
jne 0x6aca
incq %r15
movq %r15, (%r13)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2170
testq %rax, %rax
je 0x6f53
movq %rax, %rbx
movl $0x1, %eax
movq %rax, 0x20(%rsp)
movl $0x1, %edi
movl $0x8, %esi
callq 0x2170
movq %rax, 0x10(%rsp)
movq %rax, 0x10(%rbx)
movq $0x1, 0x8(%rbx)
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x740e
movq %rax, (%r13)
cmpl $0x0, (%r14)
je 0x6b33
movl $0x0, (%r14)
jmp 0x6eff
xorl %r15d, %r15d
xorl %ebp, %ebp
movq %rbx, 0x8(%rsp)
movq %r13, 0x28(%rsp)
movq 0x8(%r12), %rcx
cmpb $0x7d, (%rcx,%rax)
je 0x6eff
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x740e
movq %rax, %r13
movl (%r14), %eax
testl %eax, %eax
movq %r15, 0x18(%rsp)
je 0x6b7f
cmpl $0x6, %eax
je 0x6ef3
xorl %r15d, %r15d
jmp 0x6c26
movl $0x6, (%r14)
movq (%r12), %rcx
cmpq %r13, %rcx
jbe 0x6ef3
movq 0x8(%r12), %rbp
movq %r13, %rax
subq %rcx, %rax
movq %rbp, %rcx
xorl %ebx, %ebx
cmpb $0x3d, (%rcx,%r13)
je 0x6bba
decq %rbx
incq %rcx
cmpq %rbx, %rax
jne 0x6ba3
jmp 0x6ef3
movl $0x0, (%r14)
movl $0x1, %edi
subq %rbx, %rdi
movl $0x1, %esi
callq 0x2170
testq %rax, %rax
je 0x6f67
movq %rax, %r15
movq %rbx, %rdx
negq %rdx
addq %r13, %rbp
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2040
testq %rbx, %rbx
je 0x6c23
subq %rbx, %r13
callq 0x22c0
movq (%rax), %rax
xorl %ecx, %ecx
movsbq (%r15,%rcx), %rdx
testb $0x20, 0x1(%rax,%rdx,2)
jne 0x6c1e
incq %rcx
movq %rbx, %rdx
addq %rcx, %rdx
jne 0x6c05
jmp 0x6c23
movb $0x0, (%r15,%rcx)
movq %r13, %rbp
movl $0x1, %edi
movl $0x20, %esi
callq 0x2170
testq %rax, %rax
je 0x6f62
movq %rax, %r13
movl $0x1, %edi
movl $0x18, %esi
callq 0x2170
testq %rax, %rax
je 0x6f5d
movq %rax, %rbx
movl $0x1, %edi
movl $0x8, %esi
callq 0x2170
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x6f58
movq $0x1, 0x8(%rbx)
movq %rbx, 0x10(%r13)
movq %r15, (%r13)
incq %rbp
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x740e
movq %rax, 0x30(%rsp)
movl (%r14), %ecx
testl %ecx, %ecx
jne 0x6f35
movq 0x8(%r12), %rcx
movzbl (%rcx,%rax), %ecx
cmpl $0x7a, %ecx
jg 0x6d00
cmpl $0x22, %ecx
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r15
je 0x6d38
cmpl $0x5b, %ecx
jne 0x6d62
movabsq $0x200000001, %rcx      # imm = 0x200000001
movq %rcx, 0x8(%r13)
incq %rax
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x740e
movq %rax, %rbp
cmpl $0x0, (%r14)
jne 0x6e34
jmp 0x6d8c
cmpl $0x7b, %ecx
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r15
jne 0x6d59
movl $0x2, 0x8(%r13)
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
movq %r14, %rdx
callq 0x6a9e
movq %rax, 0x18(%r13)
movq 0x30(%rsp), %rbp
incq %rbp
jmp 0x6e3c
movabsq $0x100000000, %rcx      # imm = 0x100000000
movq %rcx, 0x8(%r13)
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x7498
jmp 0x6d7b
cmpl $0x7d, %ecx
je 0x6f23
movq $0x0, 0x8(%r13)
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x7579
movq %rax, %rbp
jmp 0x6e3c
movl $0x0, (%r14)
jmp 0x6e09
movq 0x8(%r12), %rax
movzbl (%rax,%rbp), %ecx
cmpl $0x2b, %ecx
jg 0x6dc4
cmpl $0x22, %ecx
je 0x6de4
cmpl $0x23, %ecx
jne 0x6dce
movl $0x6, (%r14)
movq (%r12), %rcx
cmpq %rbp, %rcx
jbe 0x6e26
cmpb $0xa, (%rax,%rbp)
je 0x6d83
incq %rbp
cmpq %rbp, %rcx
jne 0x6db4
jmp 0x6e26
cmpl $0x2c, %ecx
je 0x6e06
cmpl $0x5d, %ecx
je 0x6e2d
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x7579
movq %rax, %rbp
jmp 0x6e09
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x7498
movq %rax, %rbp
cmpl $0x0, (%r14)
jne 0x6e2d
movl $0x1, 0xc(%r13)
incq %rbp
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x740e
movq %rax, %rbp
cmpl $0x0, (%r14)
je 0x6d8c
jmp 0x6e2d
movq $-0x1, %rbp
cmpl $0x1, 0xc(%r13)
je 0x6e3c
movl $0x0, 0xc(%r13)
cmpl $0x0, (%r14)
movq 0x10(%rsp), %rdi
jne 0x6f2a
cmpq %rbx, %r15
jne 0x6ea0
testq %rbx, %rbx
jle 0x6ea0
movq %rbx, %rsi
shlq $0x4, %rsi
callq 0x2230
movq 0x8(%rsp), %r15
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x6f6c
movq %rbx, %rdx
addq %rbx, %rbx
leaq (%rax,%rdx,8), %rdi
shlq $0x3, %rdx
xorl %esi, %esi
movq %rax, 0x10(%rsp)
callq 0x2120
movq 0x10(%rsp), %rdi
movq %rbx, 0x8(%r15)
movq %rbx, 0x20(%rsp)
movq 0x18(%rsp), %r15
leaq 0x1(%r15), %rbx
movq 0x8(%rsp), %rax
movq %rbx, (%rax)
movq %r13, (%rdi,%r15,8)
movq 0x8(%r12), %rax
cmpb $0x7d, (%rax,%rbp)
je 0x6f11
movq %rdi, 0x10(%rsp)
leaq 0x1(%rbp), %rsi
movq 0x28(%rsp), %r13
movq %rsi, (%r13)
movq %r12, %rdi
movq %r14, %rdx
callq 0x740e
movq %rax, (%r13)
cmpl $0x0, (%r14)
movq %rbx, %r15
movq 0x8(%rsp), %rbx
je 0x6b42
jmp 0x6b27
movl $0x0, (%r14)
movq 0x8(%rsp), %rbx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %rax
movq %rbp, (%rax)
movl (%r14), %ecx
movq 0x8(%rsp), %rbx
jmp 0x6f43
movl $0x1, (%r14)
movq %r13, %rdi
callq 0x676c
movl (%r14), %ecx
cmpl $0x1, %ecx
movq 0x8(%rsp), %rbx
je 0x6b27
testl %ecx, %ecx
je 0x6eff
movq %rbx, %rdi
callq 0x670e
xorl %ebx, %ebx
jmp 0x6eff
callq 0x37b8
callq 0x3749
callq 0x376e
callq 0x3793
callq 0x36ff
callq 0x3724