// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_draw/lv_draw_img.c
// Function: lv_img_buf_set_px_alpha
void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_opa_t opa)
{
    uint8_t * buf_u8 = (uint8_t *)dsc->data;

    if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
        uint8_t px_size          = lv_img_color_format_get_px_size(dsc->header.cf) >> 3;
        uint32_t px              = dsc->header.w * y * px_size + x * px_size;
        buf_u8[px + px_size - 1] = opa;
    } else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
        opa         = opa >> 7; /*opa -> [0,1]*/
        uint8_t bit = x & 0x7;
        x           = x >> 3;

        /* Get the current pixel.
         * dsc->header.w + 7 means rounding up to 8 because the lines are byte aligned
         * so the possible real width are 8 ,16, 24 ...*/
        uint32_t px = ((dsc->header.w + 7) >> 3) * y + x;
        buf_u8[px]  = buf_u8[px] & ~(1 << (7 - bit));
        buf_u8[px]  = buf_u8[px] | ((opa & 0x1) << (7 - bit));
    } else if(dsc->header.cf == LV_IMG_CF_ALPHA_2BIT) {
        opa         = opa >> 6; /*opa -> [0,3]*/
        uint8_t bit = (x & 0x3) * 2;
        x           = x >> 2;

        /* Get the current pixel.
         * dsc->header.w + 4 means rounding up to 8 because the lines are byte aligned
         * so the possible real width are 4 ,8, 12 ...*/
        uint32_t px = ((dsc->header.w + 3) >> 2) * y + x;
        buf_u8[px]  = buf_u8[px] & ~(3 << (6 - bit));
        buf_u8[px]  = buf_u8[px] | ((opa & 0x3) << (6 - bit));
    } else if(dsc->header.cf == LV_IMG_CF_ALPHA_4BIT) {
        opa         = opa >> 4; /*opa -> [0,15]*/
        uint8_t bit = (x & 0x1) * 4;
        x           = x >> 1;

        /* Get the current pixel.
         * dsc->header.w + 1 means rounding up to 8 because the lines are byte aligned
         * so the possible real width are 2 ,4, 6 ...*/
        uint32_t px = ((dsc->header.w + 1) >> 1) * y + x;
        buf_u8[px]  = buf_u8[px] & ~(0xF << (4 - bit));
        buf_u8[px]  = buf_u8[px] | ((opa & 0xF) << (4 - bit));
    } else if(dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
        uint32_t px = dsc->header.w * y + x;
        buf_u8[px]  = opa;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %cl, %al
movw %dx, %cx
movw %si, %dx
movq %rdi, -0x8(%rbp)
movw %dx, -0xa(%rbp)
movw %cx, -0xc(%rbp)
movb %al, -0xd(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x5, %eax
jne 0x62cec
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
movzbl %al, %edi
callq 0x62530
movzbl %al, %eax
sarl $0x3, %eax
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movswl -0xc(%rbp), %ecx
imull %ecx, %eax
movzbl -0x19(%rbp), %ecx
imull %ecx, %eax
movswl -0xa(%rbp), %ecx
movzbl -0x19(%rbp), %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
movb -0xd(%rbp), %dl
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl -0x19(%rbp), %esi
addl %esi, %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x62f58
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xb, %eax
jne 0x62da5
movzbl -0xd(%rbp), %eax
sarl $0x7, %eax
movb %al, -0xd(%rbp)
movswl -0xa(%rbp), %eax
andl $0x7, %eax
movb %al, -0x21(%rbp)
movswl -0xa(%rbp), %eax
sarl $0x3, %eax
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
addl $0x7, %eax
sarl $0x3, %eax
movswl -0xc(%rbp), %ecx
imull %ecx, %eax
movswl -0xa(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x21(%rbp), %edx
movl $0x7, %ecx
subl %edx, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0xd(%rbp), %edx
andl $0x1, %edx
movzbl -0x21(%rbp), %esi
movl $0x7, %ecx
subl %esi, %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x62f56
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xc, %eax
jne 0x62e60
movzbl -0xd(%rbp), %eax
sarl $0x6, %eax
movb %al, -0xd(%rbp)
movswl -0xa(%rbp), %eax
andl $0x3, %eax
shll %eax
movb %al, -0x29(%rbp)
movswl -0xa(%rbp), %eax
sarl $0x2, %eax
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
addl $0x3, %eax
sarl $0x2, %eax
movswl -0xc(%rbp), %ecx
imull %ecx, %eax
movswl -0xa(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x29(%rbp), %edx
movl $0x6, %ecx
subl %edx, %ecx
movl $0x3, %edx
shll %cl, %edx
movl %edx, %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0xd(%rbp), %edx
andl $0x3, %edx
movzbl -0x29(%rbp), %esi
movl $0x6, %ecx
subl %esi, %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x62f54
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xd, %eax
jne 0x62f17
movzbl -0xd(%rbp), %eax
sarl $0x4, %eax
movb %al, -0xd(%rbp)
movswl -0xa(%rbp), %eax
andl $0x1, %eax
shll $0x2, %eax
movb %al, -0x31(%rbp)
movswl -0xa(%rbp), %eax
sarl %eax
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
addl $0x1, %eax
sarl %eax
movswl -0xc(%rbp), %ecx
imull %ecx, %eax
movswl -0xa(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x31(%rbp), %edx
movl $0x4, %ecx
subl %edx, %ecx
movl $0xf, %edx
shll %cl, %edx
movl %edx, %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0xd(%rbp), %edx
andl $0xf, %edx
movzbl -0x31(%rbp), %esi
movl $0x4, %ecx
subl %esi, %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x62f52
movq -0x8(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xe, %eax
jne 0x62f50
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movswl -0xc(%rbp), %ecx
imull %ecx, %eax
movswl -0xa(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x3c(%rbp)
movb -0xd(%rbp), %dl
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x62f52
jmp 0x62f54
jmp 0x62f56
jmp 0x62f58
addq $0x40, %rsp
popq %rbp
retq
nop