// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
callq 0x80d4
testb %al, %al
je 0x162c9
movq %rbx, 0x20(%rsp)
movq %rbx, %rdi
callq 0x6ad8
movzwl 0x1e(%rax), %r12d
cmpw %bp, %r12w
jne 0x162da
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28e64(%rip), %rdi     # 0x3f134
movq %rbx, %rsi
callq 0x829e
jmp 0x162d8
movq %rax, %r14
cmpw $0x2, %bp
movl $0x1, %eax
cmovael %ebp, %eax
movl %eax, 0xc(%rsp)
movq %r14, %rdi
callq 0x29e0b
testq %rax, %rax
je 0x16452
movq %rax, %r15
movzwl 0xc(%rsp), %ebp
leal (,%rbp,2), %eax
movq %rax, 0x10(%rsp)
movl %ebp, %ebx
subw %r12w, %bx
setbe %al
leal -0x1(%r12), %ecx
cmpw %bp, %cx
setae %dl
orb %al, %dl
movb %dl, 0xb(%rsp)
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ecx
addl %ecx, %ecx
movq %rcx, 0x18(%rsp)
incl %ebx
andl %eax, %ebx
cmpw $0x0, 0xa(%r15)
je 0x1639c
movq 0x10(%rsp), %rdi
callq 0x298d9
movq %rax, %r13
movq %rax, %rdi
callq 0x80d4
testb %al, %al
je 0x16473
testq %r13, %r13
je 0x162ba
cmpw %r12w, 0xc(%rsp)
jae 0x163e6
movq (%r15), %rcx
xorl %esi, %esi
movzwl 0xa(%r15), %eax
addl %esi, %eax
xorl %edx, %edx
divl %r12d
movzwl (%rcx,%rdx,2), %eax
movw %ax, (%r13,%rsi,2)
incq %rsi
cmpq %rsi, %rbp
jne 0x16379
jmp 0x16429
movq (%r15), %rdi
movq 0x10(%rsp), %rsi
callq 0x299f8
movq %rax, (%r15)
movq %rax, %rdi
callq 0x80d4
movq (%r15), %rsi
testb %al, %al
je 0x16484
testq %rsi, %rsi
je 0x162ba
cmpb $0x0, 0xb(%rsp)
jne 0x16434
addq 0x18(%rsp), %rsi
xorl %eax, %eax
movw $0x83e8, (%rsi,%rax,2)  # imm = 0x83E8
incq %rax
cmpw %ax, %bx
jne 0x163d6
jmp 0x16434
testq %r12, %r12
je 0x1640e
movq (%r15), %rcx
xorl %esi, %esi
movzwl 0xa(%r15), %eax
addl %esi, %eax
xorl %edx, %edx
divl %r12d
movzwl (%rcx,%rdx,2), %eax
movw %ax, (%r13,%rsi,2)
incq %rsi
cmpq %rsi, %r12
jne 0x163f0
movq %r12, %rax
cmpw 0xc(%rsp), %r12w
jae 0x16429
movw $0x83e8, (%r13,%rax,2)  # imm = 0x83E8
incq %rax
cmpq %rax, %rbp
jne 0x16419
movq (%r15), %rdi
callq 0x29984
movq %r13, (%r15)
movw $0x0, 0xa(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x29cdb
movq %rax, %r15
testq %rax, %rax
jne 0x1633e
movl 0xc(%rsp), %eax
movw %ax, 0x1e(%r14)
movq 0x20(%rsp), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16216
leaq 0x28bc6(%rip), %rdi     # 0x3f040
movq %r13, %rsi
callq 0x829e
jmp 0x16482
leaq 0x28bb5(%rip), %rdi     # 0x3f040
callq 0x829e
jmp 0x16490