// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_draw/lv_draw_img.c
// Function: lv_img_buf_get_px_color
lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, const lv_style_t * style)
{
    lv_color_t p_color = LV_COLOR_BLACK;
    if(x >= (lv_coord_t)dsc->header.w) {
        x = dsc->header.w - 1;
        LV_LOG_WARN("lv_canvas_get_px: x is too large (out of canvas)");
    } else if(x < 0) {
        x = 0;
        LV_LOG_WARN("lv_canvas_get_px: x is < 0 (out of canvas)");
    }

    if(y >= (lv_coord_t)dsc->header.h) {
        y = dsc->header.h - 1;
        LV_LOG_WARN("lv_canvas_get_px: y is too large (out of canvas)");
    } else if(y < 0) {
        y = 0;
        LV_LOG_WARN("lv_canvas_get_px: y is < 0 (out of canvas)");
    }

    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 ||
       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(&p_color, &buf_u8[px], sizeof(lv_color_t));
#if LV_COLOR_SIZE == 32
        p_color.ch.alpha = 0xFF; /*Only the color should be get so use a deafult alpha value*/
#endif
    } else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
        buf_u8 += 4 * 2;
        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;
        p_color.full = (buf_u8[px] & (1 << (7 - bit))) >> (7 - bit);
    } else if(dsc->header.cf == LV_IMG_CF_INDEXED_2BIT) {
        buf_u8 += 4 * 4;
        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;
        p_color.full = (buf_u8[px] & (3 << (6 - bit))) >> (6 - bit);
    } else if(dsc->header.cf == LV_IMG_CF_INDEXED_4BIT) {
        buf_u8 += 4 * 16;
        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;
        p_color.full = (buf_u8[px] & (0xF << (4 - bit))) >> (4 - bit);
    } else if(dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) {
        buf_u8 += 4 * 256;
        uint32_t px  = dsc->header.w * y + x;
        p_color.full = buf_u8[px];
    } else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
              dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
        if(style)
            p_color = style->image.color;
        else
            p_color = LV_COLOR_BLACK;
    }
    return p_color;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movw %dx, %ax
movw %si, %dx
movq %rdi, -0x10(%rbp)
movw %dx, -0x12(%rbp)
movw %ax, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x2(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2090
movswl -0x12(%rbp), %eax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
shrl $0xa, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
movswl %cx, %ecx
cmpl %ecx, %eax
jl 0x621bf
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
subl $0x1, %eax
movw %ax, -0x12(%rbp)
jmp 0x621d0
movswl -0x12(%rbp), %eax
cmpl $0x0, %eax
jge 0x621ce
movw $0x0, -0x12(%rbp)
jmp 0x621d0
movswl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
shrl $0x15, %ecx
movswl %cx, %ecx
cmpl %ecx, %eax
jl 0x621f6
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x15, %eax
subl $0x1, %eax
movw %ax, -0x14(%rbp)
jmp 0x62207
movswl -0x14(%rbp), %eax
cmpl $0x0, %eax
jge 0x62205
movw $0x0, -0x14(%rbp)
jmp 0x62207
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x4, %eax
je 0x6223d
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x6, %eax
je 0x6223d
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x5, %eax
jne 0x62297
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 -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movw (%rax,%rcx), %ax
movw %ax, -0x2(%rbp)
jmp 0x62517
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x7, %eax
jne 0x62321
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x28(%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 -0x28(%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
andl %ecx, %eax
movzbl -0x31(%rbp), %edx
movl $0x7, %ecx
subl %edx, %ecx
sarl %cl, %eax
movw %ax, -0x2(%rbp)
jmp 0x62515
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x8, %eax
jne 0x623ad
movq -0x28(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x28(%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 -0x28(%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
andl %ecx, %eax
movzbl -0x39(%rbp), %edx
movl $0x6, %ecx
subl %edx, %ecx
sarl %cl, %eax
movw %ax, -0x2(%rbp)
jmp 0x62513
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x9, %eax
jne 0x62438
movq -0x28(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x28(%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 -0x28(%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
andl %ecx, %eax
movzbl -0x41(%rbp), %edx
movl $0x4, %ecx
subl %edx, %ecx
sarl %cl, %eax
movw %ax, -0x2(%rbp)
jmp 0x62511
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xa, %eax
jne 0x62486
movq -0x28(%rbp), %rax
addq $0x400, %rax            # imm = 0x400
movq %rax, -0x28(%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)
movq -0x28(%rbp), %rax
movl -0x4c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movw %ax, -0x2(%rbp)
jmp 0x6250f
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xb, %eax
je 0x624be
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xc, %eax
je 0x624be
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xd, %eax
je 0x624be
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0xe, %eax
jne 0x6250d
cmpq $0x0, -0x20(%rbp)
je 0x624d3
movq -0x20(%rbp), %rax
movw 0x38(%rax), %ax
movw %ax, -0x2(%rbp)
jmp 0x6250b
movw -0x4e(%rbp), %ax
andw $-0x20, %ax
orw $0x0, %ax
movw %ax, -0x4e(%rbp)
movw -0x4e(%rbp), %ax
andw $0xf81f, %ax            # imm = 0xF81F
orw $0x0, %ax
movw %ax, -0x4e(%rbp)
movw -0x4e(%rbp), %ax
andw $0x7ff, %ax             # imm = 0x7FF
orw $0x0, %ax
movw %ax, -0x4e(%rbp)
movw -0x4e(%rbp), %ax
movw %ax, -0x2(%rbp)
jmp 0x6250d
jmp 0x6250f
jmp 0x62511
jmp 0x62513
jmp 0x62515
jmp 0x62517
movw -0x2(%rbp), %ax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)