// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movq 0x9d39f(%rip), %r12     # 0xe3ce0
cmpb $0x0, (%r12)
je 0x46b6c
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
jne 0x46962
movq %rbx, %rdi
callq 0xc380
movq %rax, %r14
leaq 0x30e8(%r12), %rdi
leal 0x1(%r14), %esi
callq 0x49cb6
movq 0x30f0(%r12), %r15
leaq (%r15,%r14), %r13
movq %r15, %rdi
movq %rbx, -0x58(%rbp)
movq %rbx, %rsi
movq %r14, %rdx
callq 0xc080
movq %r14, -0x50(%rbp)
movq %r15, -0x40(%rbp)
movb $0x0, (%r15,%r14)
leaq 0x30f8(%r12), %r14
xorl %r15d, %r15d
cmpl (%r14), %r15d
jge 0x469e7
movq %r14, %rdi
movl %r15d, %esi
callq 0x4baa6
cmpq $0x0, 0x18(%rax)
je 0x469e2
movq %r14, %rdi
movl %r15d, %esi
callq 0x4baa6
movq 0x18(%rax), %rbx
movq %r14, %rdi
movl %r15d, %esi
callq 0x4baa6
movq %r12, %rdi
movq %rax, %rsi
callq *%rbx
incl %r15d
jmp 0x469a9
movq %r12, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x40(%rbp), %r15
xorl %eax, %eax
movq %r15, %r12
cmpq %r13, %r15
jb 0x46a09
jmp 0x46afe
incq %r12
movzbl (%r12), %ecx
cmpl $0xa, %ecx
je 0x46a06
cmpl $0xd, %ecx
je 0x46a06
movq %r12, %r15
cmpq %r13, %r15
jae 0x46a33
movzbl (%r15), %ecx
cmpl $0xa, %ecx
je 0x46a33
cmpl $0xd, %ecx
je 0x46a33
incq %r15
jmp 0x46a1b
movb $0x0, (%r15)
movzbl (%r12), %ecx
cmpl $0x3b, %ecx
je 0x46ae4
cmpl $0x5b, %ecx
jne 0x46ac1
cmpq %r12, %r15
jbe 0x46ac1
cmpb $0x5d, -0x1(%r15)
jne 0x46ac1
movq %rax, -0x48(%rbp)
leaq -0x1(%r15), %rbx
movb $0x0, (%rbx)
incq %r12
movq %r12, %rdi
movq %rbx, %rsi
pushq $0x5d
popq %rdx
callq 0x344d9
testq %rax, %rax
je 0x46aec
movq %rax, -0x60(%rbp)
leaq 0x1(%rax), %rdi
movq %rbx, %rsi
pushq $0x5b
popq %rdx
callq 0x344d9
movq %rax, %rbx
testq %rax, %rax
movq -0x48(%rbp), %rax
je 0x46ae4
movq -0x60(%rbp), %rax
movb $0x0, (%rax)
movq %r12, %rdi
callq 0x46818
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x46af2
incq %rbx
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
callq *0x20(%rsi)
jmp 0x46ae4
cmpq $0x0, -0x30(%rbp)
je 0x46ae4
testq %rax, %rax
je 0x46ae4
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rax, %rbx
movq %rax, %rdx
movq %r12, %rcx
callq *0x28(%rsi)
movq %rbx, %rax
incq %r15
jmp 0x469f9
movq -0x48(%rbp), %rax
jmp 0x46ae4
movq $0x0, -0x30(%rbp)
xorl %eax, %eax
jmp 0x46ae4
movq -0x38(%rbp), %r12
movb $0x1, 0x30e1(%r12)
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0xc080
xorl %r15d, %r15d
cmpl (%r14), %r15d
jge 0x46b5d
movq %r14, %rdi
movl %r15d, %esi
callq 0x4baa6
cmpq $0x0, 0x30(%rax)
je 0x46b58
movq %r14, %rdi
movl %r15d, %esi
callq 0x4baa6
movq 0x30(%rax), %rbx
movq %r14, %rdi
movl %r15d, %esi
callq 0x4baa6
movq %r12, %rdi
movq %rax, %rsi
callq *%rbx
incl %r15d
jmp 0x46b1f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x56fc8(%rip), %rdi     # 0x9db3b
leaq 0x5661b(%rip), %rsi     # 0x9d195
leaq 0x58d22(%rip), %rcx     # 0x9f8a3
movl $0x27a5, %edx           # imm = 0x27A5
callq 0xc140