// File: Ciaxur[P]yagb-emu/include/imgui/imgui_widgets.cpp
// Function: ImGui::ButtonEx(char const*, ImVec2 const&, int)
bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags)
{
    ImGuiWindow* window = GetCurrentWindow();
    if (window->SkipItems)
        return false;

    ImGuiContext& g = *GImGui;
    const ImGuiStyle& style = g.Style;
    const ImGuiID id = window->GetID(label);
    const ImVec2 label_size = CalcTextSize(label, NULL, true);

    ImVec2 pos = window->DC.CursorPos;
    if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag)
        pos.y += window->DC.CurrLineTextBaseOffset - style.FramePadding.y;
    ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f);

    const ImRect bb(pos, pos + size);
    ItemSize(size, style.FramePadding.y);
    if (!ItemAdd(bb, id))
        return false;

    if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
        flags |= ImGuiButtonFlags_Repeat;
    bool hovered, held;
    bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);

    // Render
    const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
    RenderNavHighlight(bb, id);
    RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
    RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb);

    // Automatically close popups
    //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup))
    //    CloseCurrentPopup();

    IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.LastItemStatusFlags);
    return pressed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
callq 0xeb270
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
testb $0x1, 0x93(%rax)
je 0x13a675
movb $0x0, -0x1(%rbp)
jmp 0x13a913
leaq 0xd88c4(%rip), %rax     # 0x212f40
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x1560, %rax           # imm = 0x1560
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0xa8(%rbp)
callq 0xc9910
movq -0xa8(%rbp), %rsi
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %edx
movss 0x378bc(%rip), %xmm0    # 0x171f80
callq 0xc87e0
movlpd %xmm0, -0x44(%rbp)
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x4c(%rbp)
movl -0x1c(%rbp), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0x13a723
movq -0x38(%rbp), %rax
movss 0x3c(%rax), %xmm1
movq -0x28(%rbp), %rax
movss 0x110(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x13a723
movq -0x28(%rbp), %rax
movss 0x110(%rax), %xmm0
movq -0x38(%rbp), %rax
subss 0x3c(%rax), %xmm0
addss -0x48(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movss 0x38(%rax), %xmm1
movss 0x3c(%rax), %xmm2
addss %xmm1, %xmm1
movss -0x44(%rbp), %xmm3
movss -0x40(%rbp), %xmm0
addss %xmm3, %xmm1
addss %xmm2, %xmm2
addss %xmm0, %xmm2
movsd -0x60(%rbp), %xmm0
callq 0xdcef0
movlpd %xmm0, -0x54(%rbp)
leaq -0x4c(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x139090
movlpd %xmm0, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0xe8660
movq -0x38(%rbp), %rax
movss 0x3c(%rax), %xmm0
leaq -0x54(%rbp), %rdi
callq 0xd6030
movl -0x3c(%rbp), %esi
leaq -0x70(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0xd6250
testb $0x1, %al
jne 0x13a7b7
movb $0x0, -0x1(%rbp)
jmp 0x13a913
movq -0x28(%rbp), %rax
movl 0x1cc(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x13a7d4
movl -0x1c(%rbp), %eax
orl $0x400, %eax            # imm = 0x400
movl %eax, -0x1c(%rbp)
movl -0x3c(%rbp), %esi
movl -0x1c(%rbp), %r8d
leaq -0x70(%rbp), %rdi
leaq -0x79(%rbp), %rdx
leaq -0x7a(%rbp), %rcx
callq 0x139df0
andb $0x1, %al
movb %al, -0x7b(%rbp)
testb $0x1, -0x7a(%rbp)
je 0x13a80a
testb $0x1, -0x79(%rbp)
je 0x13a80a
movl $0x17, %eax
movl %eax, -0xac(%rbp)
jmp 0x13a823
movb -0x79(%rbp), %dl
movl $0x15, %eax
movl $0x16, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %edi
movss 0x3640b(%rip), %xmm0    # 0x170c3c
callq 0xc76e0
movl %eax, -0x80(%rbp)
movl -0x3c(%rbp), %esi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
movl $0x1, %edx
movl %edx, -0xc4(%rbp)
callq 0xc91e0
movl -0xc4(%rbp), %esi
movq -0x70(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x68(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x80(%rbp), %edi
movq -0x38(%rbp), %rax
movss 0x40(%rax), %xmm2
movsd -0x88(%rbp), %xmm0
movsd -0x90(%rbp), %xmm1
callq 0xc8f20
movq -0xc0(%rbp), %rdi
movq -0x38(%rbp), %rsi
addq $0x38, %rsi
callq 0x139090
movq -0xb8(%rbp), %rdi
movlpd %xmm0, -0x98(%rbp)
movq -0x38(%rbp), %rsi
addq $0x38, %rsi
callq 0x1390e0
movlpd %xmm0, -0xa0(%rbp)
movq -0x10(%rbp), %rdx
movq -0x38(%rbp), %r9
addq $0x94, %r9
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x44(%rbp), %r8
leaq -0x70(%rbp), %rax
movq %rax, (%rsp)
callq 0xc8900
jmp 0x13a90b
movb -0x7b(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)