// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::InputScalar(char const*, int, void*, void const*, void const*, char const*, int)
bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiContext& g = *GImGui;
    ImGuiStyle& style = g.Style;

    if (format == NULL)
        format = DataTypeGetInfo(data_type)->PrintFmt;

    char buf[64];
    DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);

    bool value_changed = false;
    if ((flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0)
        flags |= ImGuiInputTextFlags_CharsDecimal;
    flags |= ImGuiInputTextFlags_AutoSelectAll;
    flags |= ImGuiInputTextFlags_NoMarkEdited;  // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.

    if (p_step != NULL)
    {
        const float button_size = GetFrameHeight();

        BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive()
        PushID(label);
        SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
        if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view
            value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format);

        // Step buttons
        const ImVec2 backup_frame_padding = style.FramePadding;
        style.FramePadding.x = style.FramePadding.y;
        ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups;
        if (flags & ImGuiInputTextFlags_ReadOnly)
            button_flags |= ImGuiButtonFlags_Disabled;
        SameLine(0, style.ItemInnerSpacing.x);
        if (ButtonEx("-", ImVec2(button_size, button_size), button_flags))
        {
            DataTypeApplyOp(data_type, '-', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
            value_changed = true;
        }
        SameLine(0, style.ItemInnerSpacing.x);
        if (ButtonEx("+", ImVec2(button_size, button_size), button_flags))
        {
            DataTypeApplyOp(data_type, '+', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
            value_changed = true;
        }

        const char* label_end = FindRenderedTextEnd(label);
        if (label != label_end)
        {
            SameLine(0, style.ItemInnerSpacing.x);
            TextEx(label, label_end);
        }
        style.FramePadding = backup_frame_padding;

        PopID();
        EndGroup();
    }
    else
    {
        if (InputText(label, buf, IM_ARRAYSIZE(buf), flags))
            value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format);
    }
    if (value_changed)
        MarkItemEdited(window->DC.LastItemId);

    return value_changed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
callq 0xeb270
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
testb $0x1, 0x93(%rax)
je 0x1498e4
movb $0x0, -0x1(%rbp)
jmp 0x149cbd
leaq 0xc9655(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq $0x1560, %rax           # imm = 0x1560
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x149917
movl -0x14(%rbp), %edi
callq 0x13fc60
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
leaq -0x90(%rbp), %rdi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %r8
movl $0x40, %esi
callq 0x13fcd0
movb $0x0, -0x91(%rbp)
movl 0x10(%rbp), %eax
andl $0x20002, %eax          # imm = 0x20002
cmpl $0x0, %eax
jne 0x149950
movl 0x10(%rbp), %eax
orl $0x1, %eax
movl %eax, 0x10(%rbp)
movl 0x10(%rbp), %eax
orl $0x10, %eax
movl %eax, 0x10(%rbp)
movl 0x10(%rbp), %eax
orl $0x200000, %eax         # imm = 0x200000
movl %eax, 0x10(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x149c48
callq 0xdd050
movss %xmm0, -0x98(%rbp)
callq 0xdd220
movq -0x10(%rbp), %rdi
callq 0xdb440
callq 0xdcdc0
movss -0x98(%rbp), %xmm1
movq -0x50(%rbp), %rax
addss 0x50(%rax), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
addss %xmm1, %xmm1
addss %xmm0, %xmm1
movss 0x2727f(%rip), %xmm0    # 0x170c3c
callq 0x139050
callq 0xc6860
leaq -0x90(%rbp), %rsi
movl 0x10(%rbp), %ecx
leaq 0x28531(%rip), %rdi     # 0x171f09
movl $0x40, %edx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x149cd0
testb $0x1, %al
jne 0x1499f0
jmp 0x149a1a
leaq -0x90(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x2198(%rax), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x1409d0
andb $0x1, %al
movb %al, -0x91(%rbp)
movq -0x50(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x50(%rbp), %rax
movss 0x3c(%rax), %xmm0
movq -0x50(%rbp), %rax
movss %xmm0, 0x38(%rax)
movl $0x2400, -0xa4(%rbp)    # imm = 0x2400
movl 0x10(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x149a63
movl -0xa4(%rbp), %eax
orl $0x4000, %eax           # imm = 0x4000
movl %eax, -0xa4(%rbp)
movq -0x50(%rbp), %rax
movss 0x50(%rax), %xmm1
xorps %xmm0, %xmm0
callq 0xdc1c0
movss -0x98(%rbp), %xmm0
movss -0x98(%rbp), %xmm1
leaq -0xac(%rbp), %rdi
callq 0xbf4c0
movl -0xa4(%rbp), %edx
leaq 0x44c6a(%rip), %rdi     # 0x18e707
leaq -0xac(%rbp), %rsi
callq 0x13a640
testb $0x1, %al
jne 0x149aaf
jmp 0x149b26
movl -0x14(%rbp), %eax
movl %eax, -0xd4(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x48(%rbp), %rax
testb $0x1, 0x140(%rax)
je 0x149aef
cmpq $0x0, -0x30(%rbp)
je 0x149aef
movq -0x30(%rbp), %rax
movq %rax, -0xe0(%rbp)
jmp 0x149afa
movq -0x28(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xc8(%rbp), %rcx
movq -0xd0(%rbp), %rdx
movl -0xd4(%rbp), %edi
movq -0xe0(%rbp), %r8
movl $0x2d, %esi
callq 0x13fe60
movb $0x1, -0x91(%rbp)
movq -0x50(%rbp), %rax
movss 0x50(%rax), %xmm1
xorps %xmm0, %xmm0
callq 0xdc1c0
movss -0x98(%rbp), %xmm0
movss -0x98(%rbp), %xmm1
leaq -0xb4(%rbp), %rdi
callq 0xbf4c0
movl -0xa4(%rbp), %edx
leaq 0x323fc(%rip), %rdi     # 0x17bf5c
leaq -0xb4(%rbp), %rsi
callq 0x13a640
testb $0x1, %al
jne 0x149b72
jmp 0x149be9
movl -0x14(%rbp), %eax
movl %eax, -0xf4(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x48(%rbp), %rax
testb $0x1, 0x140(%rax)
je 0x149bb2
cmpq $0x0, -0x30(%rbp)
je 0x149bb2
movq -0x30(%rbp), %rax
movq %rax, -0x100(%rbp)
jmp 0x149bbd
movq -0x28(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xe8(%rbp), %rcx
movq -0xf0(%rbp), %rdx
movl -0xf4(%rbp), %edi
movq -0x100(%rbp), %r8
movl $0x2b, %esi
callq 0x13fe60
movb $0x1, -0x91(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xc8090
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
cmpq -0xc0(%rbp), %rax
je 0x149c2d
movq -0x50(%rbp), %rax
movss 0x50(%rax), %xmm1
xorps %xmm0, %xmm0
callq 0xdc1c0
movq -0x10(%rbp), %rdi
movq -0xc0(%rbp), %rsi
xorl %edx, %edx
callq 0x138a30
movq -0x50(%rbp), %rax
movq -0xa0(%rbp), %rcx
movq %rcx, 0x38(%rax)
callq 0xdb640
callq 0xdbe80
jmp 0x149c9a
movq -0x10(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl 0x10(%rbp), %ecx
movl $0x40, %edx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x149cd0
testb $0x1, %al
jne 0x149c6e
jmp 0x149c98
leaq -0x90(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x2198(%rax), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x1409d0
andb $0x1, %al
movb %al, -0x91(%rbp)
jmp 0x149c9a
testb $0x1, -0x91(%rbp)
je 0x149cb2
movq -0x40(%rbp), %rax
movl 0x124(%rax), %edi
callq 0xca110
movb -0x91(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax,%rax)