// File: /workspace/github_cpp_makefile_star2_O1/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 0xa3643(%rip), %rbx     # 0xfdcd0
cmpb $0x0, (%rbx)
je 0x5a94d
movq %rdi, %r13
testq %rsi, %rsi
jne 0x5a6a9
movq %r13, %rdi
callq 0xc350
movq %rax, %rsi
leal 0x1(%rsi), %r15d
movl 0x30ec(%rbx), %eax
movq %rsi, -0x30(%rbp)
cmpl %esi, %eax
jg 0x5a754
testl %eax, %eax
je 0x5a6d5
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
addl %eax, %r12d
jmp 0x5a6db
movl $0x8, %r12d
cmpl %r15d, %r12d
cmovlel %r15d, %r12d
cmpl %r12d, %eax
jge 0x5a754
movslq %r12d, %rdi
incl 0x3b4(%rbx)
movq 0xa35e9(%rip), %rsi     # 0xfdce0
callq *0x9ee13(%rip)          # 0xf9510
movq %rax, %r14
movq 0x30f0(%rbx), %rsi
testq %rsi, %rsi
je 0x5a746
movslq 0x30e8(%rbx), %rdx
movq %r14, %rdi
callq 0xc080
movq 0x30f0(%rbx), %rdi
testq %rdi, %rdi
je 0x5a739
movq 0xa35a2(%rip), %rax     # 0xfdcd0
testq %rax, %rax
je 0x5a739
decl 0x3b4(%rax)
movq 0xa35a0(%rip), %rsi     # 0xfdce0
callq *0x9edd2(%rip)          # 0xf9518
movq %r14, 0x30f0(%rbx)
movl %r12d, 0x30ec(%rbx)
movl %r15d, 0x30e8(%rbx)
movq 0x30f0(%rbx), %r14
movq %r14, %rdi
movq %r13, %rsi
movq -0x30(%rbp), %r12
movq %r12, %rdx
callq 0xc080
movq %r14, -0x38(%rbp)
movb $0x0, (%r14,%r12)
cmpl $0x0, 0x30f8(%rbx)
jle 0x5a7b8
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x3100(%rbx), %rsi
movq 0x18(%rsi,%r14), %rax
testq %rax, %rax
je 0x5a7a5
addq %r14, %rsi
movq %rbx, %rdi
callq *%rax
incq %r15
movslq 0x30f8(%rbx), %rax
addq $0x48, %r14
cmpq %rax, %r15
jl 0x5a78c
movq %r13, -0x40(%rbp)
testq %r12, %r12
jle 0x5a8eb
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %r15
leaq (%r15,%rax), %r14
xorl %eax, %eax
xorl %esi, %esi
leaq 0x2(%r15), %rdi
movq %r15, %r12
movzbl (%r12), %ecx
cmpl $0xa, %ecx
je 0x5a7eb
cmpl $0xd, %ecx
jne 0x5a7f3
incq %r12
incq %rdi
jmp 0x5a7dc
movq %r12, %r15
cmpq %r14, %r12
jae 0x5a811
movzbl (%r15), %ecx
cmpl $0xa, %ecx
je 0x5a811
cmpl $0xd, %ecx
je 0x5a811
incq %r15
cmpq %r14, %r15
jb 0x5a7fb
movb $0x0, (%r15)
movzbl (%r12), %ecx
cmpl $0x3b, %ecx
je 0x5a89d
cmpl $0x5b, %ecx
jne 0x5a87b
cmpq %r12, %r15
jbe 0x5a87b
cmpb $0x5d, -0x1(%r15)
jne 0x5a87b
movq %rsi, -0x50(%rbp)
movq %rax, -0x48(%rbp)
movb $0x0, -0x1(%r15)
incq %r12
movq %r15, %rdx
subq %rdi, %rdx
movq %r12, %rdi
movl $0x5d, %esi
callq 0xc3c0
movq %rax, %rcx
testq %rax, %rax
je 0x5a8ab
leaq -0x1(%r15), %rdx
leaq 0x1(%rcx), %rdi
subq %rdi, %rdx
movl $0x5b, %esi
movq %rcx, %r13
callq 0xc3c0
movq %r13, %rcx
movq %rax, %r13
jmp 0x5a8ae
testq %rsi, %rsi
je 0x5a89d
testq %rax, %rax
je 0x5a89d
movq %rbx, %rdi
movq %rax, %r13
movq %rax, %rdx
movq %r12, %rcx
movq %rsi, %r12
callq *0x28(%rsi)
movq %r12, %rsi
movq %r13, %rax
incq %r15
cmpq %r14, %r15
jb 0x5a7d5
jmp 0x5a8eb
xorl %r13d, %r13d
testq %rcx, %rcx
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rsi
je 0x5a89d
testq %r13, %r13
je 0x5a89d
movb $0x0, (%rcx)
movq %r12, %rdi
callq 0x5a572
movq %rax, %rsi
testq %rax, %rax
je 0x5a8e7
incq %r13
movq %rbx, %rdi
movq %r13, %rdx
movq %rsi, %r12
callq *0x20(%rsi)
movq %r12, %rsi
jmp 0x5a89d
xorl %eax, %eax
jmp 0x5a89d
movb $0x1, 0x30e1(%rbx)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0xc080
cmpl $0x0, 0x30f8(%rbx)
jle 0x5a93e
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x3100(%rbx), %rsi
movq 0x30(%rsi,%r14), %rax
testq %rax, %rax
je 0x5a92b
addq %r14, %rsi
movq %rbx, %rdi
callq *%rax
incq %r15
movslq 0x30f8(%rbx), %rax
addq $0x48, %r14
cmpq %rax, %r15
jl 0x5a912
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5e1b7(%rip), %rdi     # 0xb8b0b
leaq 0x5d80a(%rip), %rsi     # 0xb8165
leaq 0x5ff11(%rip), %rcx     # 0xba873
movl $0x27a5, %edx           # imm = 0x27A5
callq 0xc140