// File: /workspace/github_c_makefile_star2_O0/adelciotto[P]scg/examples/../scg.h
// Function: scg_image_set_pixel
void scg_image_set_pixel(scg_image_t *image, int x, int y, scg_pixel_t color) {
    int w = image->width;
    int h = image->height;

    if (x < 0 || x >= w || y < 0 || y >= h) {
        return;
    }

    scg_blend_mode_t blend_mode = image->blend_mode;
    int i = scg_pixel_index_from_xy(x, y, w);

    if (blend_mode == SCG_BLEND_MODE_NONE) {
        image->pixels[i] = color.packed;
    }

    if (blend_mode == SCG_BLEND_MODE_MASK) {
        if (color.data.a == 255) {
            image->pixels[i] = color.packed;
        }
    }

    if (blend_mode == SCG_BLEND_MODE_ALPHA) {
        scg_pixel_t d = scg_pixel_new_uint32(image->pixels[i]);
        float32_t a = (float32_t)(color.data.a / 255.0f);
        float32_t c = 1.0f - a;
        float32_t r = a * (float32_t)color.data.r + c * (float32_t)d.data.r;
        float32_t g = a * (float32_t)color.data.g + c * (float32_t)d.data.g;
        float32_t b = a * (float32_t)color.data.b + c * (float32_t)d.data.b;

        scg_pixel_t blended_color =
            scg_pixel_new_rgb((uint8_t)r, (uint8_t)g, (uint8_t)b);
        image->pixels[i] = blended_color.packed;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %ecx, -0x4(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x2fa0
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2fa0
cmpl $0x0, -0x18(%rbp)
jl 0x2fa0
movl -0x18(%rbp), %eax
cmpl -0x20(%rbp), %eax
jl 0x2fa5
jmp 0x30f3
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %eax
imull -0x1c(%rbp), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x2fd4
movl -0x4(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x1, -0x24(%rbp)
jne 0x2ff9
movzbl -0x1(%rbp), %eax
cmpl $0xff, %eax
jne 0x2ff7
movl -0x4(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x2ff9
cmpl $0x2, -0x24(%rbp)
jne 0x30f3
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movzbl -0x1(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x3fe7(%rip), %xmm1     # 0x700c
divss %xmm1, %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x30(%rbp), %xmm1
movss 0x3fcd(%rip), %xmm0     # 0x7008
subss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x30(%rbp), %xmm0
movzbl -0x2(%rbp), %eax
cvtsi2ss %eax, %xmm2
movss -0x34(%rbp), %xmm1
movzbl -0x2a(%rbp), %eax
cvtsi2ss %eax, %xmm3
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x30(%rbp), %xmm0
movzbl -0x3(%rbp), %eax
cvtsi2ss %eax, %xmm2
movss -0x34(%rbp), %xmm1
movzbl -0x2b(%rbp), %eax
cvtsi2ss %eax, %xmm3
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x30(%rbp), %xmm0
movzbl -0x4(%rbp), %eax
cvtsi2ss %eax, %xmm2
movss -0x34(%rbp), %xmm1
movzbl -0x2c(%rbp), %eax
cvtsi2ss %eax, %xmm3
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x40(%rbp)
cvttss2si -0x40(%rbp), %eax
movb %al, -0x44(%rbp)
cvttss2si -0x3c(%rbp), %eax
movb %al, -0x43(%rbp)
cvttss2si -0x38(%rbp), %eax
movb %al, -0x42(%rbp)
movb $-0x1, -0x41(%rbp)
movl -0x44(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
popq %rbp
retq
nopw %cs:(%rax,%rax)