// File: /workspace/github_c_makefile_star2_O0/adelciotto[P]scg/examples/../scg.h
// Function: scg_image_draw_image_rotate
void scg_image_draw_image_rotate(scg_image_t *dest, scg_image_t *src, int x,
                                 int y, float32_t angle) {
    float32_t src_w = src->width;
    float32_t src_h = src->height;
    float32_t origin_x = src_w * 0.5f;
    float32_t origin_y = src_h * 0.5f;
    float32_t sin_theta = sinf(-angle);
    float32_t cos_theta = cosf(-angle);

    float32_t a = src_w * cos_theta;
    float32_t b = src_h * cos_theta;
    float32_t c = src_w * sin_theta;
    float32_t d = src_h * sin_theta;
    float32_t e = -src_w * cos_theta;
    float32_t f = -src_w * sin_theta;
    int x0 = (int)(e + d);
    int y0 = (int)(f - b);
    int x1 = (int)(a + d);
    int y1 = (int)(c - b);
    int x2 = (int)(a - d);
    int y2 = (int)(c + b);
    int x3 = (int)(e - d);
    int y3 = (int)(f + b);

    int minx =
        scg_min_int(0, scg_min_int(scg_min_int(x0, scg_min_int(x1, x2)), x3));
    int miny =
        scg_min_int(0, scg_min_int(scg_min_int(y0, scg_min_int(y1, y2)), y3));
    int maxx = scg_max_int(x0, scg_max_int(x1, scg_max_int(x2, x3)));
    int maxy = scg_max_int(y0, scg_max_int(y1, scg_max_int(y2, y3)));

    // TODO: Try a pixel subsampling approach to improve the visual quality
    // of the rotation.
    // Reference:
    // http://www.leptonica.org/rotation.html#ROTATION-BY-AREA-MAPPING
    for (int i = miny; i < maxy; i++) {
        for (int j = minx; j < maxx; j++) {
            float32_t image_x = (float32_t)j - origin_x;
            float32_t image_y = (float32_t)i - origin_y;
            float32_t xt =
                (image_x * cos_theta - image_y * sin_theta) + origin_x;
            float32_t yt =
                (image_x * sin_theta + image_y * cos_theta) + origin_y;

            if (xt >= 0 && xt < src_w && yt >= 0 && yt < src_h) {
                scg_pixel_t color = scg_image_get_pixel(src, (int)xt, (int)yt);
                scg_image_set_pixel(dest, x + j, y + i, color);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
cvtsi2ssl (%rax), %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
cvtsi2ssl 0x4(%rax), %xmm0
movss %xmm0, -0x24(%rbp)
movss 0x3de3(%rip), %xmm0     # 0x7004
mulss -0x20(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movss 0x3dd1(%rip), %xmm0     # 0x7004
mulss -0x24(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x1c(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
callq 0x21d0
movss %xmm0, -0x30(%rbp)
movss -0x1c(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
callq 0x2180
movss %xmm0, -0x34(%rbp)
movss -0x20(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x24(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x20(%rbp), %xmm0
mulss -0x30(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x24(%rbp), %xmm0
mulss -0x30(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x20(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss -0x34(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x20(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss -0x30(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x48(%rbp), %xmm0
addss -0x44(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x50(%rbp)
movss -0x4c(%rbp), %xmm0
subss -0x3c(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x54(%rbp)
movss -0x38(%rbp), %xmm0
addss -0x44(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x58(%rbp)
movss -0x40(%rbp), %xmm0
subss -0x3c(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x5c(%rbp)
movss -0x38(%rbp), %xmm0
subss -0x44(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x60(%rbp)
movss -0x40(%rbp), %xmm0
addss -0x3c(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x64(%rbp)
movss -0x48(%rbp), %xmm0
subss -0x44(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x68(%rbp)
movss -0x4c(%rbp), %xmm0
addss -0x3c(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x6c(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0xb0(%rbp)
movl -0x58(%rbp), %edi
movl -0x60(%rbp), %esi
callq 0x24f0
movl -0xb0(%rbp), %edi
movl %eax, %esi
callq 0x24f0
movl %eax, %edi
movl -0x68(%rbp), %esi
callq 0x24f0
movl %eax, %esi
xorl %edi, %edi
callq 0x24f0
movl %eax, -0x70(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0x5c(%rbp), %edi
movl -0x64(%rbp), %esi
callq 0x24f0
movl -0xac(%rbp), %edi
movl %eax, %esi
callq 0x24f0
movl %eax, %edi
movl -0x6c(%rbp), %esi
callq 0x24f0
movl %eax, %esi
xorl %edi, %edi
callq 0x24f0
movl %eax, -0x74(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0x60(%rbp), %edi
movl -0x68(%rbp), %esi
callq 0x2520
movl -0xa8(%rbp), %edi
movl %eax, %esi
callq 0x2520
movl -0xa4(%rbp), %edi
movl %eax, %esi
callq 0x2520
movl %eax, -0x78(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0x64(%rbp), %edi
movl -0x6c(%rbp), %esi
callq 0x2520
movl -0xa0(%rbp), %edi
movl %eax, %esi
callq 0x2520
movl -0x9c(%rbp), %edi
movl %eax, %esi
callq 0x2520
movl %eax, -0x7c(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jge 0x35b6
movl -0x70(%rbp), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x78(%rbp), %eax
jge 0x35a6
cvtsi2ssl -0x84(%rbp), %xmm0
subss -0x28(%rbp), %xmm0
movss %xmm0, -0x88(%rbp)
cvtsi2ssl -0x80(%rbp), %xmm0
subss -0x2c(%rbp), %xmm0
movss %xmm0, -0x8c(%rbp)
movss -0x88(%rbp), %xmm0
movss -0x34(%rbp), %xmm2
movss -0x8c(%rbp), %xmm1
mulss -0x30(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
addss -0x28(%rbp), %xmm0
movss %xmm0, -0x90(%rbp)
movss -0x88(%rbp), %xmm0
movss -0x30(%rbp), %xmm2
movss -0x8c(%rbp), %xmm1
mulss -0x34(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
addss -0x2c(%rbp), %xmm0
movss %xmm0, -0x94(%rbp)
movss -0x90(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x3590
movss -0x90(%rbp), %xmm1
movss -0x20(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x3590
movss -0x94(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x3590
movss -0x94(%rbp), %xmm1
movss -0x24(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x3590
movq -0x10(%rbp), %rdi
cvttss2si -0x90(%rbp), %esi
cvttss2si -0x94(%rbp), %edx
callq 0x2ee0
movl %eax, -0x98(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
addl -0x84(%rbp), %esi
movl -0x18(%rbp), %edx
addl -0x80(%rbp), %edx
movl -0x98(%rbp), %ecx
callq 0x2f60
jmp 0x3592
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x346e
jmp 0x35a8
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x3459
addq $0xb0, %rsp
popq %rbp
retq
nop