// File: Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::EndGroup()
void ImGui::EndGroup()
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;
    IM_ASSERT(g.GroupStack.Size > 0); // Mismatched BeginGroup()/EndGroup() calls

    ImGuiGroupData& group_data = g.GroupStack.back();
    IM_ASSERT(group_data.WindowID == window->ID); // EndGroup() in wrong window?

    ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos));

    window->DC.CursorPos = group_data.BackupCursorPos;
    window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos);
    window->DC.Indent = group_data.BackupIndent;
    window->DC.GroupOffset = group_data.BackupGroupOffset;
    window->DC.CurrLineSize = group_data.BackupCurrLineSize;
    window->DC.CurrLineTextBaseOffset = group_data.BackupCurrLineTextBaseOffset;
    if (g.LogEnabled)
        g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return

    if (!group_data.EmitItem)
    {
        g.GroupStack.pop_back();
        return;
    }

    window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset);      // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
    ItemSize(group_bb.GetSize());
    ItemAdd(group_bb, 0);

    // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
    // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets.
    // Also if you grep for LastItemId you'll notice it is only used in that context.
    // (The two tests not the same because ActiveIdIsAlive is an ID itself, in order to be able to handle ActiveId being overwritten during the frame.)
    const bool group_contains_curr_active_id = (group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId;
    const bool group_contains_prev_active_id = (group_data.BackupActiveIdPreviousFrameIsAlive == false) && (g.ActiveIdPreviousFrameIsAlive == true);
    if (group_contains_curr_active_id)
        window->DC.LastItemId = g.ActiveId;
    else if (group_contains_prev_active_id)
        window->DC.LastItemId = g.ActiveIdPreviousFrame;
    window->DC.LastItemRect = group_bb;

    // Forward Edited flag
    if (group_contains_curr_active_id && g.ActiveIdHasBeenEditedThisFrame)
        window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;

    // Forward Deactivated flag
    window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDeactivated;
    if (group_contains_prev_active_id && g.ActiveId != g.ActiveIdPreviousFrame)
        window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Deactivated;

    g.GroupStack.pop_back();
    //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255));   // [Debug]
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x1370b1(%rip), %rax    # 0x212f40
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x1ae0(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1c60(%rax)
jle 0xdbeb1
jmp 0xdbed0
leaq 0x98fd3(%rip), %rdi     # 0x174e8b
leaq 0x9704a(%rip), %rsi     # 0x172f09
movl $0x1d82, %edx           # imm = 0x1D82
leaq 0x98fd6(%rip), %rcx     # 0x174ea1
callq 0xd180
movq -0x8(%rbp), %rdi
addq $0x1c60, %rdi           # imm = 0x1C60
callq 0xebf90
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0xdbef5
jmp 0xdbf14
leaq 0x98fbc(%rip), %rdi     # 0x174eb8
leaq 0x97006(%rip), %rsi     # 0x172f09
movl $0x1d85, %edx           # imm = 0x1D85
leaq 0x98f92(%rip), %rcx     # 0x174ea1
callq 0xd180
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
movq %rsi, -0x50(%rbp)
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
callq 0xd7960
movq -0x50(%rbp), %rsi
movlpd %xmm0, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0xe8660
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x4(%rcx), %rcx
movq %rcx, 0xd8(%rax)
movq -0x18(%rbp), %rdi
addq $0xc, %rdi
movq -0x10(%rbp), %rsi
addq $0xf0, %rsi
callq 0xd7960
movlpd %xmm0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0xf0(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movl 0x14(%rcx), %ecx
movl %ecx, 0x118(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movl 0x18(%rcx), %ecx
movl %ecx, 0x120(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x1c(%rcx), %rcx
movq %rcx, 0x100(%rax)
movq -0x18(%rbp), %rax
movss 0x24(%rax), %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x110(%rax)
movq -0x8(%rbp), %rax
testb $0x1, 0x3138(%rax)
je 0xdbff0
movq -0x8(%rbp), %rax
movss 0x96770(%rip), %xmm0    # 0x172758
movss %xmm0, 0x3158(%rax)
movq -0x18(%rbp), %rax
testb $0x1, 0x2d(%rax)
jne 0xdc00f
movq -0x8(%rbp), %rdi
addq $0x1c60, %rdi           # imm = 0x1C60
callq 0xebff0
jmp 0xdc1af
movq -0x10(%rbp), %rax
movss 0x114(%rax), %xmm0
movq -0x18(%rbp), %rax
movss 0x24(%rax), %xmm1
callq 0xc88c0
movq -0x10(%rbp), %rax
movss %xmm0, 0x110(%rax)
leaq -0x28(%rbp), %rdi
callq 0xeb560
movlpd %xmm0, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
movss 0x95f31(%rip), %xmm0    # 0x171f80
callq 0xd6030
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0xd6250
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl 0x1b30(%rdx), %ecx
movb %al, -0x51(%rbp)
je 0xdc0a7
movq -0x8(%rbp), %rax
movl 0x1b34(%rax), %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl 0x1b30(%rdx), %ecx
movb %al, -0x51(%rbp)
jne 0xdc0a7
movq -0x8(%rbp), %rax
cmpl $0x0, 0x1b30(%rax)
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
movq -0x18(%rbp), %rax
movb 0x2c(%rax), %al
andb $0x1, %al
movzbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x52(%rbp)
jne 0xdc0dd
movq -0x8(%rbp), %rax
movb 0x1b74(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
sete %al
movb %al, -0x52(%rbp)
movb -0x52(%rbp), %al
andb $0x1, %al
movb %al, -0x42(%rbp)
testb $0x1, -0x41(%rbp)
je 0xdc101
movq -0x8(%rbp), %rax
movl 0x1b30(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x124(%rax)
jmp 0xdc11d
testb $0x1, -0x42(%rbp)
je 0xdc11b
movq -0x8(%rbp), %rax
movl 0x1b70(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x124(%rax)
jmp 0xdc11d
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, 0x12c(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x134(%rax)
testb $0x1, -0x41(%rbp)
je 0xdc15d
movq -0x8(%rbp), %rax
testb $0x1, 0x1b41(%rax)
je 0xdc15d
movq -0x10(%rbp), %rax
movl 0x128(%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x128(%rax)
movq -0x10(%rbp), %rax
movl 0x128(%rax), %ecx
orl $0x20, %ecx
movl %ecx, 0x128(%rax)
testb $0x1, -0x42(%rbp)
je 0xdc19f
movq -0x8(%rbp), %rax
movl 0x1b30(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x1b70(%rcx), %eax
je 0xdc19f
movq -0x10(%rbp), %rax
movl 0x128(%rax), %ecx
orl $0x40, %ecx
movl %ecx, 0x128(%rax)
movq -0x8(%rbp), %rdi
addq $0x1c60, %rdi           # imm = 0x1C60
callq 0xebff0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)