// File: /workspace/github_c_makefile_star2_O2/darwin-on-arm[P]darwin-sdk/xcode_tools/xcrun/ini.c
// Function: ini_parse_file
int ini_parse_file(FILE* file,
                   int (*handler)(void*, const char*, const char*,
                                  const char*),
                   void* user)
{
    /* Uses a fair bit of stack (use heap instead if you need to) */
#if INI_USE_STACK
    char line[INI_MAX_LINE];
#else
    char* line = NULL;
#endif
    char section[MAX_SECTION] = "";
    char prev_name[MAX_NAME] = "";

    char* start = NULL;
    char* end = NULL;
    char* name = NULL;
    char* value = NULL;
    int lineno = 0;
    int error = 0;

#if !INI_USE_STACK
    line = (char*)malloc(INI_MAX_LINE);
    if (!line) {
        return -2;
    }
#endif

    /* Scan through file line by line */
    while (fgets(line, INI_MAX_LINE, file) != NULL) {
        lineno++;

        start = line;
#if INI_ALLOW_BOM
        if (lineno == 1 && (unsigned char)start[0] == 0xEF &&
                           (unsigned char)start[1] == 0xBB &&
                           (unsigned char)start[2] == 0xBF) {
            start += 3;
        }
#endif
        start = lskip(rstrip(start));

        if (*start == ';' || *start == '#') {
            /* Per Python ConfigParser, allow '#' comments at start of line */
        }
#if INI_ALLOW_MULTILINE
        else if (*prev_name && *start && start > line) {
            /* Non-black line with leading whitespace, treat as continuation
               of previous name's value (as per Python ConfigParser). */
            if (!handler(user, section, prev_name, start) && !error)
                error = lineno;
        }
#endif
        else if (*start == '[') {
            /* A "[section]" line */
            end = find_char_or_comment(start + 1, ']');
            if (*end == ']') {
                *end = '\0';
                strncpy0(section, start + 1, sizeof(section));
                *prev_name = '\0';
            }
            else if (!error) {
                /* No ']' found on section line */
                error = lineno;
            }
        }
        else if (*start && *start != ';') {
            /* Not a comment, must be a name[=:]value pair */
            end = find_char_or_comment(start, '=');
            if (*end != '=') {
                end = find_char_or_comment(start, ':');
            }
            if (*end == '=' || *end == ':') {
                *end = '\0';
                name = rstrip(start);
                value = lskip(end + 1);
                end = find_char_or_comment(value, '\0');
                if (*end == ';')
                    *end = '\0';
                rstrip(value);

                /* Valid name[=:]value pair found, call handler */
                strncpy0(prev_name, name, sizeof(prev_name));
                if (!handler(user, section, name, value) && !error)
                    error = lineno;
            }
            else if (!error) {
                /* No '=' or ':' found on name[=:]value line */
                error = lineno;
            }
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdx, 0x8(%rsp)
movq %rsi, (%rsp)
movq %rdi, %r15
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rax
movaps %xmm0, 0x20(%rax)
andw $0x0, 0x30(%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
leaq 0x10(%rsp), %rax
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
andw $0x0, 0x30(%rax)
movaps %xmm0, (%rax)
pushq $0x1
popq %r14
leaq 0x90(%rsp), %rbp
xorl %r13d, %r13d
movq %rbp, %rdi
movl $0xc8, %esi
movq %r15, %rdx
callq 0x20e0
testq %rax, %rax
je 0x250f
cmpl $0x1, %r14d
sete %al
cmpb $-0x11, 0x90(%rsp)
sete %cl
andb %al, %cl
cmpb $-0x45, 0x91(%rsp)
sete %al
cmpb $-0x41, 0x92(%rsp)
sete %dl
andb %al, %dl
andb %cl, %dl
movzbl %dl, %eax
leaq (%rax,%rax,2), %rax
leaq (%rsp,%rax), %rbx
addq $0x90, %rbx
movq %rbx, %rdi
callq 0x2554
movq %rbx, %rdi
callq 0x2524
movq %rax, %r12
movzbl (%rax), %eax
cmpl $0x23, %eax
je 0x2507
cmpl $0x3b, %eax
je 0x2507
cmpb $0x0, 0x10(%rsp)
je 0x2433
testl %eax, %eax
sete %cl
cmpq %rbp, %r12
setbe %dl
orb %cl, %dl
jne 0x2433
movq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r12, %rcx
jmp 0x24f8
testl %eax, %eax
je 0x2507
cmpl $0x3b, %eax
je 0x2507
cmpl $0x5b, %eax
jne 0x247a
incq %r12
movq %r12, %rdi
pushq $0x5d
popq %rsi
callq 0x2593
cmpb $0x5d, (%rax)
jne 0x2500
xorl %ebx, %ebx
movb %bl, (%rax)
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0x25d5
movb %bl, 0x10(%rsp)
jmp 0x2507
movq %r12, %rdi
pushq $0x3d
popq %rsi
callq 0x2593
movq %rax, %rbx
cmpb $0x3d, (%rax)
je 0x24a8
movq %r12, %rdi
pushq $0x3a
popq %rsi
callq 0x2593
movq %rax, %rbx
movzbl (%rax), %eax
cmpl $0x3d, %eax
je 0x24a8
cmpl $0x3a, %eax
jne 0x2500
movb $0x0, (%rbx)
movq %r12, %rdi
callq 0x2554
incq %rbx
movq %rbx, %rdi
callq 0x2524
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
callq 0x2593
cmpb $0x3b, (%rax)
jne 0x24d3
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x2554
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x25d5
movq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq *(%rsp)
orl %r13d, %eax
jmp 0x2503
testl %r13d, %r13d
cmovel %r14d, %r13d
incl %r14d
jmp 0x2385
movl %r13d, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq