// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdx, %rbx
movq %rdi, %r15
movq 0x8(%rdi), %rcx
movq %rsi, 0x10(%rsp)
movq (%rsi), %rax
cmpb $0x7b, (%rcx,%rax)
jne 0x69bf
incq %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movl $0x1, %edi
movl $0x18, %esi
callq 0x2170
testq %rax, %rax
je 0x6e2c
movq %rax, %rbp
movl $0x1, %edi
movl $0x8, %esi
callq 0x2170
movq %rax, 0x10(%rbp)
movq $0x1, 0x8(%rbp)
movq 0x10(%rsp), %r14
movq (%r14), %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x731c
movq %rax, (%r14)
cmpl $0x0, (%rbx)
je 0x6a37
movl $0x0, (%rbx)
cmpl $0x0, (%rbx)
je 0x6a25
movq %rbp, %rdi
callq 0x65e2
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
movq %rbp, 0x8(%rsp)
movq %r15, 0x20(%rsp)
movq 0x8(%r15), %rcx
cmpb $0x7d, (%rcx,%rax)
je 0x6a16
movq %rax, 0x18(%rsp)
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x731c
cmpl $0x0, (%rbx)
je 0x6a6b
xorl %r13d, %r13d
jmp 0x6aae
movq %rax, %r13
movl $0x6, (%rbx)
movq (%r15), %rcx
cmpq %rax, %rcx
jbe 0x6a91
movq 0x8(%r15), %rdx
movq %r13, %rax
cmpb $0x3d, (%rdx,%rax)
je 0x6a9a
incq %rax
cmpq %rax, %rcx
jne 0x6a83
movq $-0x1, %rax
jmp 0x6aa0
movl $0x0, (%rbx)
cmpl $0x0, (%rbx)
jne 0x6aae
movl $0x0, (%rbx)
movq %rax, %r12
movl (%rbx), %r14d
testl %r14d, %r14d
je 0x6abb
xorl %r15d, %r15d
jmp 0x6b21
movq %r12, %rbp
subq %r13, %rbp
leaq 0x1(%rbp), %rdi
movl $0x1, %esi
callq 0x2170
testq %rax, %rax
je 0x6e31
movq %rax, %r15
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rsi
addq %r13, %rsi
movq %r15, %rdi
movq %rbp, %rdx
callq 0x2040
cmpq %r13, %r12
je 0x6b1c
callq 0x22c0
movq (%rax), %rax
xorl %ecx, %ecx
movsbq (%r15,%rcx), %rdx
testb $0x20, 0x1(%rax,%rdx,2)
jne 0x6b17
incq %rcx
cmpq %rcx, %rbp
jne 0x6b01
jmp 0x6b1c
movb $0x0, (%r15,%rcx)
movq 0x8(%rsp), %rbp
cmpl $0x6, %r14d
jne 0x6b49
movl $0x0, (%rbx)
xorl %r13d, %r13d
cmpl $0x0, (%rbx)
je 0x6bdb
movq %r13, %rdi
callq 0x6642
xorl %r13d, %r13d
jmp 0x6bdb
movl $0x1, %edi
movl $0x20, %esi
callq 0x2170
testq %rax, %rax
je 0x6e27
movq %rax, %r13
movl $0x1, %edi
movl $0x18, %esi
callq 0x2170
testq %rax, %rax
je 0x6e22
movq %rax, %rbp
movl $0x1, %edi
movl $0x8, %esi
callq 0x2170
movq %rax, 0x10(%rbp)
testq %rax, %rax
je 0x6e1d
movq $0x1, 0x8(%rbp)
movq %rbp, 0x10(%r13)
movq %r15, (%r13)
leaq 0x1(%r12), %rsi
movq %rsi, 0x18(%rsp)
movq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
callq 0x731c
movq %rax, 0x18(%rsp)
cmpl $0x0, (%rbx)
je 0x6c8e
xorl %r13d, %r13d
movq 0x8(%rsp), %rbp
movl (%rbx), %eax
cmpl $0x1, %eax
je 0x6a10
testq %r13, %r13
je 0x6a16
testl %eax, %eax
jne 0x6a16
movq 0x8(%rbp), %r15
cmpq %r15, (%rbp)
jne 0x6c3d
testq %r15, %r15
jle 0x6c3d
movq 0x10(%rbp), %rdi
movq %r15, %rsi
shlq $0x4, %rsi
callq 0x2230
movq %rax, 0x10(%rbp)
testq %rax, %rax
je 0x6e36
leaq (%r15,%r15), %r14
leaq (%rax,%r15,8), %rdi
shlq $0x3, %r15
xorl %esi, %esi
movq %r15, %rdx
callq 0x2120
movq %r14, 0x8(%rbp)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbp)
movq %r13, (%rcx,%rax,8)
movq 0x20(%rsp), %r15
movq 0x8(%r15), %rax
cmpb $0x7d, (%rax,%r12)
je 0x6e10
leaq 0x1(%r12), %rsi
movq 0x10(%rsp), %r14
movq %rsi, (%r14)
movq %r15, %rdi
movq %rbx, %rdx
callq 0x731c
movq %rax, (%r14)
cmpl $0x0, (%rbx)
je 0x6a44
jmp 0x6a10
movq 0x8(%r14), %rcx
movzbl (%rcx,%rax), %ecx
cmpl $0x7a, %ecx
movq 0x8(%rsp), %rbp
jg 0x6d7b
cmpl $0x22, %ecx
je 0x6dc0
cmpl $0x5b, %ecx
jne 0x6d8d
movabsq $0x200000001, %rcx      # imm = 0x200000001
movq %rcx, 0x8(%r13)
incq %rax
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x731c
movq %rax, %r12
cmpl $0x0, (%rbx)
jne 0x6da8
movq 0x8(%r14), %rax
movzbl (%rax,%r12), %ecx
cmpl $0x2b, %ecx
jg 0x6d1f
cmpl $0x22, %ecx
je 0x6d3f
cmpl $0x23, %ecx
jne 0x6d29
movl $0x6, (%rbx)
movq (%r14), %rcx
cmpq %r12, %rcx
jbe 0x6d16
cmpb $0xa, (%rax,%r12)
je 0x6d65
incq %r12
cmpq %r12, %rcx
jne 0x6d07
movq $-0x1, %r12
jmp 0x6d6b
cmpl $0x2c, %ecx
je 0x6d60
cmpl $0x5d, %ecx
je 0x6da8
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x749d
movq %rax, %r12
jmp 0x6d70
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x73a9
movq %rax, %r12
cmpl $0x0, (%rbx)
jne 0x6da8
movl $0x1, 0xc(%r13)
incq %r12
jmp 0x6d70
movl $0x0, (%rbx)
cmpl $0x0, (%rbx)
jne 0x6da8
movq %r14, %rdi
movq %r12, %rsi
jmp 0x6ccd
cmpl $0x7b, %ecx
je 0x6de7
cmpl $0x7d, %ecx
jne 0x6d8d
movl $0x1, (%rbx)
jmp 0x6ddf
movq $0x0, 0x8(%r13)
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x749d
jmp 0x6ddf
cmpl $0x1, 0xc(%r13)
je 0x6b30
movl $0x0, 0xc(%r13)
jmp 0x6b30
movabsq $0x100000000, %rcx      # imm = 0x100000000
movq %rcx, 0x8(%r13)
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x73a9
movq %rax, %r12
jmp 0x6b30
movl $0x2, 0x8(%r13)
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
movq %rbx, %rdx
callq 0x698e
movq %rax, 0x18(%r13)
movq 0x18(%rsp), %r12
incq %r12
jmp 0x6b30
movq 0x10(%rsp), %rax
movq %r12, (%rax)
jmp 0x6a16
callq 0x3699
callq 0x36be
callq 0x36e3
callq 0x3752
callq 0x372d
callq 0x3708