// File: /workspace/github_c_makefile_star2_O1/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, %ebp
movq %rsi, 0x68(%rsp)
movq %rdi, %r14
callq 0x6ad8
movq %rax, %r12
xorl %eax, %eax
cmpl $0x1, %ebp
setne %al
shll $0x5, %eax
leaq 0x28(%rax), %rcx
cmpq $0x0, 0x28(%r12,%rax)
jne 0x16ee8
cmpb $0x0, 0x9(%r12,%rcx)
je 0x17237
xorl %ebx, %ebx
cmpb $0x1, %bpl
setne %bl
movq %r14, %rdi
movq %rcx, 0x50(%rsp)
callq 0x6697
movq %rax, %r13
movq %r14, %rdi
callq 0x69cc
movb %al, 0x30(%rsp)
movzwl 0x22(%r14), %eax
movl %eax, 0x64(%rsp)
movq %r14, %rdi
callq 0x567b
movw %ax, 0x38(%rsp)
movq %r14, %rdi
callq 0x5651
movq 0x50(%rsp), %r10
movzbl 0xa(%r12,%r10), %ecx
movswl %ax, %edx
imull $0xffff8889, %edx, %edx # imm = 0xFFFF8889
shrl $0x10, %edx
addl %eax, %edx
movzwl %dx, %eax
movl %eax, %edx
shrl $0xf, %edx
shrl $0x3, %eax
addl %edx, %eax
cmpb $-0x1, %cl
cmovnel %ecx, %eax
movb 0xb(%r12,%r10), %dl
cmpb $-0x1, %dl
jne 0x16f7d
movsbl %al, %ecx
addl %ecx, %ecx
movslq %ecx, %rcx
imulq $0x55555556, %rcx, %rdx # imm = 0x55555556
movq %rdx, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rdx
addl %ecx, %edx
movzwl 0x20(%r14,%rbx,4), %ecx
movzbl %dl, %esi
negb %dl
testb %bpl, %bpl
movzbl %dl, %edx
cmovnel %esi, %edx
movl %edx, 0x5c(%rsp)
movb 0x8(%r12,%r10), %sil
movq (%r12,%r10), %rdi
xorl %edx, %edx
xorl %r8d, %r8d
movzbl %r8b, %r8d
movzbl (%rdi,%r8), %r9d
cmpl $0xa, %r9d
je 0x16fb9
testl %r9d, %r9d
jne 0x16fbb
jmp 0x16fc0
incb %dl
incb %r8b
jmp 0x16fa3
movq %r14, 0x88(%rsp)
movzbl %al, %r9d
negb %al
testb %bpl, %bpl
movzbl %al, %eax
cmovnel %r9d, %eax
movl %eax, 0x48(%rsp)
andb $0x2, %sil
leaq -0x1(%rdi,%r8), %rax
cmoveq %rdi, %rax
shrb %sil
leal 0x1(%rdx), %ebx
movq %rdi, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movb %bl, 0x80(%rsp)
movb %sil, 0x81(%rsp)
movl $0x0, 0x82(%rsp)
movw $0x0, 0x86(%rsp)
cmpb $0x0, 0x9(%r12,%r10)
jne 0x1702b
movb $0x1, 0x9(%r12,%r10)
xorl %esi, %esi
movl %ebp, 0x58(%rsp)
cmpb $0x1, %bpl
setne %sil
cmpb $0x2, %bl
movb 0x9(%r12,%r10), %al
movzbl %dl, %edx
movl $0x1, %edi
cmovael %edx, %edi
mulb %dil
movl %eax, %ebp
movzbl %al, %eax
movl %eax, 0x60(%rsp)
leal (%rcx,%rsi,2), %r15d
decl %r15d
movswl 0x38(%rsp), %eax
movl %eax, 0x38(%rsp)
movzbl 0x30(%rsp), %eax
movl %eax, 0x30(%rsp)
xorl %ecx, %ecx
xorl %r14d, %r14d
movb %bpl, 0x2f(%rsp)
movw %r15w, 0x4c(%rsp)
testb %bl, %bl
je 0x170a2
movl 0x48(%rsp), %eax
testb %r14b, %r14b
je 0x170a6
movzbl %r14b, %eax
divb 0x9(%r12,%r10)
movzbl %ah, %edx
movl 0x48(%rsp), %eax
testb %dl, %dl
je 0x170a6
movl 0x5c(%rsp), %eax
movsbl %al, %eax
movl %r15d, %edx
subl %eax, %edx
movw %dx, 0x34(%rsp)
movswl 0x3e(%r13), %edx
movl 0x38(%rsp), %eax
subl %edx, %eax
imull %ecx, %eax
cltd
idivl 0x60(%rsp)
addl 0x64(%rsp), %eax
movw %ax, 0x4e(%rsp)
movw %ax, 0x36(%rsp)
movzbl 0x8(%r12,%r10), %eax
testb $0x2, %al
jne 0x170e5
cmpb %r14b, %bpl
je 0x170ea
jmp 0x170ef
testb %r14b, %r14b
jne 0x170ef
andl $0x1, %eax
je 0x17110
leaq 0x4c(%rsp), %rdi
leaq 0x34(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq %r13, %rcx
movl 0x30(%rsp), %r8d
callq 0x3a7b0
movq 0x50(%rsp), %r10
testb %bl, %bl
je 0x17227
testb %r14b, %r14b
je 0x17131
movzbl %r14b, %eax
divb 0x9(%r12,%r10)
movzbl %ah, %eax
testb %al, %al
jne 0x17227
movq %r12, %rbp
leaq 0x70(%rsp), %rdi
leaq 0x90(%rsp), %r12
movq %r12, %rsi
callq 0x17249
movq 0x28(%r13), %rdx
movswl 0x30(%r13), %ecx
movswl 0x32(%r13), %r8d
movl $0x4, (%rsp)
leaq 0x44(%rsp), %rdi
movq %r12, %rsi
movl $0x7c18, %r9d           # imm = 0x7C18
callq 0x2a643
movzwl 0x36(%rsp), %eax
movzwl 0x46(%rsp), %ecx
movl %ecx, %edx
shrl $0xf, %edx
addl %ecx, %edx
movswl %dx, %ecx
sarl %ecx
movl %eax, %edx
subl %ecx, %edx
addl %eax, %ecx
xorl %eax, %eax
movw %ax, 0x3c(%rsp)
movw %dx, 0x3e(%rsp)
movw %ax, 0x40(%rsp)
movw %cx, 0x42(%rsp)
movzwl 0x34(%rsp), %eax
cmpb $0x1, 0x58(%rsp)
jne 0x171c0
addl $-0x4, %eax
movl %eax, %ecx
subw 0x44(%rsp), %cx
movw %cx, 0x3c(%rsp)
jmp 0x171cd
addl $0x4, %eax
movw %ax, 0x3c(%rsp)
addw 0x44(%rsp), %ax
movw %ax, 0x40(%rsp)
movq 0x88(%rsp), %rdi
callq 0x4abc
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x3c(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq %r13, %rdx
movl 0x30(%rsp), %ecx
leaq 0x90(%rsp), %r8
movl $0x4, %r9d
callq 0x3a034
movq 0x50(%rsp), %r10
movq %rbp, %r12
movb 0x2f(%rsp), %bpl
incb %r14b
movzbl %r14b, %ecx
cmpb %cl, %bpl
jae 0x1707b
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq