// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x83c2
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
jmp 0x84d6
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movsbl (%rax,%rcx), %ecx
movl $0x7b, %eax
cmpl %ecx, %eax
jne 0x83ec
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
callq 0x9520
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x9170
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x842b
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
jmp 0x84d4
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7d, %eax
jne 0x8448
jmp 0x84d4
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rcx
leaq -0x30(%rbp), %rdx
callq 0x9260
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rcx
movl $0x1, %eax
cmpl (%rcx), %eax
jne 0x847d
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
jmp 0x84d4
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x8488
jmp 0x84d4
cmpq $0x0, -0x28(%rbp)
jne 0x8491
jmp 0x84d4
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x94a0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7d, %eax
jne 0x84c0
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x84d4
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x83f5
jmp 0x84d6
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x84ec
movq -0x20(%rbp), %rdi
callq 0x7e00
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)