// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/include/imgui/imgui_draw.cpp
// Function: ImDrawList::AddConvexPolyFilled(ImVec2 const*, int, unsigned int)
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col)
{
    if (points_count < 3)
        return;

    const ImVec2 uv = _Data->TexUvWhitePixel;

    if (Flags & ImDrawListFlags_AntiAliasedFill)
    {
        // Anti-aliased Fill
        const float AA_SIZE = _FringeScale;
        const ImU32 col_trans = col & ~IM_COL32_A_MASK;
        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)); //-V630
        for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
        {
            const ImVec2& p0 = points[i0];
            const ImVec2& p1 = points[i1];
            float dx = p1.x - p0.x;
            float dy = p1.y - p0.y;
            IM_NORMALIZE2F_OVER_ZERO(dx, dy);
            temp_normals[i0].x = dy;
            temp_normals[i0].y = -dx;
        }

        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];
            float dm_x = (n0.x + n1.x) * 0.5f;
            float dm_y = (n0.y + n1.y) * 0.5f;
            IM_FIXNORMAL2F(dm_x, dm_y);
            dm_x *= AA_SIZE * 0.5f;
            dm_y *= AA_SIZE * 0.5f;

            // Add vertices
            _VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;        // Inner
            _VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _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:
cmpl $0x3, %edx
jl 0x787a1
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, %r14d
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq (%rax), %r12
testb $0x4, 0x30(%rdi)
jne 0x784ee
leal -0x6(%r13,%r13,2), %esi
movq %rbx, %rdi
movl %r13d, %edx
callq 0x77438
movl %r13d, %eax
xorl %ecx, %ecx
movq 0x48(%rbx), %rdx
movq (%r15,%rcx,8), %rsi
movq %rsi, (%rdx)
movq 0x48(%rbx), %rdx
movq %r12, 0x8(%rdx)
movq 0x48(%rbx), %rdx
movl %r14d, 0x10(%rdx)
addq $0x14, %rdx
movq %rdx, 0x48(%rbx)
incq %rcx
cmpq %rcx, %rax
jne 0x7847e
movl 0x34(%rbx), %eax
cmpl $0x4, %r13d
movl $0x3, %ecx
cmovgel %r13d, %ecx
movq 0x50(%rbx), %rdx
addl $-0x2, %ecx
movl %eax, %esi
addl $0x2, %esi
movw %ax, (%rdx)
leal -0x1(%rsi), %edi
movw %di, 0x2(%rdx)
movw %si, 0x4(%rdx)
addq $0x6, %rdx
incl %esi
decl %ecx
jne 0x784c5
movq %rdx, 0x50(%rbx)
movzwl %r13w, %eax
addq $0x34, %rbx
jmp 0x78791
movq %r12, -0x70(%rbp)
movss 0xc0(%rbx), %xmm0
movss %xmm0, -0x2c(%rbp)
movl %r14d, -0x38(%rbp)
andl $0xffffff, %r14d        # imm = 0xFFFFFF
movl %r14d, -0x30(%rbp)
leal -0x6(%r13,%r13,8), %esi
leal (,%r13,2), %edx
movq %rbx, %rdi
movl %edx, -0x34(%rbp)
callq 0x77438
leaq 0x34(%rbx), %rax
movq %rax, -0x68(%rbp)
movl 0x34(%rbx), %esi
leal 0x1(%rsi), %eax
movq %rax, -0x50(%rbp)
movq 0x50(%rbx), %rax
leal -0x2(%r13), %ecx
leal 0x2(%rsi), %edx
movw %si, (%rax)
movw %dx, 0x2(%rax)
addl $0x2, %edx
movw %dx, 0x4(%rax)
addq $0x6, %rax
decl %ecx
jne 0x78543
movq %rsi, -0x58(%rbp)
movq %rax, 0x50(%rbx)
movl %r13d, %eax
movq %rsp, %rdi
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %rdi
movq %rdi, %rsp
movq %r13, %rax
decl %r13d
cmpl $0x2, %eax
movl $0x1, %edx
movq %rax, -0x60(%rbp)
cmovgel %eax, %edx
xorl %r12d, %r12d
xorps %xmm2, %xmm2
movss 0x3ea48(%rip), %xmm6    # 0xb6fe4
movaps 0x3ea1d(%rip), %xmm3    # 0xb6fc0
movl %r13d, %eax
movss -0x2c(%rbp), %xmm5
movq %rdi, -0x48(%rbp)
movq %rdx, -0x78(%rbp)
movslq %eax, %r14
movss (%r15,%r12,8), %xmm4
movss 0x4(%r15,%r12,8), %xmm7
subss (%r15,%r14,8), %xmm4
subss 0x4(%r15,%r14,8), %xmm7
movaps %xmm7, %xmm1
mulss %xmm7, %xmm1
movaps %xmm4, %xmm0
mulss %xmm4, %xmm0
addss %xmm1, %xmm0
ucomiss %xmm2, %xmm0
jbe 0x7863a
jb 0x785ef
sqrtss %xmm0, %xmm0
jmp 0x7862b
movaps %xmm4, -0x90(%rbp)
movss %xmm7, -0x3c(%rbp)
callq 0xc860
movss -0x3c(%rbp), %xmm7
movaps -0x90(%rbp), %xmm4
movaps 0x3e9ad(%rip), %xmm3    # 0xb6fc0
xorps %xmm2, %xmm2
movq -0x78(%rbp), %rdx
movss 0x3e9c2(%rip), %xmm6    # 0xb6fe4
movq -0x48(%rbp), %rdi
movss -0x2c(%rbp), %xmm5
movaps %xmm6, %xmm1
divss %xmm0, %xmm1
mulss %xmm1, %xmm4
mulss %xmm1, %xmm7
xorps %xmm3, %xmm4
movss %xmm7, (%rdi,%r14,8)
movss %xmm4, 0x4(%rdi,%r14,8)
movl %r12d, %eax
leaq 0x1(%r12), %rcx
movq %rcx, %r12
cmpq %rcx, %rdx
jne 0x785b3
mulss 0x3e99e(%rip), %xmm5    # 0xb7004
movq -0x60(%rbp), %rcx
cmpl $0x2, %ecx
movl $0x1, %eax
cmovgel %ecx, %eax
xorl %ecx, %ecx
movss 0x3e985(%rip), %xmm0    # 0xb7004
movq -0x58(%rbp), %r14
movl %r14d, %edx
movl -0x38(%rbp), %r9d
movq -0x70(%rbp), %r10
movl -0x30(%rbp), %r11d
movq -0x50(%rbp), %r12
movslq %r13d, %rsi
movss (%rdi,%rsi,8), %xmm1
movss 0x4(%rdi,%rsi,8), %xmm2
addss (%rdi,%rcx,8), %xmm1
mulss %xmm0, %xmm1
addss 0x4(%rdi,%rcx,8), %xmm2
mulss %xmm0, %xmm2
movaps %xmm2, %xmm3
mulss %xmm2, %xmm3
movaps %xmm1, %xmm4
mulss %xmm1, %xmm4
addss %xmm3, %xmm4
movaps %xmm0, %xmm3
maxss %xmm4, %xmm3
movaps %xmm6, %xmm4
divss %xmm3, %xmm4
mulss %xmm4, %xmm1
mulss %xmm2, %xmm4
mulss %xmm5, %xmm1
mulss %xmm5, %xmm4
movss (%r15,%rcx,8), %xmm2
subss %xmm1, %xmm2
movq 0x48(%rbx), %rdi
movss %xmm2, (%rdi)
movss 0x4(%r15,%rcx,8), %xmm2
subss %xmm4, %xmm2
movss %xmm2, 0x4(%rdi)
movq %r10, 0x8(%rdi)
movq 0x48(%rbx), %rdi
movl %r9d, 0x10(%rdi)
addss (%r15,%rcx,8), %xmm1
movss %xmm1, 0x14(%rdi)
addss 0x4(%r15,%rcx,8), %xmm4
movss %xmm4, 0x18(%rdi)
movq %r10, 0x1c(%rdi)
movq 0x48(%rbx), %rdi
movl %r11d, 0x24(%rdi)
addq $0x28, %rdi
movq %rdi, 0x48(%rbx)
movq 0x50(%rbx), %rdi
movw %dx, (%rdi)
leal (%r14,%rsi,2), %r8d
movw %r8w, 0x2(%rdi)
leal (%r12,%rsi,2), %esi
movw %si, 0x4(%rdi)
movw %si, 0x6(%rdi)
leal 0x1(%rdx), %esi
movw %si, 0x8(%rdi)
movw %dx, 0xa(%rdi)
addq $0xc, %rdi
movq %rdi, 0x50(%rbx)
movq -0x48(%rbp), %rdi
movl %ecx, %r13d
incq %rcx
addl $0x2, %edx
cmpq %rcx, %rax
jne 0x78696
movl -0x34(%rbp), %eax
andl $0xfffe, %eax           # imm = 0xFFFE
movq -0x68(%rbp), %rbx
addl %eax, (%rbx)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq