// File: donfreiday[P]gb/./imgui/imgui.cpp
// Function: LoadSettings()
static void LoadSettings()
{
    ImGuiState& g = *GImGui;
    const char* filename = g.IO.IniFilename;
    if (!filename)
        return;

    int file_size;
    char* file_data = (char*)ImLoadFileToMemory(filename, "rb", &file_size, 1);
    if (!file_data)
        return;

    ImGuiIniData* settings = NULL;
    const char* buf_end = file_data + file_size;
    for (const char* line_start = file_data; line_start < buf_end; )
    {
        const char* line_end = line_start;
        while (line_end < buf_end && *line_end != '\n' && *line_end != '\r')
            line_end++;

        if (line_start[0] == '[' && line_end > line_start && line_end[-1] == ']')
        {
            char name[64];
            ImFormatString(name, IM_ARRAYSIZE(name), "%.*s", (int)(line_end-line_start-2), line_start+1);
            settings = FindWindowSettings(name);
            if (!settings)
                settings = AddWindowSettings(name);
        }
        else if (settings)
        {
            float x, y;
            int i;
            if (sscanf(line_start, "Pos=%f,%f", &x, &y) == 2)
                settings->Pos = ImVec2(x, y);
            else if (sscanf(line_start, "Size=%f,%f", &x, &y) == 2)
                settings->Size = ImMax(ImVec2(x, y), g.Style.WindowMinSize);
            else if (sscanf(line_start, "Collapsed=%d", &i) == 1)
                settings->Collapsed = (i != 0);
        }

        line_start = line_end+1;
    }

    ImGui::MemFree(file_data);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x6b95e(%rip), %rax     # 0x794c0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xdb7e
jmp 0xddd4
movq -0x10(%rbp), %rdi
leaq 0x4eb29(%rip), %rsi     # 0x5c6b2
leaq -0x14(%rbp), %rdx
movl $0x1, %ecx
callq 0xa5c0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xdba7
jmp 0xddd4
movq $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0xddcb
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpq -0x30(%rbp), %rcx
movb %al, -0xa5(%rbp)
jae 0xdc15
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0xa5(%rbp)
je 0xdc15
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
setne %al
movb %al, -0xa5(%rbp)
movb -0xa5(%rbp), %al
testb $0x1, %al
jne 0xdc21
jmp 0xdc2f
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xdbdc
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0xdca8
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jbe 0xdca8
movq -0x40(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x5d, %eax
jne 0xdca8
leaq -0x80(%rbp), %rdi
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
subq $0x2, %rax
movl %eax, %ecx
movq -0x38(%rbp), %r8
addq $0x1, %r8
movl $0x40, %esi
leaq 0x4ebd9(%rip), %rdx     # 0x5c854
movb $0x0, %al
callq 0x95a0
leaq -0x80(%rbp), %rdi
callq 0x2af40
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xdca3
leaq -0x80(%rbp), %rdi
callq 0x2afd0
movq %rax, -0x28(%rbp)
jmp 0xddba
cmpq $0x0, -0x28(%rbp)
je 0xddb8
movq -0x38(%rbp), %rdi
leaq 0x4e9f7(%rip), %rsi     # 0x5c6b5
leaq -0x84(%rbp), %rdx
leaq -0x88(%rbp), %rcx
movb $0x0, %al
callq 0x70c0
cmpl $0x2, %eax
jne 0xdd08
movss -0x84(%rbp), %xmm0
movss -0x88(%rbp), %xmm1
leaq -0x94(%rbp), %rdi
callq 0x2d280
movq -0x28(%rbp), %rax
movq -0x94(%rbp), %rcx
movq %rcx, 0xc(%rax)
jmp 0xddb6
movq -0x38(%rbp), %rdi
leaq 0x4e9ac(%rip), %rsi     # 0x5c6bf
leaq -0x84(%rbp), %rdx
leaq -0x88(%rbp), %rcx
movb $0x0, %al
callq 0x70c0
cmpl $0x2, %eax
jne 0xdd80
movss -0x84(%rbp), %xmm0
movss -0x88(%rbp), %xmm1
leaq -0xa4(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x2d280
movq -0xb0(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x13f4, %rsi           # imm = 0x13F4
callq 0x16b80
movlpd %xmm0, -0x9c(%rbp)
movq -0x28(%rbp), %rax
movq -0x9c(%rbp), %rcx
movq %rcx, 0x14(%rax)
jmp 0xddb4
movq -0x38(%rbp), %rdi
leaq 0x4e93f(%rip), %rsi     # 0x5c6ca
leaq -0x8c(%rbp), %rdx
movb $0x0, %al
callq 0x70c0
cmpl $0x1, %eax
jne 0xddb2
cmpl $0x0, -0x8c(%rbp)
setne %cl
movq -0x28(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x1c(%rax)
jmp 0xddb4
jmp 0xddb6
jmp 0xddb8
jmp 0xddba
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xdbc6
movq -0x20(%rbp), %rdi
callq 0xa760
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)