// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::LoadIniSettingsFromMemory(char const*, unsigned long)
void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
{
    ImGuiContext& g = *GImGui;
    IM_ASSERT(g.Initialized);
    //IM_ASSERT(!g.WithinFrameScope && "Cannot be called between NewFrame() and EndFrame()");
    //IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0);

    // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
    // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
    if (ini_size == 0)
        ini_size = strlen(ini_data);
    g.SettingsIniData.Buf.resize((int)ini_size + 1);
    char* const buf = g.SettingsIniData.Buf.Data;
    char* const buf_end = buf + ini_size;
    memcpy(buf, ini_data, ini_size);
    buf_end[0] = 0;

    // Call pre-read handlers
    // Some types will clear their data (e.g. dock information) some types will allow merge/override (window)
    for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
        if (g.SettingsHandlers[handler_n].ReadInitFn)
            g.SettingsHandlers[handler_n].ReadInitFn(&g, &g.SettingsHandlers[handler_n]);

    void* entry_data = NULL;
    ImGuiSettingsHandler* entry_handler = NULL;

    char* line_end = NULL;
    for (char* line = buf; line < buf_end; line = line_end + 1)
    {
        // Skip new lines markers, then find end of the line
        while (*line == '\n' || *line == '\r')
            line++;
        line_end = line;
        while (line_end < buf_end && *line_end != '\n' && *line_end != '\r')
            line_end++;
        line_end[0] = 0;
        if (line[0] == ';')
            continue;
        if (line[0] == '[' && line_end > line && line_end[-1] == ']')
        {
            // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code.
            line_end[-1] = 0;
            const char* name_end = line_end - 1;
            const char* type_start = line + 1;
            char* type_end = (char*)(void*)ImStrchrRange(type_start, name_end, ']');
            const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL;
            if (!type_end || !name_start)
                continue;
            *type_end = 0; // Overwrite first ']'
            name_start++;  // Skip second '['
            entry_handler = FindSettingsHandler(type_start);
            entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL;
        }
        else if (entry_handler != NULL && entry_data != NULL)
        {
            // Let type handler parse the line
            entry_handler->ReadLineFn(&g, entry_handler, entry_data, line);
        }
    }
    g.SettingsLoaded = true;

    // [DEBUG] Restore untouched copy so it can be browsed in Metrics (not strictly necessary)
    memcpy(buf, ini_data, ini_size);

    // Call post-read handlers
    for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
        if (g.SettingsHandlers[handler_n].ApplyAllFn)
            g.SettingsHandlers[handler_n].ApplyAllFn(&g, &g.SettingsHandlers[handler_n]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0xa27e5(%rip), %rbx     # 0xfbcd0
cmpb $0x0, (%rbx)
je 0x597c1
movq %rsi, %r13
movq %rdi, %r12
testq %rsi, %rsi
jne 0x5950a
movq %r12, %rdi
callq 0xc350
movq %rax, %r13
leal 0x1(%r13), %r14d
movl 0x30ec(%rbx), %eax
cmpl %r13d, %eax
jle 0x59525
movq 0x30f0(%rbx), %rdi
jmp 0x595ba
testl %eax, %eax
je 0x5953b
movl %eax, %r15d
shrl $0x1f, %r15d
addl %eax, %r15d
sarl %r15d
addl %eax, %r15d
jmp 0x59541
movl $0x8, %r15d
cmpl %r14d, %r15d
cmovlel %r14d, %r15d
movslq %r15d, %rdi
incl 0x3b4(%rbx)
movq 0xa2788(%rip), %rsi     # 0xfbce0
callq *0x9dfb2(%rip)          # 0xf7510
movq %rax, %rdi
movq 0x30f0(%rbx), %rsi
testq %rsi, %rsi
je 0x595ac
movslq 0x30e8(%rbx), %rdx
movq %rdi, -0x30(%rbp)
callq 0xc080
movq 0x30f0(%rbx), %rdi
testq %rdi, %rdi
je 0x5959b
movq 0xa2740(%rip), %rax     # 0xfbcd0
testq %rax, %rax
je 0x5959b
decl 0x3b4(%rax)
movq 0xa273e(%rip), %rsi     # 0xfbce0
callq *0x9df70(%rip)          # 0xf7518
movq -0x30(%rbp), %rdi
movq %rdi, 0x30f0(%rbx)
movl %r15d, 0x30ec(%rbx)
movl %r14d, 0x30e8(%rbx)
movq %r12, %rsi
movq %r13, %rdx
movq %rdi, %r14
callq 0xc080
movq %r14, -0x30(%rbp)
movb $0x0, (%r14,%r13)
movl 0x30f8(%rbx), %eax
testl %eax, %eax
jle 0x59616
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x3100(%rbx), %rsi
movq 0x18(%rsi,%r14), %rcx
testq %rcx, %rcx
je 0x59607
addq %r14, %rsi
movq %rbx, %rdi
callq *%rcx
movl 0x30f8(%rbx), %eax
incq %r15
movslq %eax, %rcx
addq $0x48, %r14
cmpq %rcx, %r15
jl 0x595e8
movq %r12, -0x50(%rbp)
movq %r13, -0x40(%rbp)
testq %r13, %r13
jle 0x5975c
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %r15
leaq (%r15,%rax), %r14
xorl %edx, %edx
xorl %r13d, %r13d
leaq 0x2(%r15), %rax
leaq 0x1(%r15), %rcx
movq %r15, %r12
movzbl (%r12), %esi
cmpl $0xa, %esi
je 0x59652
cmpl $0xd, %esi
jne 0x5965d
incq %r12
incq %rax
incq %rcx
jmp 0x59643
movq %r12, %r15
cmpq %r14, %r12
jae 0x59687
cmpb $0xa, %sil
je 0x59681
movzbl %sil, %esi
cmpl $0xd, %esi
je 0x59681
cmpq %r14, %rcx
jae 0x59684
movb (%rcx), %sil
incq %rcx
jmp 0x59665
decq %rcx
movq %rcx, %r15
movb $0x0, (%r15)
movzbl (%r12), %ecx
cmpl $0x3b, %ecx
je 0x59741
cmpl $0x5b, %ecx
jne 0x59724
cmpq %r12, %r15
jbe 0x59724
cmpb $0x5d, -0x1(%r15)
jne 0x59724
movq %rdx, -0x38(%rbp)
movb $0x0, -0x1(%r15)
incq %r12
movq %r15, %rdx
subq %rax, %rdx
movq %r12, %rdi
movl $0x5d, %esi
callq 0xc3c0
testq %rax, %rax
je 0x5974f
leaq -0x1(%r15), %rdx
movq %rax, -0x48(%rbp)
leaq 0x1(%rax), %rdi
subq %rdi, %rdx
movl $0x5b, %esi
callq 0xc3c0
testq %rax, %rax
movq -0x38(%rbp), %rdx
je 0x59741
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movb $0x0, (%rax)
movq %r12, %rdi
callq 0x593cd
testq %rax, %rax
je 0x59755
movq %rax, %r13
movq -0x38(%rbp), %rdx
incq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq *0x20(%rax)
movq %rax, %rdx
jmp 0x59741
testq %r13, %r13
je 0x59741
testq %rdx, %rdx
je 0x59741
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rcx
movq %rdx, %r12
callq *0x28(%r13)
movq %r12, %rdx
incq %r15
cmpq %r14, %r15
jb 0x59638
jmp 0x5975c
movq -0x38(%rbp), %rdx
jmp 0x59741
xorl %r13d, %r13d
xorl %edx, %edx
jmp 0x59741
movb $0x1, 0x30e1(%rbx)
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0xc080
movl 0x30f8(%rbx), %eax
testl %eax, %eax
jle 0x597b2
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x3100(%rbx), %rsi
movq 0x30(%rsi,%r14), %rcx
testq %rcx, %rcx
je 0x597a3
addq %r14, %rsi
movq %rbx, %rdi
callq *%rcx
movl 0x30f8(%rbx), %eax
incq %r15
movslq %eax, %rcx
addq $0x48, %r14
cmpq %rcx, %r15
jl 0x59784
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d343(%rip), %rdi     # 0xb6b0b
leaq 0x5c996(%rip), %rsi     # 0xb6165
leaq 0x5f09d(%rip), %rcx     # 0xb8873
movl $0x27a5, %edx           # imm = 0x27A5
callq 0xc140