// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_ta.c
// Function: lv_ta_add_char
void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
{
    LV_ASSERT_OBJ(ta, LV_OBJX_NAME);

    lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);

    uint32_t letter_buf[2];
    letter_buf[0] = c;
    letter_buf[1] = '\0';

    ta_insert_replace = NULL;
    lv_event_send(ta, LV_EVENT_INSERT, letter_buf);
    if(ta_insert_replace) {
        if(ta_insert_replace[0] == '\0') return; /*Drop this text*/

        /*Add the replaced text directly it's different from the original*/
        if(strcmp(ta_insert_replace, (char *)letter_buf)) {
            lv_ta_add_text(ta, ta_insert_replace);
            return;
        }
    }

    if(ext->one_line && (c == '\n' || c == '\r')) {
        LV_LOG_INFO("Text area: line break ignored in one-line mode");
        return;
    }

    uint32_t c_uni = lv_txt_encoded_next((const char *)&c, NULL);

    if(char_is_accepted(ta, c_uni) == false) {
        LV_LOG_INFO("Character is no accepted by the text area (too long text or not in the "
                    "accepted list)");
        return;
    }

    /*If a new line was added it shouldn't show edge flash effect*/
    bool edge_flash_en = lv_ta_get_edge_flash(ta);
    lv_ta_set_edge_flash(ta, false);

    if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/

    lv_label_ins_text(ext->label, ext->cursor.pos, (const char *)letter_buf); /*Insert the character*/
    lv_ta_clear_selection(ta);                                                /*Clear selection*/

    if(ext->pwd_mode != 0) {

        ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */
        LV_ASSERT_MEM(ext->pwd_tmp);
        if(ext->pwd_tmp == NULL) return;

        lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, (const char *)letter_buf);

#if LV_USE_ANIMATION
        /*Auto hide characters*/
        lv_anim_t a;
        a.var            = ta;
        a.exec_cb        = (lv_anim_exec_xcb_t)pwd_char_hider_anim;
        a.time           = ext->pwd_show_time;
        a.act_time       = 0;
        a.ready_cb       = pwd_char_hider_anim_ready;
        a.start          = 0;
        a.end            = 1;
        a.repeat         = 0;
        a.repeat_pause   = 0;
        a.playback       = 0;
        a.playback_pause = 0;
        a.path_cb        = lv_anim_path_step;
        lv_anim_create(&a);

#else
        pwd_char_hider(ta);
#endif
    }

    /*Move the cursor after the new character*/
    lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) + 1);

    /*Revert the original edge flash state*/
    lv_ta_set_edge_flash(ta, edge_flash_en);

    placeholder_update(ta);

    lv_event_send(ta, LV_EVENT_VALUE_CHANGED, NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, 0xc(%rsp)
callq 0x80e4
testb %al, %al
je 0x1f117
movq %rbx, %rdi
callq 0x6af7
movq %rax, %r14
leaq 0x4(%rsp), %rdx
movl %ebp, (%rdx)
movl $0x0, 0x4(%rdx)
movq $0x0, 0x41335(%rip) # 0x60408
movq %rbx, %rdi
movl $0xf, %esi
callq 0x5018
movq 0x41321(%rip), %r15     # 0x60408
testq %r15, %r15
je 0x1f128
cmpb $0x0, (%r15)
je 0x1f308
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
callq 0x20e0
testl %eax, %eax
je 0x1f128
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1f336
jmp 0x1f308
leaq 0x200c6(%rip), %rdi     # 0x3f1e4
movq %rbx, %rsi
callq 0x8294
jmp 0x1f126
testb $0x2, 0x98(%r14)
je 0x1f144
cmpl $0xa, %ebp
je 0x1f308
cmpl $0xd, %ebp
je 0x1f308
leaq 0x344e5(%rip), %r13     # 0x53630
leaq 0xc(%rsp), %rdi
xorl %esi, %esi
callq *(%r13)
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6af7
movq %rax, %r15
cmpq $0x0, 0x68(%rax)
movzwl 0x70(%rax), %eax
je 0x1f175
testw %ax, %ax
jne 0x1f17a
jmp 0x1f1a6
testw %ax, %ax
je 0x1f1d0
leaq 0x344cf(%rip), %rax     # 0x53650
movq (%rax), %r12
movq %rbx, %rdi
callq 0x2069b
movq %rax, %rdi
callq *%r12
movzwl 0x70(%r15), %ecx
cmpl %ecx, %eax
jae 0x1f308
cmpq $0x0, 0x68(%r15)
je 0x1f1d0
leaq 0x10(%rsp), %r12
movl $0x0, (%r12)
movq 0x68(%r15), %rdi
movl 0x10(%rsp), %eax
cmpb $0x0, (%rdi,%rax)
je 0x1f308
movq %r12, %rsi
callq *(%r13)
cmpl %ebp, %eax
jne 0x1f1b3
movq %rbx, %rdi
callq 0x26ac6
movl %eax, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x269ff
testb $0x1, 0x98(%r14)
je 0x1f1f6
movq %rbx, %rdi
callq 0x1ed9b
movq 0x50(%r14), %rdi
movzwl 0x82(%r14), %esi
leaq 0x4(%rsp), %rdx
callq 0x1be17
movq %rbx, %rdi
callq 0x80e4
testb %al, %al
je 0x1f317
testb $0x1, 0x98(%r14)
je 0x1f2d0
movq 0x60(%r14), %r15
movq %r15, %rdi
callq 0x2070
leaq 0x2(%rax), %rsi
movq %r15, %rdi
callq 0x2a06f
movq %rax, 0x60(%r14)
movq %rax, %rdi
callq 0x80e4
movq 0x60(%r14), %rsi
testb %al, %al
je 0x1f328
testq %rsi, %rsi
je 0x1f308
movzwl 0x82(%r14), %eax
leaq 0x4(%rsp), %rdx
movq %rsi, %rdi
movl %eax, %esi
callq 0x2b402
leaq 0x10(%rsp), %rdi
movq %rbx, (%rdi)
leaq 0x334(%rip), %rax       # 0x1f5bd
movq %rax, 0x8(%rdi)
movzwl 0x72(%r14), %eax
movw %ax, 0x28(%rdi)
movw $0x0, 0x2a(%rdi)
leaq 0x31b(%rip), %rax       # 0x1f5be
movq %rax, 0x18(%rdi)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x20(%rdi)
movl $0x0, 0x2c(%rdi)
movb $0x0, 0x30(%rdi)
leaq 0xac8d(%rip), %rax      # 0x29f54
movq %rax, 0x10(%rdi)
callq 0x29bb4
movq %rbx, %rdi
callq 0x1f823
incl %eax
movswl %ax, %esi
movq %rbx, %rdi
callq 0x1f5c6
movzbl %bpl, %esi
movq %rbx, %rdi
callq 0x269ff
movq %rbx, %rdi
callq 0x1f852
movq %rbx, %rdi
movl $0xe, %esi
xorl %edx, %edx
callq 0x5018
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1fec6(%rip), %rdi     # 0x3f1e4
movq %rbx, %rsi
callq 0x8294
jmp 0x1f326
leaq 0x1fda1(%rip), %rdi     # 0x3f0d0
callq 0x8294
jmp 0x1f334