// File: /workspace/github_c_makefile_star2_O0/adelciotto[P]scg/examples/../scg.h
// Function: scg_image_draw_image_rotate_scale
void scg_image_draw_image_rotate_scale(scg_image_t *dest, scg_image_t *src,
                                       int x, int y, float32_t angle,
                                       float32_t sx, float32_t sy) {
    if (sx <= 0.0f)
        sx = 1.0f;
    if (sy <= 0.0f)
        sy = 1.0f;

    float32_t src_w = src->width;
    float32_t src_h = src->height;
    float32_t src_sw = src_w * sx;
    float32_t src_sh = src_h * sy;

    float32_t ratio_x = src_w / src_sw;
    float32_t ratio_y = src_h / src_sh;
    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_sw * cos_theta;
    float32_t b = src_sh * cos_theta;
    float32_t c = src_sw * sin_theta;
    float32_t d = src_sh * sin_theta;
    float32_t e = -src_sw * cos_theta;
    float32_t f = -src_sw * 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)));

    for (int i = miny; i < maxy; i++) {
        for (int j = minx; j < maxx; j++) {
            float32_t image_x = (float32_t)j * ratio_x - origin_x;
            float32_t image_y = (float32_t)i * ratio_y - 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 $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movss %xmm1, -0x20(%rbp)
movss %xmm2, -0x24(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x20(%rbp), %xmm0
jb 0x35fe
movss 0x3a0f(%rip), %xmm0     # 0x7008
movss %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x24(%rbp), %xmm0
jb 0x3614
movss 0x39f9(%rip), %xmm0     # 0x7008
movss %xmm0, -0x24(%rbp)
movq -0x10(%rbp), %rax
cvtsi2ssl (%rax), %xmm0
movss %xmm0, -0x28(%rbp)
movq -0x10(%rbp), %rax
cvtsi2ssl 0x4(%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x28(%rbp), %xmm0
mulss -0x20(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x2c(%rbp), %xmm0
mulss -0x24(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x28(%rbp), %xmm0
divss -0x30(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x2c(%rbp), %xmm0
divss -0x34(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss 0x3991(%rip), %xmm0     # 0x7004
mulss -0x28(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movss 0x397f(%rip), %xmm0     # 0x7004
mulss -0x2c(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x1c(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
callq 0x21d0
movss %xmm0, -0x48(%rbp)
movss -0x1c(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
callq 0x2180
movss %xmm0, -0x4c(%rbp)
movss -0x30(%rbp), %xmm0
mulss -0x4c(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movss -0x34(%rbp), %xmm0
mulss -0x4c(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x30(%rbp), %xmm0
mulss -0x48(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x34(%rbp), %xmm0
mulss -0x48(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
movss -0x30(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss -0x4c(%rbp), %xmm0
movss %xmm0, -0x60(%rbp)
movss -0x30(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss -0x48(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x60(%rbp), %xmm0
addss -0x5c(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x68(%rbp)
movss -0x64(%rbp), %xmm0
subss -0x54(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x6c(%rbp)
movss -0x50(%rbp), %xmm0
addss -0x5c(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x70(%rbp)
movss -0x58(%rbp), %xmm0
subss -0x54(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x74(%rbp)
movss -0x50(%rbp), %xmm0
subss -0x5c(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x78(%rbp)
movss -0x58(%rbp), %xmm0
addss -0x54(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x7c(%rbp)
movss -0x60(%rbp), %xmm0
subss -0x5c(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x80(%rbp)
movss -0x64(%rbp), %xmm0
addss -0x54(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x84(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0xc8(%rbp)
movl -0x70(%rbp), %edi
movl -0x78(%rbp), %esi
callq 0x24f0
movl -0xc8(%rbp), %edi
movl %eax, %esi
callq 0x24f0
movl %eax, %edi
movl -0x80(%rbp), %esi
callq 0x24f0
movl %eax, %esi
xorl %edi, %edi
callq 0x24f0
movl %eax, -0x88(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0x74(%rbp), %edi
movl -0x7c(%rbp), %esi
callq 0x24f0
movl -0xc4(%rbp), %edi
movl %eax, %esi
callq 0x24f0
movl %eax, %edi
movl -0x84(%rbp), %esi
callq 0x24f0
movl %eax, %esi
xorl %edi, %edi
callq 0x24f0
movl %eax, -0x8c(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0xc0(%rbp)
movl -0x78(%rbp), %edi
movl -0x80(%rbp), %esi
callq 0x2520
movl -0xc0(%rbp), %edi
movl %eax, %esi
callq 0x2520
movl -0xbc(%rbp), %edi
movl %eax, %esi
callq 0x2520
movl %eax, -0x90(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0x7c(%rbp), %edi
movl -0x84(%rbp), %esi
callq 0x2520
movl -0xb8(%rbp), %edi
movl %eax, %esi
callq 0x2520
movl -0xb4(%rbp), %edi
movl %eax, %esi
callq 0x2520
movl %eax, -0x94(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x98(%rbp)
movl -0x98(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x3a6f
movl -0x88(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x90(%rbp), %eax
jge 0x3a59
cvtsi2ssl -0x9c(%rbp), %xmm0
movss -0x38(%rbp), %xmm2
movss -0x40(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0xa0(%rbp)
cvtsi2ssl -0x98(%rbp), %xmm0
movss -0x3c(%rbp), %xmm2
movss -0x44(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0xa4(%rbp)
movss -0xa0(%rbp), %xmm0
movss -0x4c(%rbp), %xmm2
movss -0xa4(%rbp), %xmm1
mulss -0x48(%rbp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
addss -0x40(%rbp), %xmm0
movss %xmm0, -0xa8(%rbp)
movss -0xa0(%rbp), %xmm0
movss -0x48(%rbp), %xmm2
movss -0xa4(%rbp), %xmm1
mulss -0x4c(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
addss -0x44(%rbp), %xmm0
movss %xmm0, -0xac(%rbp)
movss -0xa8(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x3a43
movss -0xa8(%rbp), %xmm1
movss -0x28(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x3a43
movss -0xac(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jb 0x3a43
movss -0xac(%rbp), %xmm1
movss -0x2c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x3a43
movq -0x10(%rbp), %rdi
cvttss2si -0xa8(%rbp), %esi
cvttss2si -0xac(%rbp), %edx
callq 0x2ee0
movl %eax, -0xb0(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
addl -0x9c(%rbp), %esi
movl -0x18(%rbp), %edx
addl -0x98(%rbp), %edx
movl -0xb0(%rbp), %ecx
callq 0x2f60
jmp 0x3a45
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x38e4
jmp 0x3a5b
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x38c6
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax,%rax)