// File: /workspace/github_c_makefile_star2_O0/mesbahamin[P]star-sim/src/sim.c
// Function: sim_bounding_box_render
void sim_bounding_box_render(struct OffscreenBuffer *buffer, struct SimBounds *bounding_box, uint32_t color, struct SimView *view)
{
    if (!buffer)
    {
        // TODO: handle invalid pointer error
        return;
    }

    if (bounding_box)
    {
        int reticle_radius = 3;
        for (int x = bounding_box->center_x - reticle_radius;
            x <= bounding_box->center_x + reticle_radius;
            x++)
        {
            sim_set_pixel(
                    buffer,
                    sim_calc_render_offset(view->zoom, view->dx, x, buffer->width/2),
                    sim_calc_render_offset(view->zoom, view->dy, bounding_box->center_y, buffer->height/2),
                    color);
        }
        for (int y = bounding_box->center_y - reticle_radius;
            y <= bounding_box->center_y + reticle_radius;
            y++)
        {
            sim_set_pixel(
                    buffer,
                    sim_calc_render_offset(view->zoom, view->dx, bounding_box->center_x, buffer->width/2),
                    sim_calc_render_offset(view->zoom, view->dy, y, buffer->height/2),
                    color);
        }

        float half_length_x = bounding_box->side_length_x / 2;
        float half_length_y = bounding_box->side_length_y / 2;

        for (int x = (bounding_box->center_x - half_length_x);
            x <= (bounding_box->center_x + half_length_x);
            ++x)
        {
            sim_set_pixel(
                    buffer,
                    sim_calc_render_offset(view->zoom, view->dx, x, buffer->width/2),
                    sim_calc_render_offset(view->zoom, view->dy, bounding_box->center_y - half_length_y, buffer->height/2),
                    color);
            sim_set_pixel(
                    buffer,
                    sim_calc_render_offset(view->zoom, view->dx, x, buffer->width/2),
                    sim_calc_render_offset(view->zoom, view->dy, bounding_box->center_y + half_length_y, buffer->height/2),
                    color);
        }

        for (int y = (bounding_box->center_y - half_length_y);
            y <= (bounding_box->center_y + half_length_y);
            ++y)
        {
            sim_set_pixel(
                    buffer,
                    sim_calc_render_offset(view->zoom, view->dx, bounding_box->center_x - half_length_x, buffer->width/2),
                    sim_calc_render_offset(view->zoom, view->dy, y, buffer->height/2),
                    color);
            sim_set_pixel(
                    buffer,
                    sim_calc_render_offset(view->zoom, view->dx, bounding_box->center_x + half_length_x, buffer->width/2),
                    sim_calc_render_offset(view->zoom, view->dy, y, buffer->height/2),
                    color);
        }
    }
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movl %edx, 0x84(%rsp)
movq %rcx, 0x78(%rsp)
cmpq $0x0, 0x90(%rsp)
jne 0x2cf3
jmp 0x31d1
cmpq $0x0, 0x88(%rsp)
je 0x31d1
movl $0x3, 0x74(%rsp)
movq 0x88(%rsp), %rax
movss (%rax), %xmm0
cvtsi2ssl 0x74(%rsp), %xmm1
subss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x70(%rsp)
cvtsi2ssl 0x70(%rsp), %xmm1
movq 0x88(%rsp), %rax
movss (%rax), %xmm0
cvtsi2ssl 0x74(%rsp), %xmm2
addss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jb 0x2de3
movq 0x90(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x78(%rsp), %rcx
movss (%rcx), %xmm1
movss 0x8(%rcx), %xmm0
cvtsi2ssl 0x70(%rsp), %xmm2
movl 0x8(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
cvttss2si %xmm0, %rax
movl %eax, 0x58(%rsp)
movq 0x78(%rsp), %rax
movss 0x4(%rax), %xmm1
movss 0x8(%rax), %xmm0
movq 0x88(%rsp), %rax
movss 0x4(%rax), %xmm2
movq 0x90(%rsp), %rax
movl 0xc(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
movq 0x50(%rsp), %rdi
movl 0x58(%rsp), %esi
cvttss2si %xmm0, %rax
movl %eax, %edx
movl 0x84(%rsp), %ecx
callq 0x2960
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x2d28
movq 0x88(%rsp), %rax
movss 0x4(%rax), %xmm0
cvtsi2ssl 0x74(%rsp), %xmm1
subss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x6c(%rsp)
cvtsi2ssl 0x6c(%rsp), %xmm1
movq 0x88(%rsp), %rax
movss 0x4(%rax), %xmm0
cvtsi2ssl 0x74(%rsp), %xmm2
addss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jb 0x2ebd
movq 0x90(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x78(%rsp), %rcx
movss (%rcx), %xmm1
movss 0x8(%rcx), %xmm0
movq 0x88(%rsp), %rcx
movss (%rcx), %xmm2
movl 0x8(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
cvttss2si %xmm0, %rax
movl %eax, 0x4c(%rsp)
movq 0x78(%rsp), %rax
movss 0x4(%rax), %xmm1
movss 0x8(%rax), %xmm0
cvtsi2ssl 0x6c(%rsp), %xmm2
movq 0x90(%rsp), %rax
movl 0xc(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
movq 0x40(%rsp), %rdi
movl 0x4c(%rsp), %esi
cvttss2si %xmm0, %rax
movl %eax, %edx
movl 0x84(%rsp), %ecx
callq 0x2960
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x2e02
movq 0x88(%rsp), %rax
movss 0x8(%rax), %xmm0
movss 0x11b6(%rip), %xmm1     # 0x4088
divss %xmm1, %xmm0
movss %xmm0, 0x68(%rsp)
movq 0x88(%rsp), %rax
movss 0xc(%rax), %xmm0
movss 0x1197(%rip), %xmm1     # 0x4088
divss %xmm1, %xmm0
movss %xmm0, 0x64(%rsp)
movq 0x88(%rsp), %rax
movss (%rax), %xmm0
subss 0x68(%rsp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x60(%rsp)
cvtsi2ssl 0x60(%rsp), %xmm1
movq 0x88(%rsp), %rax
movss (%rax), %xmm0
addss 0x68(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x3066
movq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x78(%rsp), %rcx
movss (%rcx), %xmm1
movss 0x8(%rcx), %xmm0
cvtsi2ssl 0x60(%rsp), %xmm2
movl 0x8(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
cvttss2si %xmm0, %rax
movl %eax, 0x2c(%rsp)
movq 0x78(%rsp), %rax
movss 0x4(%rax), %xmm1
movss 0x8(%rax), %xmm0
movq 0x88(%rsp), %rax
movss 0x4(%rax), %xmm2
movss 0x64(%rsp), %xmm3
subss %xmm3, %xmm2
movq 0x90(%rsp), %rax
movl 0xc(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
movq 0x20(%rsp), %rdi
movl 0x2c(%rsp), %esi
cvttss2si %xmm0, %rax
movl %eax, %edx
movl 0x84(%rsp), %ecx
callq 0x2960
movq 0x90(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x78(%rsp), %rcx
movss (%rcx), %xmm1
movss 0x8(%rcx), %xmm0
cvtsi2ssl 0x60(%rsp), %xmm2
movl 0x8(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
cvttss2si %xmm0, %rax
movl %eax, 0x3c(%rsp)
movq 0x78(%rsp), %rax
movss 0x4(%rax), %xmm1
movss 0x8(%rax), %xmm0
movq 0x88(%rsp), %rax
movss 0x4(%rax), %xmm2
movss 0x64(%rsp), %xmm3
addss %xmm3, %xmm2
movq 0x90(%rsp), %rax
movl 0xc(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
movq 0x30(%rsp), %rdi
movl 0x3c(%rsp), %esi
cvttss2si %xmm0, %rax
movl %eax, %edx
movl 0x84(%rsp), %ecx
callq 0x2960
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x2f15
movq 0x88(%rsp), %rax
movss 0x4(%rax), %xmm0
subss 0x64(%rsp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x5c(%rsp)
cvtsi2ssl 0x5c(%rsp), %xmm1
movq 0x88(%rsp), %rax
movss 0x4(%rax), %xmm0
addss 0x64(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x31cf
movq 0x90(%rsp), %rax
movq %rax, (%rsp)
movq 0x78(%rsp), %rcx
movss (%rcx), %xmm1
movss 0x8(%rcx), %xmm0
movq 0x88(%rsp), %rcx
movss (%rcx), %xmm2
movss 0x68(%rsp), %xmm3
subss %xmm3, %xmm2
movl 0x8(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
cvttss2si %xmm0, %rax
movl %eax, 0xc(%rsp)
movq 0x78(%rsp), %rax
movss 0x4(%rax), %xmm1
movss 0x8(%rax), %xmm0
cvtsi2ssl 0x5c(%rsp), %xmm2
movq 0x90(%rsp), %rax
movl 0xc(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
movq (%rsp), %rdi
movl 0xc(%rsp), %esi
cvttss2si %xmm0, %rax
movl %eax, %edx
movl 0x84(%rsp), %ecx
callq 0x2960
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x78(%rsp), %rcx
movss (%rcx), %xmm1
movss 0x8(%rcx), %xmm0
movq 0x88(%rsp), %rcx
movss (%rcx), %xmm2
movss 0x68(%rsp), %xmm3
addss %xmm3, %xmm2
movl 0x8(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
cvttss2si %xmm0, %rax
movl %eax, 0x1c(%rsp)
movq 0x78(%rsp), %rax
movss 0x4(%rax), %xmm1
movss 0x8(%rax), %xmm0
cvtsi2ssl 0x5c(%rsp), %xmm2
movq 0x90(%rsp), %rax
movl 0xc(%rax), %eax
shrl %eax
cvtsi2ss %eax, %xmm3
callq 0x29e0
movq 0x10(%rsp), %rdi
movl 0x1c(%rsp), %esi
cvttss2si %xmm0, %rax
movl %eax, %edx
movl 0x84(%rsp), %ecx
callq 0x2960
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x3081
jmp 0x31d1
addq $0x98, %rsp
retq
nopl (%rax)