// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_spinbox.c
// Function: lv_spinbox_updatevalue
static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
{
    lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);

    char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8];
    memset(buf, 0, sizeof(buf));
    char * buf_p = buf;

    if (ext->range_min < 0) { // hide sign if there are only positive values
        /*Add the sign*/
        (*buf_p) = ext->value >= 0 ? '+' : '-';
        buf_p++;
    }

    int32_t i;
    /*padding left*/
    for(i = 0; i < ext->digit_padding_left; i++) {
        (*buf_p) = ' ';
        buf_p++;
    }

    char digits[64];
    /*Convert the numbers to string (the sign is already handled so always covert positive number)*/
    lv_utils_num_to_str(ext->value < 0 ? -ext->value : ext->value, digits);

    /*Add leading zeros*/
    int lz_cnt = ext->digit_count - (int)strlen(digits);
    if(lz_cnt > 0) {
        for(i = (uint16_t)strlen(digits); i >= 0; i--) {
            digits[i + lz_cnt] = digits[i];
        }
        for(i = 0; i < lz_cnt; i++) {
            digits[i] = '0';
        }
    }

    int32_t intDigits;
    intDigits = (ext->dec_point_pos == 0) ? ext->digit_count : ext->dec_point_pos;

    /*Add the decimal part*/
    for(i = 0; i < intDigits && digits[i] != '\0'; i++) {
        (*buf_p) = digits[i];
        buf_p++;
    }

    if(ext->dec_point_pos != 0) {
        /*Insert the decimal point*/
        (*buf_p) = '.';
        buf_p++;

        for(/*Leave i*/; i < ext->digit_count && digits[i] != '\0'; i++) {
            (*buf_p) = digits[i];
            buf_p++;
        }
    }

    /*Refresh the text*/
    lv_ta_set_text(spinbox, (char *)buf);

    /*Set the cursor position*/
    int32_t step    = ext->step;
    uint8_t cur_pos = (uint8_t)ext->digit_count;
    while(step >= 10) {
        step /= 10;
        cur_pos--;
    }

    if(cur_pos > intDigits) cur_pos++; /*Skip teh decimal point*/

    cur_pos += ext->digit_padding_left;

    lv_ta_set_cursor_pos(spinbox, cur_pos);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
callq 0x6af7
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0xa8(%rax)
js 0x21100
movq %rsp, %r12
jmp 0x21118
movl 0xa0(%r14), %eax
shrl $0x1f, %eax
addb %al, %al
addb $0x2b, %al
leaq 0x1(%rsp), %r12
movb %al, -0x1(%r12)
movzwl 0xb0(%r14), %eax
testl $0xf00, %eax            # imm = 0xF00
je 0x2113e
shrl $0x8, %eax
andl $0xf, %eax
xorl %ecx, %ecx
movb $0x20, (%r12,%rcx)
incq %rcx
cmpl %eax, %ecx
jb 0x2112f
addq %rcx, %r12
movl 0xa0(%r14), %eax
movl %eax, %edi
negl %edi
cmovsl %eax, %edi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x2b6c4
movzwl 0xb0(%r14), %r13d
movl %r13d, %ebp
andl $0xf, %ebp
movq %r15, %rdi
callq 0x2070
movl %ebp, %edx
subl %eax, %edx
jle 0x211a9
movzwl %ax, %ecx
movl %edx, %edx
addq %rsp, %rdx
addq $0x20, %rdx
movb 0x20(%rsp,%rcx), %sil
movb %sil, (%rdx,%rcx)
addq $-0x1, %rcx
jb 0x21181
notl %eax
addl %ebp, %eax
incq %rax
leaq 0x20(%rsp), %rdi
movl $0x30, %esi
movq %rax, %rdx
callq 0x20a0
movl %r13d, %eax
shrl $0x4, %eax
andl $0xf, %eax
cmovnel %eax, %ebp
testw %bp, %bp
je 0x211dc
movzwl %bp, %eax
movl %eax, %edx
xorl %ecx, %ecx
movb 0x20(%rsp,%rcx), %sil
testb %sil, %sil
je 0x211e0
movb %sil, (%r12,%rcx)
incq %rcx
cmpq %rcx, %rdx
jne 0x211c1
addq %rcx, %r12
jmp 0x211e5
xorl %eax, %eax
jmp 0x211ed
addq %rcx, %r12
movl %ecx, %eax
movzwl 0xb0(%r14), %r13d
testb $-0x10, %r13b
je 0x2122e
movb $0x2e, (%r12)
movzwl 0xb0(%r14), %ecx
andl $0xf, %ecx
cmpl %ecx, %eax
jae 0x2122e
movl %eax, %eax
incq %r12
movb 0x20(%rsp,%rax), %cl
testb %cl, %cl
je 0x2122e
movb %cl, (%r12)
incq %rax
movzwl 0xb0(%r14), %ecx
andl $0xf, %ecx
incq %r12
cmpq %rcx, %rax
jb 0x2120c
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x1fb7c
movl 0xac(%r14), %edx
movzwl 0xb0(%r14), %eax
movl %eax, %ecx
andb $0xf, %cl
cmpl $0xa, %edx
jl 0x2126a
movl $0xcccccccd, %esi       # imm = 0xCCCCCCCD
movl %edx, %edi
imulq %rsi, %rdi
shrq $0x23, %rdi
decb %cl
cmpl $0x63, %edx
movl %edi, %edx
ja 0x21257
movzbl %cl, %ecx
shrl $0x8, %eax
andb $0xf, %al
cmpw %cx, %bp
adcb %al, %cl
movzbl %cl, %esi
movq %rbx, %rdi
callq 0x1f5c6
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq