// File: donfreiday[P]gb/./imgui/imgui_draw.cpp
// Function: ImDrawList::AddConvexPolyFilled(ImVec2 const*, int, unsigned int, bool)
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col, bool anti_aliased)
{
    const ImVec2 uv = GImGui->FontTexUvWhitePixel;
    anti_aliased &= GImGui->Style.AntiAliasedShapes;
    //if (ImGui::GetIO().KeyCtrl) anti_aliased = false; // Debug

    if (anti_aliased)
    {
        // Anti-aliased Fill
        const float AA_SIZE = 1.0f;
        const ImU32 col_trans = col & 0x00ffffff;
        const int idx_count = (points_count-2)*3 + points_count*6;
        const int vtx_count = (points_count*2);
        PrimReserve(idx_count, vtx_count);

        // Add indexes for fill
        unsigned int vtx_inner_idx = _VtxCurrentIdx;
        unsigned int vtx_outer_idx = _VtxCurrentIdx+1;
        for (int i = 2; i < points_count; i++)
        {
            _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+((i-1)<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx+(i<<1));
            _IdxWritePtr += 3;
        }

        // Compute normals
        ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2));
        for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
        {
            const ImVec2& p0 = points[i0];
            const ImVec2& p1 = points[i1];
            ImVec2 diff = p1 - p0;
            diff *= ImInvLength(diff, 1.0f);
            temp_normals[i0].x = diff.y;
            temp_normals[i0].y = -diff.x;
        }

        for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
        {
            // Average normals
            const ImVec2& n0 = temp_normals[i0];
            const ImVec2& n1 = temp_normals[i1];
            ImVec2 dm = (n0 + n1) * 0.5f;
            float dmr2 = dm.x*dm.x + dm.y*dm.y;
            if (dmr2 > 0.000001f)
            {
                float scale = 1.0f / dmr2;
                if (scale > 100.0f) scale = 100.0f;
                dm *= scale;
            }
            dm *= AA_SIZE * 0.5f;

            // Add vertices
            _VtxWritePtr[0].pos = (points[i1] - dm); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;        // Inner
            _VtxWritePtr[1].pos = (points[i1] + dm); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans;  // Outer
            _VtxWritePtr += 2;

            // Add indexes for fringes
            _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+(i0<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx+(i0<<1));
            _IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx+(i1<<1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx+(i1<<1));
            _IdxWritePtr += 6;
        }
        _VtxCurrentIdx += (ImDrawIdx)vtx_count;
    }
    else
    {
        // Non Anti-aliased Fill
        const int idx_count = (points_count-2)*3;
        const int vtx_count = points_count;
        PrimReserve(idx_count, vtx_count);
        for (int i = 0; i < vtx_count; i++)
        {
            _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
            _VtxWritePtr++;
        }
        for (int i = 2; i < points_count; i++)
        {
            _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i);
            _IdxWritePtr += 3;
        }
        _VtxCurrentIdx += (ImDrawIdx)vtx_count;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq 0x3a2dd(%rip), %rax     # 0x794c0
movq (%rax), %rax
movq 0x1720(%rax), %rax
movq %rax, -0x24(%rbp)
leaq 0x3a2c8(%rip), %rax     # 0x794c0
movq (%rax), %rax
movb 0x1459(%rax), %al
andb $0x1, %al
movzbl %al, %ecx
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
andl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
je 0x3f625
movq -0xc0(%rbp), %rdi
movss 0x1bde4(%rip), %xmm0    # 0x5b018
movss %xmm0, -0x28(%rbp)
movl -0x18(%rbp), %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %eax
subl $0x2, %eax
imull $0x3, %eax, %eax
imull $0x6, -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x14(%rbp), %eax
shll %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x3d830
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %ecx
movl %ecx, -0x38(%rbp)
movl 0x38(%rax), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl $0x2, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3f2e6
movq -0xc0(%rbp), %rax
movl -0x38(%rbp), %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, (%rcx)
movl -0x38(%rbp), %ecx
movl -0x40(%rbp), %edx
subl $0x1, %edx
shll %edx
addl %edx, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0x2(%rcx)
movl -0x38(%rbp), %ecx
movl -0x40(%rbp), %edx
shll %edx
addl %edx, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0x4(%rcx)
movq 0x48(%rax), %rcx
addq $0x6, %rcx
movq %rcx, 0x48(%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x3f286
movslq -0x14(%rbp), %rax
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0x48(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3f3b0
movq -0x10(%rbp), %rax
movslq -0x4c(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x3f000
movlpd %xmm0, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
movss 0x1bcbb(%rip), %xmm0    # 0x5b018
callq 0x3f090
leaq -0x68(%rbp), %rdi
callq 0x3f050
movss -0x64(%rbp), %xmm0
movq -0x48(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movss %xmm0, (%rax,%rcx,8)
movss -0x68(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq -0x48(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movss %xmm0, 0x4(%rax,%rcx,8)
movl -0x50(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x50(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x3f313
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3f60d
movq -0x48(%rbp), %rax
movslq -0x6c(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movslq -0x70(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x3f120
movlpd %xmm0, -0x90(%rbp)
leaq -0x90(%rbp), %rdi
movss 0x1bc14(%rip), %xmm0    # 0x5b024
callq 0x3f170
movlpd %xmm0, -0x88(%rbp)
movss -0x88(%rbp), %xmm0
movss -0x88(%rbp), %xmm2
movss -0x84(%rbp), %xmm1
mulss -0x84(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x94(%rbp)
movss -0x94(%rbp), %xmm0
movss 0x21167(%rip), %xmm1    # 0x605c4
ucomiss %xmm1, %xmm0
jbe 0x3f4b3
movss 0x1bbae(%rip), %xmm0    # 0x5b018
divss -0x94(%rbp), %xmm0
movss %xmm0, -0x98(%rbp)
movss -0x98(%rbp), %xmm0
movss 0x1bc9e(%rip), %xmm1    # 0x5b128
ucomiss %xmm1, %xmm0
jbe 0x3f49f
movss 0x1bc91(%rip), %xmm0    # 0x5b128
movss %xmm0, -0x98(%rbp)
movss -0x98(%rbp), %xmm0
leaq -0x88(%rbp), %rdi
callq 0x3f050
leaq -0x88(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
movss 0x1bb5b(%rip), %xmm0    # 0x5b024
callq 0x3f050
movq -0xc8(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq -0x70(%rbp), %rcx
leaq (%rax,%rcx,8), %rdi
callq 0x3f000
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rax
movlpd %xmm0, -0xa0(%rbp)
movq 0x40(%rax), %rcx
movq -0xa0(%rbp), %rdx
movq %rdx, (%rcx)
movq 0x40(%rax), %rcx
movq -0x24(%rbp), %rdx
movq %rdx, 0x8(%rcx)
movl -0x18(%rbp), %ecx
movq 0x40(%rax), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movslq -0x70(%rbp), %rcx
leaq (%rax,%rcx,8), %rdi
callq 0x3f120
movq -0xc0(%rbp), %rax
movlpd %xmm0, -0xa8(%rbp)
movq 0x40(%rax), %rcx
movq -0xa8(%rbp), %rdx
movq %rdx, 0x14(%rcx)
movq 0x40(%rax), %rcx
movq -0x24(%rbp), %rdx
movq %rdx, 0x1c(%rcx)
movl -0x2c(%rbp), %edx
movq 0x40(%rax), %rcx
movl %edx, 0x24(%rcx)
movq 0x40(%rax), %rcx
addq $0x28, %rcx
movq %rcx, 0x40(%rax)
movl -0x38(%rbp), %ecx
movl -0x70(%rbp), %edx
shll %edx
addl %edx, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, (%rcx)
movl -0x38(%rbp), %ecx
movl -0x6c(%rbp), %edx
shll %edx
addl %edx, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0x2(%rcx)
movl -0x3c(%rbp), %ecx
movl -0x6c(%rbp), %edx
shll %edx
addl %edx, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0x4(%rcx)
movl -0x3c(%rbp), %ecx
movl -0x6c(%rbp), %edx
shll %edx
addl %edx, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0x6(%rcx)
movl -0x3c(%rbp), %ecx
movl -0x70(%rbp), %edx
shll %edx
addl %edx, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0x8(%rcx)
movl -0x38(%rbp), %ecx
movl -0x70(%rbp), %edx
shll %edx
addl %edx, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0xa(%rcx)
movq 0x48(%rax), %rcx
addq $0xc, %rcx
movq %rcx, 0x48(%rax)
movl -0x70(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x70(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x3f3c0
movq -0xc0(%rbp), %rax
movl -0x34(%rbp), %ecx
movzwl %cx, %ecx
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
jmp 0x3f744
movq -0xc0(%rbp), %rdi
movl -0x14(%rbp), %eax
subl $0x2, %eax
imull $0x3, %eax, %eax
movl %eax, -0xac(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0xac(%rbp), %esi
movl -0xb0(%rbp), %edx
callq 0x3d830
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
cmpl -0xb0(%rbp), %eax
jge 0x3f6bd
movq -0xc0(%rbp), %rax
movq -0x10(%rbp), %rdx
movslq -0xb4(%rbp), %rsi
movq 0x40(%rax), %rcx
movq (%rdx,%rsi,8), %rdx
movq %rdx, (%rcx)
movq 0x40(%rax), %rcx
movq -0x24(%rbp), %rdx
movq %rdx, 0x8(%rcx)
movl -0x18(%rbp), %edx
movq 0x40(%rax), %rcx
movl %edx, 0x10(%rcx)
movq 0x40(%rax), %rcx
addq $0x14, %rcx
movq %rcx, 0x40(%rax)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x3f65f
movl $0x2, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3f72e
movq -0xc0(%rbp), %rax
movl 0x38(%rax), %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, (%rcx)
movl 0x38(%rax), %ecx
addl -0xb8(%rbp), %ecx
subl $0x1, %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0x2(%rcx)
movl 0x38(%rax), %ecx
addl -0xb8(%rbp), %ecx
movw %cx, %dx
movq 0x48(%rax), %rcx
movw %dx, 0x4(%rcx)
movq 0x48(%rax), %rcx
addq $0x6, %rcx
movq %rcx, 0x48(%rax)
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x3f6c7
movq -0xc0(%rbp), %rax
movl -0xb0(%rbp), %ecx
movzwl %cx, %ecx
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)