// 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_color
void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_color_t c)
{
    uint8_t * buf_u8 = (uint8_t *)dsc->data;

    if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
        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;
        memcpy(&buf_u8[px], &c, px_size);
    } else 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;
        memcpy(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/
    } else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
        buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/

        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] | ((c.full & 0x1) << (7 - bit));
    } else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
        buf_u8 += sizeof(lv_color32_t) * 4; /*Skip the palette*/
        uint8_t bit = (x & 0x3) * 2;
        x           = x >> 2;

        /* Get the current pixel.
         * dsc->header.w + 3 means rounding up to 4 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] | ((c.full & 0x3) << (6 - bit));
    } else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
        buf_u8 += sizeof(lv_color32_t) * 16; /*Skip the palette*/
        uint8_t bit = (x & 0x1) * 4;
        x           = x >> 1;

        /* Get the current pixel.
         * dsc->header.w + 1 means rounding up to 2 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] | ((c.full & 0xF) << (4 - bit));
    } else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
        buf_u8 += sizeof(lv_color32_t) * 256; /*Skip the palette*/
        uint32_t px = dsc->header.w * y + x;
        buf_u8[px]  = c.full;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edx, %eax
movw %cx, %dx
movw %si, %cx
movw %dx, -0x2(%rbp)
movq %rdi, -0x10(%rbp)
movw %cx, -0x12(%rbp)
movw %ax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x4, %eax
je 0x628e8
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x6, %eax
jne 0x6294c
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
movzbl %al, %edi
callq 0x62530
movzbl %al, %eax
sarl $0x3, %eax
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movswl -0x14(%rbp), %ecx
imull %ecx, %eax
movzbl -0x21(%rbp), %ecx
imull %ecx, %eax
movswl -0x12(%rbp), %ecx
movzbl -0x21(%rbp), %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movl -0x28(%rbp), %eax
addq %rax, %rdi
movzbl -0x21(%rbp), %eax
movl %eax, %edx
leaq -0x2(%rbp), %rsi
callq 0x20e0
jmp 0x62c47
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x5, %eax
jne 0x629c2
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
movzbl %al, %edi
callq 0x62530
movzbl %al, %eax
sarl $0x3, %eax
movb %al, -0x29(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movswl -0x14(%rbp), %ecx
imull %ecx, %eax
movzbl -0x29(%rbp), %ecx
imull %ecx, %eax
movswl -0x12(%rbp), %ecx
movzbl -0x29(%rbp), %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movl -0x30(%rbp), %eax
addq %rax, %rdi
movzbl -0x29(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rdx
leaq -0x2(%rbp), %rsi
callq 0x20e0
jmp 0x62c45
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x7, %eax
jne 0x62a7d
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movswl -0x12(%rbp), %eax
andl $0x7, %eax
movb %al, -0x31(%rbp)
movswl -0x12(%rbp), %eax
sarl $0x3, %eax
movw %ax, -0x12(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
addl $0x7, %eax
sarl $0x3, %eax
movswl -0x14(%rbp), %ecx
imull %ecx, %eax
movswl -0x12(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x31(%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 -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzwl -0x2(%rbp), %edx
andl $0x1, %edx
movzbl -0x31(%rbp), %esi
movl $0x7, %ecx
subl %esi, %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x62c43
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x8, %eax
jne 0x62b3a
movq -0x20(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x20(%rbp)
movswl -0x12(%rbp), %eax
andl $0x3, %eax
shll %eax
movb %al, -0x39(%rbp)
movswl -0x12(%rbp), %eax
sarl $0x2, %eax
movw %ax, -0x12(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
addl $0x3, %eax
sarl $0x2, %eax
movswl -0x14(%rbp), %ecx
imull %ecx, %eax
movswl -0x12(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x39(%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 -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzwl -0x2(%rbp), %edx
andl $0x3, %edx
movzbl -0x39(%rbp), %esi
movl $0x6, %ecx
subl %esi, %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x62c41
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x9, %eax
jne 0x62bf3
movq -0x20(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x20(%rbp)
movswl -0x12(%rbp), %eax
andl $0x1, %eax
shll $0x2, %eax
movb %al, -0x41(%rbp)
movswl -0x12(%rbp), %eax
sarl %eax
movw %ax, -0x12(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
addl $0x1, %eax
sarl %eax
movswl -0x14(%rbp), %ecx
imull %ecx, %eax
movswl -0x12(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movl -0x48(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzbl -0x41(%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 -0x20(%rbp), %rax
movl -0x48(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq -0x20(%rbp), %rax
movl -0x48(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movzwl -0x2(%rbp), %edx
andl $0xf, %edx
movzbl -0x41(%rbp), %esi
movl $0x4, %ecx
subl %esi, %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x48(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x62c3f
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xa, %eax
jne 0x62c3d
movq -0x20(%rbp), %rax
addq $0x400, %rax            # imm = 0x400
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movswl -0x14(%rbp), %ecx
imull %ecx, %eax
movswl -0x12(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movw -0x2(%rbp), %ax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x4c(%rbp), %ecx
movb %dl, (%rax,%rcx)
jmp 0x62c3f
jmp 0x62c41
jmp 0x62c43
jmp 0x62c45
jmp 0x62c47
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)