// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_chart.c
// Function: lv_chart_set_point_count
void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
{
    LV_ASSERT_OBJ(chart, LV_OBJX_NAME);

    lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
    if(ext->point_cnt == point_cnt) return;

    lv_chart_series_t * ser;
    uint16_t point_cnt_old = ext->point_cnt;
    uint16_t i;
    lv_coord_t def = LV_CHART_POINT_DEF;

    if(point_cnt < 1) point_cnt = 1;

    LV_LL_READ_BACK(ext->series_ll, ser)
    {
        if(ser->start_point != 0) {
            lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
            LV_ASSERT_MEM(new_points);
            if(new_points == NULL) return;

            if(point_cnt >= point_cnt_old) {
                for(i = 0; i < point_cnt_old; i++) {
                    new_points[i] =
                        ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
                }
                for(i = point_cnt_old; i < point_cnt; i++) {
                    new_points[i] = def; /*Fill up the rest with default value*/
                }
            } else {
                for(i = 0; i < point_cnt; i++) {
                    new_points[i] =
                        ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
                }
            }

            /*Switch over pointer from old to new*/
            lv_mem_free(ser->points);
            ser->points = new_points;
        } else {
            ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
            LV_ASSERT_MEM(ser->points);
            if(ser->points == NULL) return;
            /*Initialize the new points*/
            if(point_cnt > point_cnt_old) {
                for(i = point_cnt_old - 1; i < point_cnt; i++) {
                    ser->points[i] = def;
                }
            }
        }

        ser->start_point = 0;
    }

    ext->point_cnt = point_cnt;

    lv_chart_refresh(chart);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movw %si, %ax
movq %rdi, -0x8(%rbp)
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x239b2
movq -0x8(%rbp), %rsi
leaq 0x44751(%rip), %rdi     # 0x680fc
callq 0xd410
jmp 0x239b0
movq -0x8(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x1e(%rax), %eax
movzwl -0xa(%rbp), %ecx
cmpl %ecx, %eax
jne 0x239d4
jmp 0x23c38
movq -0x18(%rbp), %rax
movw 0x1e(%rax), %ax
movw %ax, -0x22(%rbp)
movw $0x83e8, -0x26(%rbp)    # imm = 0x83E8
movzwl -0xa(%rbp), %eax
cmpl $0x1, %eax
jge 0x239f5
movw $0x1, -0xa(%rbp)
movq -0x18(%rbp), %rdi
callq 0x458e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x23c23
movq -0x20(%rbp), %rax
movzwl 0xa(%rax), %eax
cmpl $0x0, %eax
je 0x23b6b
movzwl -0xa(%rbp), %eax
movl %eax, %edi
shlq %rdi
callq 0x44d20
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x23a4f
movq -0x30(%rbp), %rsi
leaq 0x445fc(%rip), %rdi     # 0x68044
callq 0xd410
jmp 0x23a4d
cmpq $0x0, -0x30(%rbp)
jne 0x23a5b
jmp 0x23c38
movzwl -0xa(%rbp), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jl 0x23af6
movw $0x0, -0x24(%rbp)
movzwl -0x24(%rbp), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jge 0x23ac2
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movzwl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movzwl -0x22(%rbp), %ecx
cltd
idivl %ecx
movq -0x38(%rbp), %rax
movslq %edx, %rcx
movw (%rax,%rcx,2), %dx
movq -0x30(%rbp), %rax
movzwl -0x24(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movw -0x24(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x24(%rbp)
jmp 0x23a71
movw -0x22(%rbp), %ax
movw %ax, -0x24(%rbp)
movzwl -0x24(%rbp), %eax
movzwl -0xa(%rbp), %ecx
cmpl %ecx, %eax
jge 0x23af4
movw -0x26(%rbp), %dx
movq -0x30(%rbp), %rax
movzwl -0x24(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movw -0x24(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x24(%rbp)
jmp 0x23aca
jmp 0x23b4f
movw $0x0, -0x24(%rbp)
movzwl -0x24(%rbp), %eax
movzwl -0xa(%rbp), %ecx
cmpl %ecx, %eax
jge 0x23b4d
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movzwl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
movzwl 0xa(%rcx), %ecx
addl %ecx, %eax
movzwl -0x22(%rbp), %ecx
cltd
idivl %ecx
movq -0x40(%rbp), %rax
movslq %edx, %rcx
movw (%rax,%rcx,2), %dx
movq -0x30(%rbp), %rax
movzwl -0x24(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movw -0x24(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x24(%rbp)
jmp 0x23afc
jmp 0x23b4f
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x44ec0
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x23c03
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movzwl -0xa(%rbp), %eax
movl %eax, %esi
shlq %rsi
callq 0x44f70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0xd120
testb $0x1, %al
jne 0x23baf
movq -0x20(%rbp), %rax
movq (%rax), %rsi
leaq 0x4449c(%rip), %rdi     # 0x68044
callq 0xd410
jmp 0x23bad
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x23bbb
jmp 0x23c38
movzwl -0xa(%rbp), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jle 0x23c01
movzwl -0x22(%rbp), %eax
subl $0x1, %eax
movw %ax, -0x24(%rbp)
movzwl -0x24(%rbp), %eax
movzwl -0xa(%rbp), %ecx
cmpl %ecx, %eax
jge 0x23bff
movw -0x26(%rbp), %dx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movzwl -0x24(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movw -0x24(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x24(%rbp)
jmp 0x23bd2
jmp 0x23c01
jmp 0x23c03
movq -0x20(%rbp), %rax
movw $0x0, 0xa(%rax)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x45690
movq %rax, -0x20(%rbp)
jmp 0x23a02
movw -0xa(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x1e(%rax)
movq -0x8(%rbp), %rdi
callq 0x238d0
addq $0x40, %rsp
popq %rbp
retq
nop