// File: /workspace/github_c_makefile_star2_O0/nkanaev[P]tipsy/src/tigr.c
// Function: tigrFillRect
void tigrFillRect(Tigr* bmp, int x, int y, int w, int h, TPixel color) {
    x += 1;
    y += 1;
    w -= 2;
    h -= 2;

    int cx = bmp->cx;
    int cy = bmp->cy;
    int cw = bmp->cw >= 0 ? bmp->cw : bmp->w;
    int ch = bmp->ch >= 0 ? bmp->ch : bmp->h;

    if (x < cx) {
        w += (x - cx);
        x = cx;
    }
    if (y < cy) {
        h += (y - cy);
        y = cy;
    }
    if (x + w > cx + cw) {
        w -= (x + w) - (cx + cw);
    }
    if (y + h > cy + ch) {
        h -= (y + h) - (cy + ch);
    }
    if (w <= 0 || h <= 0)
        return;

    TPixel* td = &bmp->pix[y * bmp->w + x];
    int dt = bmp->w;
    int xa = EXPAND(color.a);
    int a = xa * xa;

    do {
        for (int i = 0; i < w; i++) {
            td[i].r += (unsigned char)((color.r - td[i].r) * a >> 16);
            td[i].g += (unsigned char)((color.g - td[i].g) * a >> 16);
            td[i].b += (unsigned char)((color.b - td[i].b) * a >> 16);
            td[i].a += (bmp->blitMode) * (unsigned char)((color.a - td[i].a) * a >> 16);
        }
        td += dt;
    } while (--h);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %r9d, -0x4(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jl 0x40c7
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x4c(%rbp)
jmp 0x40d0
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jl 0x40ec
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x50(%rbp)
jmp 0x40f6
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4116
movl -0x14(%rbp), %eax
subl -0x24(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x4130
movl -0x18(%rbp), %eax
subl -0x28(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
addl -0x1c(%rbp), %eax
movl -0x24(%rbp), %ecx
addl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jle 0x4156
movl -0x14(%rbp), %ecx
addl -0x1c(%rbp), %ecx
movl -0x24(%rbp), %eax
addl -0x2c(%rbp), %eax
subl %eax, %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
addl -0x20(%rbp), %eax
movl -0x28(%rbp), %ecx
addl -0x30(%rbp), %ecx
cmpl %ecx, %eax
jle 0x417c
movl -0x18(%rbp), %ecx
addl -0x20(%rbp), %ecx
movl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
subl %eax, %ecx
movl -0x20(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
jle 0x4188
cmpl $0x0, -0x20(%rbp)
jg 0x418d
jmp 0x42eb
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rdx
imull (%rdx), %ecx
addl -0x14(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movzbl -0x1(%rbp), %eax
movzbl -0x1(%rbp), %ecx
cmpl $0x0, %ecx
setg %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
imull -0x40(%rbp), %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x42c4
movzbl -0x4(%rbp), %eax
movq -0x38(%rbp), %rcx
movslq -0x48(%rbp), %rdx
movzbl (%rcx,%rdx,4), %ecx
subl %ecx, %eax
imull -0x44(%rbp), %eax
sarl $0x10, %eax
movzbl %al, %esi
movq -0x38(%rbp), %rax
movslq -0x48(%rbp), %rcx
movzbl (%rax,%rcx,4), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx,4)
movzbl -0x3(%rbp), %eax
movq -0x38(%rbp), %rcx
movslq -0x48(%rbp), %rdx
movzbl 0x1(%rcx,%rdx,4), %ecx
subl %ecx, %eax
imull -0x44(%rbp), %eax
sarl $0x10, %eax
movzbl %al, %esi
movq -0x38(%rbp), %rax
movslq -0x48(%rbp), %rcx
movzbl 0x1(%rax,%rcx,4), %edx
addl %esi, %edx
movb %dl, 0x1(%rax,%rcx,4)
movzbl -0x2(%rbp), %eax
movq -0x38(%rbp), %rcx
movslq -0x48(%rbp), %rdx
movzbl 0x2(%rcx,%rdx,4), %ecx
subl %ecx, %eax
imull -0x44(%rbp), %eax
sarl $0x10, %eax
movzbl %al, %esi
movq -0x38(%rbp), %rax
movslq -0x48(%rbp), %rcx
movzbl 0x2(%rax,%rcx,4), %edx
addl %esi, %edx
movb %dl, 0x2(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl 0x28(%rax), %esi
movzbl -0x1(%rbp), %eax
movq -0x38(%rbp), %rcx
movslq -0x48(%rbp), %rdx
movzbl 0x3(%rcx,%rdx,4), %ecx
subl %ecx, %eax
imull -0x44(%rbp), %eax
sarl $0x10, %eax
movzbl %al, %eax
imull %eax, %esi
movq -0x38(%rbp), %rax
movslq -0x48(%rbp), %rcx
movzbl 0x3(%rax,%rcx,4), %edx
addl %esi, %edx
movb %dl, 0x3(%rax,%rcx,4)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x41e3
movl -0x3c(%rbp), %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, %eax
jne 0x41dc
popq %rbp
retq
nopl (%rax)