// File: /workspace/github_c_makefile_star2_O1/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
xorl %ebp, %ebp
movw %bp, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movw %bp, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
leaq 0x90(%rsp), %r12
movq %r12, %rdi
movl $0xc8, %esi
movq %r15, %rdx
callq 0x20e0
testq %rax, %rax
je 0x2911
movl $0x1, %r14d
xorl %ebp, %ebp
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 0x295c
movq %rbx, %rdi
callq 0x2925
movq %rax, %r13
movzbl (%rax), %eax
cmpl $0x23, %eax
je 0x28f5
cmpl $0x3b, %eax
je 0x28f5
cmpb $0x0, 0x10(%rsp)
je 0x2807
testl %eax, %eax
sete %cl
cmpq %r12, %r13
setbe %dl
orb %cl, %dl
jne 0x2807
movq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r13, %rcx
jmp 0x28e8
testl %eax, %eax
je 0x28f5
cmpl $0x3b, %eax
je 0x28f5
cmpl $0x5b, %eax
jne 0x285c
incq %r13
movq %r13, %rdi
movl $0x5d, %esi
callq 0x299e
cmpb $0x5d, (%rax)
jne 0x28ef
xorl %ebx, %ebx
movb %bl, (%rax)
movl $0x32, %edx
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x2060
movb %bl, 0x81(%rsp)
movb %bl, 0x10(%rsp)
jmp 0x28f5
movq %r13, %rdi
movl $0x3d, %esi
callq 0x299e
movq %rax, %rbx
cmpb $0x3d, (%rax)
je 0x2881
movq %r13, %rdi
movl $0x3a, %esi
callq 0x299e
movq %rax, %rbx
movzbl (%rbx), %eax
cmpl $0x3d, %eax
je 0x288e
cmpl $0x3a, %eax
jne 0x28ef
movb $0x0, (%rbx)
movq %r13, %rdi
callq 0x295c
incq %rbx
movq %rbx, %rdi
callq 0x2925
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
callq 0x299e
cmpb $0x3b, (%rax)
jne 0x28b9
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0x295c
movl $0x32, %edx
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x2060
movb $0x0, 0x41(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq *(%rsp)
orl %ebp, %eax
jmp 0x28f1
testl %ebp, %ebp
cmovel %r14d, %ebp
movq %r12, %rdi
movl $0xc8, %esi
movq %r15, %rdx
callq 0x20e0
incl %r14d
testq %rax, %rax
jne 0x2772
movl %ebp, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq