// File: /workspace/github_c_makefile_star2_O2/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 %rdi, %r12
movq 0x8(%rdi), %rax
movq (%rsi), %rbx
cmpb $0x7b, (%rax,%rbx)
movq %rsi, 0x20(%rsp)
jne 0x5dfe
incq %rbx
movq %rbx, (%rsi)
pushq $0x1
popq %r15
pushq $0x18
popq %rsi
movq %r15, %rdi
callq 0x2170
testq %rax, %rax
je 0x6277
movq %rax, %rbp
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x2170
movq %rax, 0x8(%rsp)
movq %rax, 0x10(%rbp)
movq %rbp, 0x18(%rsp)
movq $0x1, 0x8(%rbp)
xorl %r13d, %r13d
movq %r15, 0x10(%rsp)
xorl %r15d, %r15d
movq 0x20(%rsp), %rbp
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x67b8
movq %rax, (%rbp)
cmpl $0x0, (%r14)
jne 0x61c0
movq 0x8(%r12), %rcx
cmpb $0x7d, (%rcx,%rax)
movq 0x18(%rsp), %rsi
je 0x6204
movq %r13, 0x28(%rsp)
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x67b8
movq %rax, %r13
movl (%r14), %eax
testl %eax, %eax
jne 0x5eb6
movq %r12, %rdi
movq %r13, %rsi
pushq $0x3d
popq %rdx
movq %r14, %rcx
callq 0x682c
movq %rax, %rbp
movl (%r14), %eax
testl %eax, %eax
je 0x615b
cmpl $0x6, %eax
je 0x61c0
xorl %r13d, %r13d
movq %r15, %rbp
pushq $0x1
popq %r15
movq %r15, %rdi
pushq $0x20
popq %rsi
callq 0x2170
testq %rax, %rax
je 0x6216
movq %rax, %rbx
movq %r15, %rdi
pushq $0x18
popq %rsi
callq 0x2170
testq %rax, %rax
je 0x6229
movq %r15, %rdi
movq %rax, %r15
pushq $0x8
popq %rsi
callq 0x2170
movq %rax, 0x10(%r15)
testq %rax, %rax
je 0x623e
movq $0x1, 0x8(%r15)
movq %r15, 0x10(%rbx)
movq %r13, (%rbx)
incq %rbp
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x67b8
movq %rax, %r15
movq %rax, 0x30(%rsp)
movl (%r14), %eax
testl %eax, %eax
movq 0x18(%rsp), %rsi
jne 0x61eb
movq 0x8(%r12), %rax
movzbl (%rax,%r15), %eax
cmpl $0x22, %eax
je 0x6043
cmpl $0x5b, %eax
movq 0x20(%rsp), %rbp
movq 0x28(%rsp), %r13
je 0x5f99
cmpl $0x7b, %eax
je 0x6076
cmpl $0x7d, %eax
je 0x61d4
andq $0x0, 0x8(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x6926
movq %rax, %r15
jmp 0x6099
movabsq $0x200000001, %rax      # imm = 0x200000001
movq %rax, 0x8(%rbx)
incq %r15
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x67b8
movq %rax, %r15
cmpl $0x0, (%r14)
jne 0x6037
movq 0x8(%r12), %rax
movzbl (%rax,%r15), %eax
cmpl $0x22, %eax
je 0x6011
cmpl $0x23, %eax
je 0x5ff5
cmpl $0x2c, %eax
je 0x5fa7
cmpl $0x5d, %eax
je 0x6037
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x6926
movq %rax, %r15
jmp 0x5faa
movq %r12, %rdi
movq %r15, %rsi
pushq $0xa
popq %rdx
movq %r14, %rcx
callq 0x682c
movq %rax, %r15
cmpl $0x0, (%r14)
je 0x5faa
jmp 0x6037
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x685b
movq %rax, %r15
cmpl $0x0, (%r14)
jne 0x6037
movl $0x1, 0xc(%rbx)
jmp 0x5fa7
cmpl $0x1, 0xc(%rbx)
je 0x6099
andl $0x0, 0xc(%rbx)
jmp 0x6099
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x8(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x685b
movq %rax, %r15
movq 0x20(%rsp), %rbp
movq 0x8(%rsp), %rdi
movq 0x28(%rsp), %r13
jmp 0x609e
movl $0x2, 0x8(%rbx)
movq %r12, %rdi
leaq 0x30(%rsp), %rsi
movq %r14, %rdx
callq 0x5dd2
movq %rax, 0x18(%rbx)
movq 0x30(%rsp), %r15
incq %r15
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
cmpl $0x0, (%r14)
jne 0x61db
cmpq %rdx, %r13
jne 0x6121
testq %rdx, %rdx
jle 0x6121
movq %rdx, %rsi
shlq $0x4, %rsi
movq %rdx, %r13
callq 0x2230
movq 0x18(%rsp), %rbp
movq %rax, 0x10(%rbp)
testq %rax, %rax
je 0x6262
leaq (,%r13,2), %rcx
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
leaq (%rax,%r13,8), %rdi
shlq $0x3, %r13
xorl %esi, %esi
movq %r13, %rdx
callq 0x2120
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq %rdx, 0x8(%rbp)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %r13
movq %rbp, %rsi
movq %rax, %rbp
jmp 0x6126
movq 0x18(%rsp), %rsi
leaq 0x1(%r13), %rax
movq %rax, (%rsi)
movq %rbx, (%rdi,%r13,8)
movq 0x8(%r12), %rcx
cmpb $0x7d, (%rcx,%r15)
je 0x61cb
movq %rdx, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0x1(%r15), %rbx
movq %rbx, (%rbp)
movq %rax, %r13
jmp 0x5e4a
movq %rbp, %rbx
movq %r13, %r15
subq %r13, %rbx
leaq 0x1(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0x2170
testq %rax, %rax
je 0x628a
movq %rax, %r13
movq 0x8(%r12), %rsi
addq %r15, %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0x2040
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0x5ec5
callq 0x22c0
movq (%rax), %rax
movsbq (%r13,%r15), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x61b5
incq %r15
jmp 0x6192
movb $0x0, (%r13,%r15)
jmp 0x5ec5
andl $0x0, (%r14)
movq 0x18(%rsp), %rsi
jmp 0x6204
movq %r15, (%rbp)
movl (%r14), %eax
jmp 0x61f6
movl $0x1, (%r14)
movq %rbx, %rdi
callq 0x5a8b
movl (%r14), %eax
movq 0x18(%rsp), %rsi
cmpl $0x1, %eax
jne 0x61f6
andl $0x0, (%r14)
jmp 0x6204
testl %eax, %eax
je 0x6204
movq %rsi, %rdi
callq 0x5a3c
xorl %esi, %esi
movq %rsi, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7ddb(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x3b5a(%rip), %rdi      # 0x9d81
jmp 0x623a
movq 0x7dc8(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x3b66(%rip), %rdi      # 0x9da0
pushq $0x1e
jmp 0x6251
movq 0x7db3(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x3b70(%rip), %rdi      # 0x9dbf
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
callq 0x2290
pushq $0x1
popq %rdi
callq 0x2280
movq 0x7d8f(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x3b8a(%rip), %rdi      # 0x9dfd
pushq $0x19
jmp 0x6251
movq 0x7d7a(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x3abc(%rip), %rdi      # 0x9d44
jmp 0x624f
movq 0x7d67(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x3ac9(%rip), %rdi      # 0x9d64
pushq $0x1c
jmp 0x6251