// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_misc/lv_txt.c
// Function: lv_txt_get_next_line
uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font,
                              lv_coord_t letter_space, lv_coord_t max_width, lv_txt_flag_t flag)
{
    if(txt == NULL) return 0;
    if(font == NULL) return 0;

    if(flag & LV_TXT_FLAG_EXPAND) max_width = LV_COORD_MAX;
    lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
    uint32_t i = 0;                                        /* Iterating index into txt */

    while(txt[i] != '\0' && max_width > 0) {
        uint32_t word_w = 0;
        uint32_t advance = lv_txt_get_next_word(&txt[i], font, letter_space, max_width, flag, &word_w, &cmd_state, i==0);
        max_width -= word_w;

        if( advance == 0 ){
            if(i == 0) lv_txt_encoded_next(txt, &i); // prevent inf loops
            break;
        }

        i += advance;

        if(txt[0] == '\n' || txt[0] == '\r') break;

        if(txt[i] == '\n' || txt[i] == '\r'){
            i++;  /* Include the following newline in the current line */
            break;
        }

    }

    /* Always step at least one to avoid infinite loops */
    if(i == 0) {
        lv_txt_encoded_next(txt, &i);
    }

    return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %r15d
movl %edx, 0x3c(%rsp)
testq %rdi, %rdi
sete %dl
movq %rsi, 0x50(%rsp)
testq %rsi, %rsi
sete %cl
xorl %eax, %eax
orb %dl, %cl
jne 0x28ba4
movl %r8d, %ebp
movq %rdi, %r14
testb $0x2, %bpl
movl $0x7c18, %ecx           # imm = 0x7C18
cmovnel %ecx, %r15d
andl $0x0, 0x10(%rsp)
leaq 0x7(%rsp), %rcx
movb $0x0, (%rcx)
movb (%rdi), %cl
movq %rdi, 0x28(%rsp)
movl %r8d, 0xc(%rsp)
testb %cl, %cl
je 0x28b8d
testw %r15w, %r15w
jle 0x28b8d
movq %rax, 0x48(%rsp)
movl %eax, %ebx
addq %r14, %rbx
testb $0x2, %bpl
movl $0x7c18, %eax           # imm = 0x7C18
movl %r15d, 0x14(%rsp)
cmovel %r15d, %eax
movl %eax, 0x44(%rsp)
andl $0x0, (%rsp)
movq %rbx, %rdi
movq %rsp, %rsi
callq *0x28d2c(%rip)          # 0x51630
movl %eax, %r12d
movl (%rsp), %eax
movl %eax, 0x24(%rsp)
movl $0x0, 0x8(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
movl $0x0, 0x38(%rsp)
xorl %r15d, %r15d
pushq $-0x1
popq %rax
movl %eax, 0x1c(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x34(%rsp)
movl %ebp, 0x40(%rsp)
movl %r12d, %r14d
movl %ebp, %eax
cmpb $0x0, (%rbx,%rax)
je 0x28a55
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
callq *0x28cd2(%rip)          # 0x51630
movl %eax, %r13d
testb $0x1, 0xc(%rsp)
je 0x2898f
leaq 0x7(%rsp), %rdi
movl %r14d, %esi
callq 0x28c9d
testb %al, %al
je 0x2899a
movl (%rsp), %ebp
movl %ebp, 0x18(%rsp)
movl 0x24(%rsp), %eax
movl %eax, (%rsp)
incl %r15d
movl %r13d, %r14d
jmp 0x28944
movl 0x34(%rsp), %r14d
movl 0x40(%rsp), %ebp
jmp 0x289a0
movl %r14d, %r12d
movl %r15d, %r14d
movq 0x50(%rsp), %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x2603b
movl 0x38(%rsp), %edi
addl %eax, %edi
cmpw 0x44(%rsp), %di
pushq $-0x1
popq %rcx
cmovgl %ebp, %ecx
movl 0x20(%rsp), %esi
movl %esi, %edx
cmovgl %r14d, %edx
movl 0x1c(%rsp), %r8d
cmpl $-0x1, %r8d
cmovel %ecx, %r8d
cmovel %edx, %esi
movl %esi, 0x20(%rsp)
cmpl $0xa, %r12d
leaq 0x165a6(%rip), %rsi     # 0x3ef90
je 0x28a89
cmpl $0xd, %r12d
je 0x28a89
incl %r15d
xorl %ecx, %ecx
cmpq $0x7, %rcx
je 0x28a13
movsbl (%rcx,%rsi), %edx
incq %rcx
cmpl %edx, %r12d
jne 0x289ff
jmp 0x28a89
movl %r8d, 0x1c(%rsp)
cmpl $-0x1, %r8d
movl 0x8(%rsp), %ecx
cmovel %edi, %ecx
movl %ecx, 0x8(%rsp)
testw %ax, %ax
movl $0x0, %eax
cmovgl 0x3c(%rsp), %eax
addl %edi, %eax
movl (%rsp), %ebp
movl %ebp, 0x18(%rsp)
movl 0x24(%rsp), %ecx
movl %ecx, (%rsp)
movl %r13d, %r12d
movl %eax, 0x38(%rsp)
movl %r15d, 0x34(%rsp)
jmp 0x2893d
movl %ebp, %ecx
movl %r14d, %r12d
movl %r15d, %r14d
movl 0x1c(%rsp), %r8d
cmpl $-0x1, %r8d
je 0x28a99
cmpl $0xb, %r14d
ja 0x28aba
movl 0x8(%rsp), %eax
movl %eax, %edx
cmpl $0x0, 0x48(%rsp)
movq 0x28(%rsp), %r14
movl 0xc(%rsp), %ebp
movl 0x14(%rsp), %r15d
jmp 0x28ae6
movl %ebp, %ecx
testl %ebp, %ebp
jne 0x28a62
xorl %eax, %eax
cmpl $-0x1, %r8d
je 0x28aa1
jmp 0x28a62
movl %ecx, %eax
movl 0x8(%rsp), %ecx
movl %ecx, %edi
testl %r14d, %r14d
je 0x28ab2
cmpl $0xd, %r12d
jne 0x28af0
cmpl $0xa, %r13d
jne 0x28af0
movl %edi, %edx
movzwl (%rsp), %ecx
jmp 0x28af4
movl %r14d, %eax
movl 0x20(%rsp), %r13d
cmpl $0x2, %r13d
movq 0x28(%rsp), %r14
movl 0xc(%rsp), %ebp
movl 0x14(%rsp), %r15d
leaq 0x18(%rsp), %r12
ja 0x28b3b
movl 0x8(%rsp), %eax
movl %eax, %edx
cmpl $0x0, 0x48(%rsp)
movl %r8d, %ecx
je 0x28b02
jmp 0x28b72
movl %edi, %edx
movl %eax, %ecx
movq 0x28(%rsp), %r14
movl 0xc(%rsp), %ebp
movl 0x14(%rsp), %r15d
movl %ecx, %eax
andl $0xffff, %eax           # imm = 0xFFFF
je 0x28b72
addl 0x10(%rsp), %eax
movl %eax, 0x10(%rsp)
movzbl (%r14), %ecx
cmpl $0xa, %ecx
je 0x28b8d
cmpl $0xd, %ecx
je 0x28b8d
movl %eax, %ecx
movzbl (%r14,%rcx), %ecx
cmpl $0xd, %ecx
je 0x28b6a
subl %edx, %r15d
cmpl $0xa, %ecx
jne 0x288c2
jmp 0x28b6a
movl %r8d, 0x18(%rsp)
subl %eax, %r13d
addl $0x3, %r13d
testl %r13d, %r13d
jle 0x28b5d
movq %rbx, %rdi
movq %r12, %rsi
callq *0x28ae0(%rip)          # 0x51638
decl %r13d
jmp 0x28b47
movzwl 0x18(%rsp), %ecx
movl 0x8(%rsp), %eax
movl %eax, %edx
jmp 0x28b02
incl %eax
movl %eax, 0x10(%rsp)
jmp 0x28b8d
movl 0x10(%rsp), %eax
testl %eax, %eax
jne 0x28ba4
leaq 0x10(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x28aa5(%rip)          # 0x51630
movl (%rbx), %eax
testl %eax, %eax
jne 0x28ba4
leaq 0x10(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq *0x28a8e(%rip)          # 0x51630
movl (%rbx), %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq