// File: /workspace/github_c_makefile_star2_O0/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
subq $0x1e0, %rsp            # imm = 0x1E0
movl 0x65117(%rip), %eax     # 0x69db8
movl %eax, %esi
leaq 0x65116(%rip), %rdi     # 0x69dc0
callq 0x57f0
movq %rax, -0x8(%rbp)
movss 0x40355(%rip), %xmm1    # 0x45010
movss %xmm1, -0x1c4(%rbp)
movaps %xmm1, %xmm0
callq 0x372e0
movlpd %xmm0, -0x10(%rbp)
movss 0x40330(%rip), %xmm1    # 0x45008
movss %xmm1, -0x1d0(%rbp)
movaps %xmm1, %xmm0
callq 0x372e0
movlpd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x1e0(%rbp)
xorps %xmm1, %xmm1
movss %xmm1, -0x1c8(%rbp)
movaps %xmm1, %xmm0
callq 0x372e0
movlpd %xmm0, -0x20(%rbp)
movss 0x4030c(%rip), %xmm1    # 0x45028
movaps %xmm1, %xmm0
callq 0x372e0
movss -0x1d0(%rbp), %xmm3
movlpd %xmm0, -0x28(%rbp)
movaps %xmm3, %xmm0
movaps %xmm3, %xmm1
movaps %xmm3, %xmm2
callq 0x37390
movq -0x1e0(%rbp), %rsi
movss -0x1c8(%rbp), %xmm2
movlpd %xmm0, -0x38(%rbp)
movlpd %xmm1, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x20(%rbp), %xmm3
movsd -0x28(%rbp), %xmm4
movsd -0x38(%rbp), %xmm5
movsd -0x30(%rbp), %xmm6
xorl %edi, %edi
movl %edi, -0x1d8(%rbp)
callq 0x38cf0
movss -0x1c8(%rbp), %xmm2
movss -0x1c4(%rbp), %xmm1
movss -0x1d0(%rbp), %xmm3
movaps %xmm3, %xmm0
callq 0x37390
movl -0x1d8(%rbp), %edi
movlpd %xmm0, -0x48(%rbp)
movlpd %xmm1, -0x40(%rbp)
callq 0x389e0
movss -0x1c8(%rbp), %xmm1
movss 0x10(%rax), %xmm0
cvtss2sd %xmm0, %xmm2
movsd 0x402bf(%rip), %xmm0    # 0x45090
divsd %xmm2, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x4c(%rbp)
movaps %xmm1, %xmm0
callq 0x372e0
movss -0x1c8(%rbp), %xmm1
movaps %xmm0, %xmm2
movss -0x1d0(%rbp), %xmm0
movlpd %xmm2, -0x54(%rbp)
callq 0x372e0
movlpd %xmm0, -0x5c(%rbp)
movups -0x48(%rbp), %xmm0
movaps %xmm0, -0x70(%rbp)
movss -0x4c(%rbp), %xmm4
movsd -0x54(%rbp), %xmm0
movsd -0x5c(%rbp), %xmm1
movsd -0x70(%rbp), %xmm2
movsd -0x68(%rbp), %xmm3
movl $0x1, %edi
movl %edi, -0x1d4(%rbp)
callq 0x38ed0
movss -0x1c8(%rbp), %xmm1
movss -0x1d0(%rbp), %xmm0
callq 0x372e0
movss -0x1d0(%rbp), %xmm1
movlpd %xmm0, -0x78(%rbp)
movaps %xmm1, %xmm0
callq 0x372e0
movl -0x1d4(%rbp), %edi
movlpd %xmm0, -0x80(%rbp)
movups -0x48(%rbp), %xmm0
movaps %xmm0, -0x90(%rbp)
movss -0x4c(%rbp), %xmm4
movsd -0x78(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
movsd -0x90(%rbp), %xmm2
movsd -0x88(%rbp), %xmm3
callq 0x38ed0
movss -0x1d0(%rbp), %xmm1
movaps %xmm1, %xmm0
callq 0x372e0
movss -0x1d0(%rbp), %xmm1
movaps %xmm0, %xmm2
movss -0x1c8(%rbp), %xmm0
movlpd %xmm2, -0x98(%rbp)
callq 0x372e0
movl -0x1d4(%rbp), %edi
movlpd %xmm0, -0xa0(%rbp)
movups -0x48(%rbp), %xmm0
movaps %xmm0, -0xb0(%rbp)
movss -0x4c(%rbp), %xmm4
movsd -0x98(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
movsd -0xb0(%rbp), %xmm2
movsd -0xa8(%rbp), %xmm3
callq 0x38ed0
movss -0x1c8(%rbp), %xmm0
movss -0x1d0(%rbp), %xmm1
callq 0x372e0
movss -0x1c8(%rbp), %xmm1
movlpd %xmm0, -0xb8(%rbp)
movaps %xmm1, %xmm0
callq 0x372e0
movl -0x1d4(%rbp), %edi
movlpd %xmm0, -0xc0(%rbp)
movups -0x48(%rbp), %xmm0
movaps %xmm0, -0xd0(%rbp)
movss -0x4c(%rbp), %xmm4
movsd -0xb8(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm1
movsd -0xd0(%rbp), %xmm2
movsd -0xc8(%rbp), %xmm3
callq 0x38ed0
movss -0x1c8(%rbp), %xmm0
movss -0x1c4(%rbp), %xmm3
movss -0x1d0(%rbp), %xmm2
movaps %xmm3, %xmm1
callq 0x37390
movss -0x1c8(%rbp), %xmm2
movaps %xmm0, %xmm4
movss -0x1d0(%rbp), %xmm0
movaps %xmm1, %xmm3
movss -0x1c4(%rbp), %xmm1
movlpd %xmm4, -0xe0(%rbp)
movlpd %xmm3, -0xd8(%rbp)
movss 0x40056(%rip), %xmm3    # 0x4502c
movss %xmm3, -0x1cc(%rbp)
callq 0x37390
movss -0x1d0(%rbp), %xmm2
movss -0x1cc(%rbp), %xmm3
movaps %xmm0, %xmm5
movss -0x1c8(%rbp), %xmm0
movaps %xmm1, %xmm4
movss -0x1c4(%rbp), %xmm1
movlpd %xmm5, -0xf0(%rbp)
movlpd %xmm4, -0xe8(%rbp)
callq 0x37390
movlpd %xmm0, -0x100(%rbp)
movlpd %xmm1, -0xf8(%rbp)
movl $0xffffffff, -0x104(%rbp) # imm = 0xFFFFFFFF
movss 0x64da4(%rip), %xmm0    # 0x69de4
movss %xmm0, -0x108(%rbp)
movq 0x64d89(%rip), %rax     # 0x69dd8
movq %rax, -0x110(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
callq 0x53d0
movl %eax, -0x11c(%rbp)
movl $0x0, -0x120(%rbp)
movl -0x120(%rbp), %eax
cmpl -0x11c(%rbp), %eax
jge 0x51cb
movq -0x118(%rbp), %rdi
movslq -0x120(%rbp), %rsi
callq 0x53f0
movq (%rax), %rax
movq %rax, -0x128(%rbp)
movq -0x118(%rbp), %rdi
movl -0x120(%rbp), %eax
incl %eax
movl -0x11c(%rbp), %ecx
cltd
idivl %ecx
movslq %edx, %rsi
callq 0x53f0
movq (%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x140(%rbp)
movups -0xe0(%rbp), %xmm0
movaps %xmm0, -0x150(%rbp)
movss -0x4c(%rbp), %xmm4
movsd -0x138(%rbp), %xmm0
movsd -0x140(%rbp), %xmm1
movsd -0x150(%rbp), %xmm2
movsd -0x148(%rbp), %xmm3
movl $0x2, %edi
callq 0x38ed0
movq -0x110(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x160(%rbp)
movsd -0x158(%rbp), %xmm0
movsd -0x160(%rbp), %xmm1
callq 0x37550
movaps %xmm0, %xmm1
movss -0x108(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x51b5
movl -0x120(%rbp), %eax
movl %eax, -0x104(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x170(%rbp)
movsd -0x168(%rbp), %xmm0
movsd -0x170(%rbp), %xmm1
callq 0x37550
movss %xmm0, -0x108(%rbp)
jmp 0x51b7
movl -0x120(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x120(%rbp)
jmp 0x507d
xorl %edi, %edi
callq 0x389e0
movss 0x10(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3fec5(%rip), %xmm0    # 0x450a8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x174(%rbp)
xorl %edi, %edi
callq 0x389e0
movss 0x10(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3fe95(%rip), %xmm0    # 0x450a0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x178(%rbp)
movl $0x0, -0x17c(%rbp)
movl -0x17c(%rbp), %eax
cmpl -0x11c(%rbp), %eax
jge 0x5306
movq -0x118(%rbp), %rdi
movslq -0x17c(%rbp), %rsi
callq 0x53f0
movq (%rax), %rax
movq %rax, -0x184(%rbp)
movl -0x104(%rbp), %eax
cmpl -0x17c(%rbp), %eax
jne 0x52aa
movq -0x184(%rbp), %rax
movq %rax, -0x190(%rbp)
movups -0x100(%rbp), %xmm0
movaps %xmm0, -0x1a0(%rbp)
movss -0x178(%rbp), %xmm3
movsd -0x190(%rbp), %xmm0
movsd -0x1a0(%rbp), %xmm1
movsd -0x198(%rbp), %xmm2
movl $0x3, %edi
callq 0x38f40
jmp 0x52f0
movq -0x184(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movups -0xf0(%rbp), %xmm0
movaps %xmm0, -0x1c0(%rbp)
movss -0x174(%rbp), %xmm3
movsd -0x1a8(%rbp), %xmm0
movsd -0x1c0(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm2
movl $0x3, %edi
callq 0x38f40
jmp 0x52f2
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0x5225
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nop