// File: /workspace/github_c_makefile_star2_O1/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 0x4bddb(%rip), %eax     # 0x4fd88
movq 0x4bddc(%rip), %r15     # 0x4fd90
leaq (%rax,%rax,2), %r12
shlq $0x4, %r12
leaq (%r15,%r12), %rax
movq %rax, -0x88(%rbp)
movss 0x2c039(%rip), %xmm0    # 0x30008
movaps %xmm0, %xmm1
callq 0x2899d
movaps %xmm0, -0x40(%rbp)
movss 0x2c021(%rip), %xmm0    # 0x30004
movaps %xmm0, %xmm1
callq 0x2899d
movaps %xmm0, -0x60(%rbp)
movq 0x18(%r15,%r12), %rbx
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x2899d
movaps %xmm0, -0x50(%rbp)
movss 0x2c019(%rip), %xmm0    # 0x30024
movaps %xmm0, %xmm1
callq 0x2899d
movaps %xmm0, -0x80(%rbp)
movss 0x2bfe5(%rip), %xmm0    # 0x30004
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
callq 0x289b2
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 0x297cb
xorps %xmm2, %xmm2
movss 0x2bfa9(%rip), %xmm0    # 0x30004
movss 0x2bfa5(%rip), %xmm1    # 0x30008
movaps %xmm0, %xmm3
callq 0x289b2
movaps %xmm0, -0x40(%rbp)
movaps %xmm1, -0x60(%rbp)
xorl %edi, %edi
callq 0x2958a
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rax), %xmm0
movsd 0x2c006(%rip), %xmm1    # 0x30090
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x2899d
movaps %xmm0, -0x50(%rbp)
xorps %xmm1, %xmm1
movss 0x2bf50(%rip), %xmm0    # 0x30004
callq 0x2899d
movaps %xmm0, %xmm1
movl $0x1, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29889
xorps %xmm1, %xmm1
movss 0x2bf22(%rip), %xmm0    # 0x30004
callq 0x2899d
movaps %xmm0, -0x50(%rbp)
movss 0x2bf11(%rip), %xmm0    # 0x30004
movaps %xmm0, %xmm1
callq 0x2899d
movaps %xmm0, %xmm1
movl $0x1, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29889
movss 0x2bee3(%rip), %xmm0    # 0x30004
movaps %xmm0, %xmm1
callq 0x2899d
movaps %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movss 0x2becc(%rip), %xmm1    # 0x30004
callq 0x2899d
movaps %xmm0, %xmm1
movl $0x1, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29889
xorps %xmm0, %xmm0
movss 0x2be9e(%rip), %xmm1    # 0x30004
callq 0x2899d
movaps %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
callq 0x2899d
movaps %xmm0, %xmm1
movl $0x1, %edi
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movss -0x80(%rbp), %xmm4
callq 0x29889
xorps %xmm0, %xmm0
movss 0x2be65(%rip), %xmm1    # 0x30008
movss 0x2be59(%rip), %xmm2    # 0x30004
movaps %xmm1, %xmm3
callq 0x289b2
movaps %xmm0, -0xf0(%rbp)
movaps %xmm1, -0xe0(%rbp)
movss 0x2be5f(%rip), %xmm3    # 0x30028
xorps %xmm2, %xmm2
movss 0x2be30(%rip), %xmm0    # 0x30004
movss 0x2be2c(%rip), %xmm1    # 0x30008
callq 0x289b2
movaps %xmm0, -0xd0(%rbp)
movaps %xmm1, -0xc0(%rbp)
xorps %xmm0, %xmm0
movss 0x2be0e(%rip), %xmm1    # 0x30008
movss 0x2be02(%rip), %xmm2    # 0x30004
movss 0x2be1e(%rip), %xmm3    # 0x30028
callq 0x289b2
movaps %xmm0, -0xb0(%rbp)
movaps %xmm1, -0xa0(%rbp)
movq 0x8(%r15,%r12), %rbx
subq (%r15,%r12), %rbx
shrq $0x3, %rbx
testl %ebx, %ebx
jle 0x42e7
movsd 0x4bb6e(%rip), %xmm0    # 0x4fda8
movaps %xmm0, -0x60(%rbp)
movss 0x4bb6e(%rip), %xmm0    # 0x4fdb4
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 0x29889
movaps -0x60(%rbp), %xmm0
movaps -0x40(%rbp), %xmm1
callq 0x28a2a
movss -0x50(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x42d9
movaps -0x60(%rbp), %xmm0
movaps -0x40(%rbp), %xmm1
callq 0x28a2a
movss %xmm0, -0x50(%rbp)
movl %r13d, -0x64(%rbp)
movq %r14, %r13
cmpq %r14, %r15
jne 0x4263
movl -0x64(%rbp), %r15d
jmp 0x42ed
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
xorl %edi, %edi
callq 0x2958a
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
xorl %edi, %edi
callq 0x2958a
testl %ebx, %ebx
jle 0x439e
movsd 0x2bd88(%rip), %xmm0    # 0x300a0
divsd -0x40(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rax), %xmm0
movsd 0x2bd72(%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 0x437e
movaps -0xb0(%rbp), %xmm1
movaps -0xa0(%rbp), %xmm2
movss -0x60(%rbp), %xmm3
jmp 0x4391
movaps -0xd0(%rbp), %xmm1
movaps -0xc0(%rbp), %xmm2
movss -0x40(%rbp), %xmm3
callq 0x2989c
incq %r14
cmpq %r14, %rbx
jne 0x434f
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq