// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_chart.c
// Function: lv_chart_draw_y_ticks
static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask, uint8_t which_axis)
{
    lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
    lv_chart_axis_cfg_t * y_axis = (which_axis == LV_CHART_AXIS_PRIMARY_Y) ?
                                            &ext->y_axis : &ext->secondary_y_axis;

    if(y_axis->list_of_values != NULL || y_axis->num_tick_marks != 0) {

        const lv_style_t * style = lv_obj_get_style(chart);
        lv_opa_t opa_scale       = lv_obj_get_opa_scale(chart);

        uint8_t i;
        uint8_t num_of_labels;
        uint8_t num_scale_ticks;
        int8_t major_tick_len, minor_tick_len;
        uint8_t iter_dir;

        lv_point_t p1;
        lv_point_t p2;
        lv_coord_t x_ofs;
        lv_chart_label_iterator_t iter;
        lv_coord_t y_ofs = chart->coords.y1;
        lv_coord_t h     = lv_obj_get_height(chart);
        lv_coord_t w     = lv_obj_get_width(chart);
        char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + 1]; /* up to N symbols per label + null terminator */

        /* chose correct side of the chart */
        if(which_axis == LV_CHART_AXIS_PRIMARY_Y)
            x_ofs = chart->coords.x1;
        else
            x_ofs = chart->coords.x2;

        /* calculate the size of tick marks */
        if(y_axis->major_tick_len == LV_CHART_TICK_LENGTH_AUTO)
            major_tick_len = (int32_t)w * LV_CHART_AXIS_MAJOR_TICK_LEN_COE;
        else
            major_tick_len = y_axis->major_tick_len;

        if(y_axis->minor_tick_len == LV_CHART_TICK_LENGTH_AUTO)
            minor_tick_len = major_tick_len * LV_CHART_AXIS_MINOR_TICK_LEN_COE;
        else
            minor_tick_len = y_axis->minor_tick_len;

        /* tick lines on secondary y axis are drawn in other direction*/
        if(which_axis == LV_CHART_AXIS_SECONDARY_Y) {
            major_tick_len *= -1;
            minor_tick_len *= -1;
        }

        iter_dir = (y_axis->options & LV_CHART_AXIS_INVERSE_LABELS_ORDER) ? LV_CHART_LABEL_ITERATOR_REVERSE : LV_CHART_LABEL_ITERATOR_FORWARD;
        iter = lv_chart_create_label_iter(y_axis->list_of_values, iter_dir);

        /*determine the number of options */
        num_of_labels = iter.items_left;

        /* we can't have string labels without ticks step, set to 1 if not specified */
        if(y_axis->num_tick_marks == 0) y_axis->num_tick_marks = 1;

        /* calculate total number of ticks */
        if(num_of_labels < 2)
            num_scale_ticks = y_axis->num_tick_marks;
        else
            num_scale_ticks = (y_axis->num_tick_marks * (num_of_labels - 1));

        for(i = 0; i < (num_scale_ticks + 1); i++) { /* one extra loop - it may not exist in the list, empty label */
                                                     /* first point of the tick */
            p1.x = x_ofs;

            /* move extra pixel out of chart boundary */
            if (which_axis == LV_CHART_AXIS_PRIMARY_Y)
                p1.x--;
            else
                p1.x++;

            /* second point of the tick */
            if((num_of_labels != 0) && (i == 0 || i % y_axis->num_tick_marks == 0))
                p2.x = p1.x - major_tick_len; /* major tick */
            else
                p2.x = p1.x - minor_tick_len; /* minor tick */

            /* draw a line at moving y position */
            p2.y = p1.y =
                y_ofs + (int32_t)((int32_t)(h - style->line.width) * i) / num_scale_ticks;

            if(y_axis->options & LV_CHART_AXIS_INVERSE_LABELS_ORDER) {
                /*if label order is inversed last tick have number 0*/
                if(i != 0)
                    lv_draw_line(&p1, &p2, mask, style, opa_scale);
                else if((y_axis->options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
                    lv_draw_line(&p1, &p2, mask, style, opa_scale);
            } else {
                if(i != num_scale_ticks)
                    lv_draw_line(&p1, &p2, mask, style, opa_scale);
                else if((y_axis->options & LV_CHART_AXIS_DRAW_LAST_TICK) != 0)
                    lv_draw_line(&p1, &p2, mask, style, opa_scale);
            }

            /* draw values if available */
            if(num_of_labels != 0) {
                /* add text only to major tick */
                if(lv_chart_is_tick_with_label(i, y_axis)) {

                    lv_chart_get_next_label(&iter, buf);

                    /* reserve appropriate area */
                    lv_point_t size;
                    lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space, style->text.line_space,
                                    LV_COORD_MAX, LV_TXT_FLAG_CENTER);

                    /* set the area at some distance of the major tick len left of the tick */
                    lv_area_t a = {.y1 = p2.y - size.y / 2, .y2 = p2.y + size.y / 2};

                    if(which_axis == LV_CHART_AXIS_PRIMARY_Y) {
                        a.x1 = p2.x - size.x - LV_CHART_AXIS_TO_LABEL_DISTANCE;
                        a.x2 = p2.x - LV_CHART_AXIS_TO_LABEL_DISTANCE;
                    } else {
                        a.x1 = p2.x + LV_CHART_AXIS_TO_LABEL_DISTANCE;
                        a.x2 = p2.x + size.x + LV_CHART_AXIS_TO_LABEL_DISTANCE;
                    }

                    lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, NULL, NULL, lv_obj_get_base_dir(chart));
                }
            }

        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, %r15d
movq %rsi, 0x60(%rsp)
movq %rdi, %r14
callq 0x6747
xorl %ecx, %ecx
cmpl $0x1, %r15d
setne %cl
shll $0x5, %ecx
leaq 0x28(%rcx), %rdx
cmpq $0x0, 0x28(%rax,%rcx)
jne 0x15da4
cmpb $0x0, 0x9(%rax,%rdx)
je 0x16084
xorl %ebx, %ebx
cmpb $0x1, %r15b
setne %bl
movq %rax, 0x40(%rsp)
movq %r14, %rdi
movq %rdx, 0x38(%rsp)
callq 0x6316
movq %rax, %r13
movq %r14, %rdi
callq 0x6649
movl %eax, %r12d
movzwl 0x22(%r14), %eax
movl %eax, 0x5c(%rsp)
movq %r14, %rdi
callq 0x5332
movw %ax, 0x24(%rsp)
movq %r14, %rdi
callq 0x5308
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %rdi
movq %r14, 0x68(%rsp)
movzwl 0x20(%r14,%rbx,4), %r14d
movzbl 0xa(%rdi,%r8), %esi
cwtd
movw $0xf, %cx
idivw %cx
movl %eax, %ecx
cmpb $-0x1, %sil
cmovnel %esi, %ecx
movb 0xb(%rdi,%r8), %al
cmpb $-0x1, %al
jne 0x15e2c
movsbl %cl, %eax
addl %eax, %eax
pushq $0x3
popq %rsi
cltd
idivl %esi
movzbl %cl, %edx
negb %cl
movzbl %al, %esi
negb %al
testb %r15b, %r15b
movzbl %al, %eax
cmovnel %esi, %eax
movl %eax, 0x54(%rsp)
movzbl %cl, %eax
cmovnel %edx, %eax
movl %eax, 0x30(%rsp)
xorl %edx, %edx
testb $0x2, 0x8(%rdi,%r8)
sete %dl
movq (%rdi,%r8), %rsi
leaq 0x90(%rsp), %rbp
movq %rbp, %rdi
callq 0x16096
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %rdi
movb 0x10(%rbp), %bl
movb 0x9(%rdi,%r8), %al
testb %al, %al
jne 0x15e8a
movb $0x1, 0x9(%rdi,%r8)
movb $0x1, %al
xorl %ecx, %ecx
movl %r15d, 0x50(%rsp)
cmpb $0x1, %r15b
setne %cl
leal -0x1(%rbx), %edx
cmpb $0x2, %bl
movzbl %dl, %edx
pushq $0x1
popq %rsi
cmovael %edx, %esi
mulb %sil
movl %eax, %ebp
movzbl %al, %eax
movl %eax, 0x58(%rsp)
leal (%r14,%rcx,2), %r15d
decl %r15d
movswl 0x24(%rsp), %eax
movl %eax, 0x24(%rsp)
xorl %r14d, %r14d
movzbl %r12b, %eax
movl %eax, 0x2c(%rsp)
cmpb %r14b, %bpl
jb 0x16084
movzbl %r14b, %r12d
movw %r15w, 0x34(%rsp)
testb %bl, %bl
je 0x15f02
movl 0x30(%rsp), %eax
testl %r12d, %r12d
je 0x15f06
movzbl %r14b, %eax
divb 0x9(%rdi,%r8)
movzbl %ah, %ecx
movl 0x30(%rsp), %eax
testb %cl, %cl
je 0x15f06
movl 0x54(%rsp), %eax
movsbl %al, %eax
movl %r15d, %ecx
subl %eax, %ecx
movw %cx, 0x20(%rsp)
movswl 0x3e(%r13), %ecx
movl 0x24(%rsp), %eax
subl %ecx, %eax
imull %r12d, %eax
cltd
idivl 0x58(%rsp)
addl 0x5c(%rsp), %eax
movw %ax, 0x36(%rsp)
movw %ax, 0x22(%rsp)
movzbl 0x8(%rdi,%r8), %eax
testb $0x2, %al
jne 0x15f46
cmpb %r14b, %bpl
je 0x15f4b
jmp 0x15f50
testl %r12d, %r12d
jne 0x15f50
andl $0x1, %eax
je 0x15f76
leaq 0x34(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq %r13, %rcx
movl 0x2c(%rsp), %r8d
callq 0x37138
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %rdi
testb %bl, %bl
je 0x1607c
testl %r12d, %r12d
je 0x15f97
movzbl %r14b, %eax
divb 0x9(%rdi,%r8)
movzbl %ah, %eax
testb %al, %al
jne 0x1607c
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %r12
movq %r12, %rsi
callq 0x160dc
movq 0x28(%r13), %rdx
movswl 0x30(%r13), %ecx
movswl 0x32(%r13), %r8d
movl $0x4, (%rsp)
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
movl $0x7c18, %r9d           # imm = 0x7C18
callq 0x28723
movzwl 0x22(%rsp), %edi
movzwl 0x2a(%rsp), %ecx
movl %ecx, %eax
cwtd
movw $0xfffe, %si            # imm = 0xFFFE
idivw %si
movl %eax, %esi
movl %ecx, %eax
cwtd
addl %edi, %esi
movw $0x2, %cx
idivw %cx
addl %edi, %eax
movw %si, 0x4a(%rsp)
movw %ax, 0x4e(%rsp)
movzwl 0x20(%rsp), %eax
cmpb $0x1, 0x50(%rsp)
jne 0x1601c
addl $-0x4, %eax
movl %eax, %ecx
subw 0x28(%rsp), %cx
jmp 0x1602b
addl $0x4, %eax
movzwl 0x28(%rsp), %edx
addw %ax, %dx
movl %eax, %ecx
movl %edx, %eax
movw %cx, 0x48(%rsp)
movw %ax, 0x4c(%rsp)
movq 0x68(%rsp), %rdi
callq 0x47b9
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
leaq 0x48(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq %r13, %rdx
movl 0x2c(%rsp), %ecx
leaq 0x70(%rsp), %r8
pushq $0x4
popq %r9
callq 0x3699c
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %r8
incb %r14b
jmp 0x15ece
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq