// File: /workspace/github_c_makefile_star2_O2/FredTheDino[P]Fog/src/rain/editor_main.cpp
// Function: sprite_editor_draw()
void sprite_editor_draw() {
    EditableSprite *sprite = &global_editor.sprites[global_editor.current_sprite];
    fog_renderer_push_sprite_rect(0, fog_V2(0.5, 0.5), fog_V2(1, 1), 0, sprite->sheet, fog_V2(0, 0), fog_V2(512, 512), fog_V4(1, 1, 1, 1));
    const Vec4 line_color = fog_V4(1.0, 0.5, 0.0, 1.0);
    const f32 line_width = 0.03 / fog_renderer_fetch_camera(0)->zoom;
    fog_renderer_push_line(1, fog_V2(0, 0), fog_V2(1, 0), line_color, line_width);
    fog_renderer_push_line(1, fog_V2(1, 0), fog_V2(1, 1), line_color, line_width);
    fog_renderer_push_line(1, fog_V2(1, 1), fog_V2(0, 1), line_color, line_width);
    fog_renderer_push_line(1, fog_V2(0, 1), fog_V2(0, 0), line_color, line_width);

    const Vec4 shape_color = fog_V4(0.0, 0.5, 1.0, 0.5);
    const Vec4 point_color = fog_V4(1.0, 0.5, 0.0, 0.75);
    const Vec4 closest_point_color = fog_V4(0.0, 0.5, 1.0, 0.75);

    s32 closest = -1;
    f32 dist = global_editor.worst_best_distance;
    Vec2 point = global_editor.cursor;

    std::vector<Vec2> *points = &sprite->points;
    s32 num_points = points->size();
    for (s32 i = 0; i < num_points; i++) {
        Vec2 curr = (*points)[i];
        Vec2 next = (*points)[(i + 1) % num_points];
        fog_renderer_push_line(2, next, curr, shape_color, line_width);

        if (fog_distance_v2(point, curr) < dist) {
            closest = i;
            dist = fog_distance_v2(point, curr);
        }
    }

    const f32 point_size = 0.04 / fog_renderer_fetch_camera(0)->zoom;
    const f32 point_size_closest = 0.045 / fog_renderer_fetch_camera(0)->zoom;
    for (s32 i = 0; i < num_points; i++) {
        Vec2 curr = (*points)[i];
        if (closest == i)
            fog_renderer_push_point(3, curr, closest_point_color, point_size_closest);
        else
            fog_renderer_push_point(3, curr, point_color, point_size);
    }

    // fog_util_debug_text(sprite->name, Renderer::fetch_camera()->aspect_ratio);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl 0x472b7(%rip), %eax     # 0x4ad88
movq 0x472b8(%rip), %rcx     # 0x4ad90
imulq $0x30, %rax, %r12
leaq (%rcx,%r12), %r15
movq %rcx, %r13
movss 0x2751d(%rip), %xmm0    # 0x2b008
movaps %xmm0, %xmm1
callq 0x2530a
movaps %xmm0, -0x50(%rbp)
movss 0x27505(%rip), %xmm0    # 0x2b004
movaps %xmm0, %xmm1
callq 0x2530a
movaps %xmm0, -0x70(%rbp)
movq 0x18(%r13,%r12), %r14
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x2530a
movaps %xmm0, -0x60(%rbp)
movss 0x274fd(%rip), %xmm0    # 0x2b024
movaps %xmm0, %xmm1
callq 0x2530a
movaps %xmm0, -0x40(%rbp)
movss 0x274c9(%rip), %xmm0    # 0x2b004
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
callq 0x2531f
movaps %xmm0, %xmm5
movaps %xmm1, %xmm6
xorl %ebx, %ebx
xorps %xmm2, %xmm2
xorl %edi, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x70(%rbp), %xmm1
movq %r14, %rsi
movaps -0x60(%rbp), %xmm3
movaps -0x40(%rbp), %xmm4
callq 0x25a45
xorps %xmm2, %xmm2
movss 0x2748b(%rip), %xmm0    # 0x2b004
movss 0x27487(%rip), %xmm1    # 0x2b008
movaps %xmm0, %xmm3
callq 0x2531f
movaps %xmm0, -0x50(%rbp)
movaps %xmm1, -0x60(%rbp)
xorl %edi, %edi
callq 0x258d0
cvtss2sd 0x10(%rax), %xmm0
movsd 0x274eb(%rip), %xmm1    # 0x2b090
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x2530a
movaps %xmm0, -0x40(%rbp)
xorps %xmm1, %xmm1
movss 0x27438(%rip), %xmm0    # 0x2b004
callq 0x2530a
movaps %xmm0, %xmm1
pushq $0x1
popq %r14
movl %r14d, %edi
movaps -0x40(%rbp), %xmm0
movaps -0x50(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x70(%rbp), %xmm4
callq 0x25a6d
xorps %xmm1, %xmm1
movss 0x27408(%rip), %xmm0    # 0x2b004
callq 0x2530a
movaps %xmm0, -0x40(%rbp)
movss 0x273f7(%rip), %xmm0    # 0x2b004
movaps %xmm0, %xmm1
callq 0x2530a
movaps %xmm0, %xmm1
movl %r14d, %edi
movaps -0x40(%rbp), %xmm0
movaps -0x50(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x70(%rbp), %xmm4
callq 0x25a6d
movss 0x273cb(%rip), %xmm0    # 0x2b004
movaps %xmm0, %xmm1
callq 0x2530a
movaps %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movss 0x273b4(%rip), %xmm1    # 0x2b004
callq 0x2530a
movaps %xmm0, %xmm1
movl %r14d, %edi
movaps -0x40(%rbp), %xmm0
movaps -0x50(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x70(%rbp), %xmm4
callq 0x25a6d
xorps %xmm0, %xmm0
movss 0x27388(%rip), %xmm1    # 0x2b004
callq 0x2530a
movaps %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x2530a
movaps %xmm0, %xmm1
movl %r14d, %edi
movaps -0x40(%rbp), %xmm0
movaps -0x50(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x70(%rbp), %xmm4
callq 0x25a6d
xorps %xmm0, %xmm0
movss 0x27351(%rip), %xmm1    # 0x2b008
movss 0x27345(%rip), %xmm2    # 0x2b004
movaps %xmm1, %xmm3
callq 0x2531f
movaps %xmm0, -0xe0(%rbp)
movaps %xmm1, -0xd0(%rbp)
movss 0x2734b(%rip), %xmm3    # 0x2b028
xorps %xmm2, %xmm2
movss 0x2731c(%rip), %xmm0    # 0x2b004
movss 0x27318(%rip), %xmm1    # 0x2b008
callq 0x2531f
movaps %xmm0, -0xc0(%rbp)
movaps %xmm1, -0xb0(%rbp)
xorps %xmm0, %xmm0
movss 0x272fa(%rip), %xmm1    # 0x2b008
movss 0x272ee(%rip), %xmm2    # 0x2b004
movss 0x2730a(%rip), %xmm3    # 0x2b028
callq 0x2531f
movaps %xmm0, -0xa0(%rbp)
movaps %xmm1, -0x90(%rbp)
movss 0x4707b(%rip), %xmm0    # 0x4adb4
movss %xmm0, -0x40(%rbp)
movq %r13, %rax
movq 0x8(%r13,%r12), %r13
subq (%rax,%r12), %r13
movsd 0x47056(%rip), %xmm0    # 0x4ada8
movaps %xmm0, -0x60(%rbp)
shrq $0x3, %r13
testl %r13d, %r13d
movl $0x0, %r12d
cmovgl %r13d, %r12d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0x78(%rbp)
pushq $0x2
popq %r14
cmpq %rbx, %r12
je 0x3de1
movq (%r15), %rcx
movsd (%rcx,%rbx,8), %xmm1
movaps %xmm1, -0x50(%rbp)
incq %rbx
movl %ebx, %eax
cltd
idivl %r13d
movsd (%rcx,%rdx,8), %xmm0
movl %r14d, %edi
movaps -0xe0(%rbp), %xmm2
movaps -0xd0(%rbp), %xmm3
movss -0x70(%rbp), %xmm4
callq 0x25a6d
movaps -0x60(%rbp), %xmm0
movaps -0x50(%rbp), %xmm1
callq 0x25389
movss -0x40(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x3d74
movaps -0x60(%rbp), %xmm0
movaps -0x50(%rbp), %xmm1
callq 0x25389
movss %xmm0, -0x40(%rbp)
leaq -0x1(%rbx), %rax
movq %rax, -0x78(%rbp)
jmp 0x3d74
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x258d0
cvtss2sd 0x10(%rax), %xmm0
movsd 0x272a8(%rip), %xmm1    # 0x2b0a0
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, -0x50(%rbp)
xorl %edi, %edi
callq 0x258d0
cvtss2sd 0x10(%rax), %xmm0
movsd 0x2728f(%rip), %xmm1    # 0x2b0a8
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, -0x70(%rbp)
movl -0x78(%rbp), %r13d
pushq $0x3
popq %rbx
cmpq %r14, %r12
je 0x3e74
movq (%r15), %rax
movsd (%rax,%r14,8), %xmm0
movl %ebx, %edi
cmpq %r14, %r13
jne 0x3e57
movaps -0xa0(%rbp), %xmm1
movaps -0x90(%rbp), %xmm2
movss -0x70(%rbp), %xmm3
jmp 0x3e6a
movaps -0xc0(%rbp), %xmm1
movaps -0xb0(%rbp), %xmm2
movss -0x50(%rbp), %xmm3
callq 0x25a77
incq %r14
jmp 0x3e2d
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq