// File: /workspace/github_c_makefile_star2_O0/buf1024[P]mysch/iniconf.c
// Function: ini_load
int ini_load(ini_conf_t* ini, const char* file)
{
    if(!ini || !file) return -1;

    int fd = open(file, O_RDONLY);
    if (fd == -1) return -1;

    char tmpline[INI_READ_LINE + 1] = { 0 };
    char line[INI_READ_LINE + 1] = { 0 };
    char* tmp = 0;
    char key[INI_MAX_KEY_LEN] = { 0 };
    char value[INI_MAX_VALUE_LEN] = { 0 };

    char tmpkey[INI_MAX_KEY_LEN] = { 0 };
    char tmpvalue[INI_MAX_VALUE_LEN] = { 0 };

    ini_sec_t* cur_sec = 0;

    int len = 0;
    while (1) {
        if ((len = read_line(fd, tmpline, INI_READ_LINE)) < 0) {
            break;
        }
        if (*tmpline == '#' || *tmpline == ';' || len == 0) {
            continue;
        }
        trim(tmpline, " ", line, INI_READ_LINE);
        if(line[0] == 0) {
            continue;
        }

        // start section
        memset(key, 0, INI_MAX_KEY_LEN);
        memset(value, 0, INI_MAX_VALUE_LEN);
        memset(tmpkey, 0, sizeof(tmpkey));
        memset(tmpvalue, 0, sizeof(tmpvalue));

        tmp = line;
        if (*tmp == '[') {
            const char* key_del = ++tmp;
            while (*tmp != '\0' && *tmp != ']') {
                tmp++;
            }
            if (*tmp == '\0') {
                return -1;
            }
            strncpy(key, key_del, tmp - key_del);
            cur_sec = ini_insert_sec(ini, key);
            continue;
        }
        if (cur_sec) {
            const char* eq_del = tmp;
            while (*eq_del != '\0') {
                if (*eq_del == '=') {
                    break;
                }
                eq_del++;
            }
            if (*eq_del == '\0' || *(eq_del + 1) == '\0') {
                continue;
            }

            strncpy(tmpkey, tmp, eq_del - tmp);
            strcpy(tmpvalue, eq_del + 1);

            trim(tmpkey, " ", key, INI_MAX_KEY_LEN);
            trim(tmpvalue, " ", value, INI_MAX_VALUE_LEN);

            if(key[0] == 0 || value[0] == 0) {
                continue;
            }

            ini_insert_val(cur_sec, key, value);

        }
    }
    close(fd);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1470, %rsp           # imm = 0x1470
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x44e1
cmpq $0x0, -0x18(%rbp)
jne 0x44ed
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x487b
movq -0x18(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x22f0
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x450f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x487b
leaq -0x520(%rbp), %rdi
xorl %esi, %esi
movl $0x503, %edx            # imm = 0x503
callq 0x2190
leaq -0xa30(%rbp), %rdi
xorl %esi, %esi
movl $0x503, %edx            # imm = 0x503
callq 0x2190
movq $0x0, -0xa38(%rbp)
leaq -0xb40(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x2190
leaq -0xf40(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x2190
leaq -0x1040(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x2190
leaq -0x1440(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x2190
movq $0x0, -0x1448(%rbp)
movl $0x0, -0x144c(%rbp)
movl -0x1c(%rbp), %edi
leaq -0x520(%rbp), %rsi
movl $0x502, %edx            # imm = 0x502
callq 0x4890
movl %eax, -0x144c(%rbp)
cmpl $0x0, %eax
jge 0x45c5
jmp 0x486c
movsbl -0x520(%rbp), %eax
cmpl $0x23, %eax
je 0x45e6
movsbl -0x520(%rbp), %eax
cmpl $0x3b, %eax
je 0x45e6
cmpl $0x0, -0x144c(%rbp)
jne 0x45e8
jmp 0x45a1
leaq -0x520(%rbp), %rdi
leaq -0xa30(%rbp), %rdx
leaq 0x5b3f(%rip), %rsi      # 0xa13c
movl $0x502, %ecx            # imm = 0x502
callq 0x7490
movsbl -0xa30(%rbp), %eax
cmpl $0x0, %eax
jne 0x4615
jmp 0x45a1
leaq -0xb40(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x2190
leaq -0xf40(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x2190
leaq -0x1040(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x2190
leaq -0x1440(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x2190
leaq -0xa30(%rbp), %rax
movq %rax, -0xa38(%rbp)
movq -0xa38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0x4743
movq -0xa38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa38(%rbp)
movq %rax, -0x1458(%rbp)
movq -0xa38(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x1461(%rbp)
je 0x46c8
movq -0xa38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5d, %eax
setne %al
movb %al, -0x1461(%rbp)
movb -0x1461(%rbp), %al
testb $0x1, %al
jne 0x46d4
jmp 0x46e8
movq -0xa38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa38(%rbp)
jmp 0x469b
movq -0xa38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4703
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x487b
leaq -0xb40(%rbp), %rdi
movq -0x1458(%rbp), %rsi
movq -0xa38(%rbp), %rdx
movq -0x1458(%rbp), %rax
subq %rax, %rdx
callq 0x2070
movq -0x10(%rbp), %rdi
leaq -0xb40(%rbp), %rsi
callq 0x4970
movq %rax, -0x1448(%rbp)
jmp 0x45a1
cmpq $0x0, -0x1448(%rbp)
je 0x4867
movq -0xa38(%rbp), %rax
movq %rax, -0x1460(%rbp)
movq -0x1460(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x4793
movq -0x1460(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0x477f
jmp 0x4793
movq -0x1460(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1460(%rbp)
jmp 0x475f
movq -0x1460(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x47b2
movq -0x1460(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x47b7
jmp 0x45a1
leaq -0x1040(%rbp), %rdi
movq -0xa38(%rbp), %rsi
movq -0x1460(%rbp), %rdx
movq -0xa38(%rbp), %rax
subq %rax, %rdx
callq 0x2070
leaq -0x1440(%rbp), %rdi
movq -0x1460(%rbp), %rsi
addq $0x1, %rsi
callq 0x2090
leaq -0x1040(%rbp), %rdi
leaq -0xb40(%rbp), %rdx
leaq 0x5935(%rip), %rsi      # 0xa13c
movl $0x100, %ecx            # imm = 0x100
callq 0x7490
leaq -0x1440(%rbp), %rdi
leaq -0xf40(%rbp), %rdx
leaq 0x5916(%rip), %rsi      # 0xa13c
movl $0x400, %ecx            # imm = 0x400
callq 0x7490
movsbl -0xb40(%rbp), %eax
cmpl $0x0, %eax
je 0x4848
movsbl -0xf40(%rbp), %eax
cmpl $0x0, %eax
jne 0x484d
jmp 0x45a1
movq -0x1448(%rbp), %rdi
leaq -0xb40(%rbp), %rsi
leaq -0xf40(%rbp), %rdx
callq 0x4a20
jmp 0x45a1
movl -0x1c(%rbp), %edi
callq 0x21b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1470, %rsp           # imm = 0x1470
popq %rbp
retq
nopw (%rax,%rax)