// File: /workspace/github_c_makefile_star2_O3/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 $0xc8, %rsp
movl 0x4bec6(%rip), %eax     # 0x4fd78
movq 0x4bec7(%rip), %r15     # 0x4fd80
leaq (%rax,%rax,2), %r12
shlq $0x4, %r12
leaq (%r15,%r12), %rax
movq %rax, -0x88(%rbp)
movss 0x2c134(%rip), %xmm0    # 0x30008
movaps %xmm0, %xmm1
callq 0x28631
movaps %xmm0, -0x40(%rbp)
movss 0x2c11c(%rip), %xmm0    # 0x30004
movaps %xmm0, %xmm1
callq 0x28631
movaps %xmm0, -0x60(%rbp)
movq 0x18(%r15,%r12), %rbx
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x28631
movaps %xmm0, -0x50(%rbp)
movss 0x2c114(%rip), %xmm0    # 0x30024
movaps %xmm0, %xmm1
callq 0x28631
movaps %xmm0, -0x80(%rbp)
movss 0x2c0e0(%rip), %xmm0    # 0x30004
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
callq 0x28646
movaps %xmm0, %xmm5
movaps %xmm1, %xmm6
xorps %xmm2, %xmm2
xorl %edi, %edi
movaps -0x40(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
movq %rbx, %rsi
movaps -0x50(%rbp), %xmm3
movaps -0x80(%rbp), %xmm4
callq 0x29386
xorps %xmm2, %xmm2
movss 0x2c0a4(%rip), %xmm0    # 0x30004
movss 0x2c0a0(%rip), %xmm1    # 0x30008
movaps %xmm0, %xmm3
callq 0x28646
movaps %xmm0, -0x40(%rbp)
movaps %xmm1, -0x60(%rbp)
xorl %edi, %edi
callq 0x29145
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rax), %xmm0
movsd 0x2c101(%rip), %xmm1    # 0x30090
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x28631
movaps %xmm0, -0x50(%rbp)
xorps %xmm1, %xmm1
movss 0x2c04b(%rip), %xmm0    # 0x30004
callq 0x28631
movaps %xmm0, %xmm1
movl $0x1, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29444
xorps %xmm1, %xmm1
movss 0x2c01d(%rip), %xmm0    # 0x30004
callq 0x28631
movaps %xmm0, -0x50(%rbp)
movss 0x2c00c(%rip), %xmm0    # 0x30004
movaps %xmm0, %xmm1
callq 0x28631
movaps %xmm0, %xmm1
movl $0x1, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29444
movss 0x2bfde(%rip), %xmm0    # 0x30004
movaps %xmm0, %xmm1
callq 0x28631
movaps %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movss 0x2bfc7(%rip), %xmm1    # 0x30004
callq 0x28631
movaps %xmm0, %xmm1
movl $0x1, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29444
xorps %xmm0, %xmm0
movss 0x2bf99(%rip), %xmm1    # 0x30004
callq 0x28631
movaps %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x28631
movaps %xmm0, %xmm1
movl $0x1, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29444
xorps %xmm0, %xmm0
movss 0x2bf60(%rip), %xmm1    # 0x30008
movss 0x2bf54(%rip), %xmm2    # 0x30004
movaps %xmm1, %xmm3
callq 0x28646
movaps %xmm0, -0xf0(%rbp)
movaps %xmm1, -0xe0(%rbp)
movss 0x2bf5a(%rip), %xmm3    # 0x30028
xorps %xmm2, %xmm2
movss 0x2bf2b(%rip), %xmm0    # 0x30004
movss 0x2bf27(%rip), %xmm1    # 0x30008
callq 0x28646
movaps %xmm0, -0xd0(%rbp)
movaps %xmm1, -0xc0(%rbp)
xorps %xmm0, %xmm0
movss 0x2bf09(%rip), %xmm1    # 0x30008
movss 0x2befd(%rip), %xmm2    # 0x30004
movss 0x2bf19(%rip), %xmm3    # 0x30028
callq 0x28646
movaps %xmm0, -0xb0(%rbp)
movaps %xmm1, -0xa0(%rbp)
movq 0x8(%r15,%r12), %rbx
subq (%r15,%r12), %rbx
shrq $0x3, %rbx
testl %ebx, %ebx
jle 0x41ec
movsd 0x4bc59(%rip), %xmm0    # 0x4fd98
movaps %xmm0, -0x60(%rbp)
movss 0x4bc59(%rip), %xmm0    # 0x4fda4
movss %xmm0, -0x50(%rbp)
movl %ebx, %r15d
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
leaq -0x1(%r15), %r12
movl $0xffffffff, -0x64(%rbp) # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movq -0x88(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r13,8), %xmm1
movaps %xmm1, -0x40(%rbp)
leaq 0x1(%r13), %r14
cmpq %r13, %r12
movl %r14d, %ecx
movl $0x0, %edx
cmovneq %rcx, %rdx
movsd (%rax,%rdx,8), %xmm0
movl $0x2, %edi
movaps -0xf0(%rbp), %xmm2
movaps -0xe0(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29444
movaps -0x60(%rbp), %xmm0
movaps -0x40(%rbp), %xmm1
callq 0x286b0
movss -0x50(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x41de
movaps -0x60(%rbp), %xmm0
movaps -0x40(%rbp), %xmm1
callq 0x286b0
movss %xmm0, -0x50(%rbp)
movl %r13d, -0x64(%rbp)
movq %r14, %r13
cmpq %r14, %r15
jne 0x4168
movl -0x64(%rbp), %r15d
jmp 0x41f2
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %edi, %edi
callq 0x29145
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
xorl %edi, %edi
callq 0x29145
testl %ebx, %ebx
jle 0x42a3
movsd 0x2be83(%rip), %xmm0    # 0x300a0
divsd -0x40(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rax), %xmm0
movsd 0x2be6d(%rip), %xmm1    # 0x300a8
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, -0x60(%rbp)
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movq -0x88(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r14,8), %xmm0
movl $0x3, %edi
cmpq %r14, %r15
jne 0x4283
movaps -0xb0(%rbp), %xmm1
movaps -0xa0(%rbp), %xmm2
movss -0x60(%rbp), %xmm3
jmp 0x4296
movaps -0xd0(%rbp), %xmm1
movaps -0xc0(%rbp), %xmm2
movss -0x40(%rbp), %xmm3
callq 0x29457
incq %r14
cmpq %r14, %rbx
jne 0x4254
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq