// File: /workspace/github_c_makefile_star2_O1/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, %r13d
movl %edx, 0x34(%rsp)
testq %rdi, %rdi
sete %dl
movq %rsi, 0x50(%rsp)
testq %rsi, %rsi
sete %cl
xorl %eax, %eax
orb %dl, %cl
jne 0x2ab3a
movl %r8d, %ebp
movq %rdi, %r14
testb $0x2, %bpl
movl $0x7c18, %eax           # imm = 0x7C18
cmovnel %eax, %r13d
movl $0x0, 0x8(%rsp)
movl $0x0, 0x1c(%rsp)
movq %rdi, 0x28(%rsp)
movl %r8d, 0x14(%rsp)
movl 0x8(%rsp), %eax
cmpb $0x0, (%r14,%rax)
je 0x2ab20
testw %r13w, %r13w
jle 0x2ab20
movq %rax, 0x48(%rsp)
leaq (%r14,%rax), %r15
testb $0x2, %bpl
movl $0x7c18, %eax           # imm = 0x7C18
cmovel %r13d, %eax
movl %eax, 0x44(%rsp)
xorl %eax, %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq *0x28dfd(%rip)          # 0x53630
movl %eax, %r10d
movl 0x10(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0xc(%rsp), %eax
cmpb $0x0, (%r15,%rax)
je 0x2a9ee
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl $0x0, 0x4(%rsp)
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %edx, %edx
movl %r13d, 0x20(%rsp)
movl %edx, 0x40(%rsp)
movl %r9d, 0x24(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, %r14d
movl %ecx, 0x38(%rsp)
movl %r10d, 0x3c(%rsp)
movl %r10d, %r13d
movl %ecx, %ebp
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq *0x28d9d(%rip)          # 0x53630
movl %eax, %ebx
testb $0x1, 0x14(%rsp)
je 0x2a906
cmpl $0x23, %r13d
sete %al
cmpb $0x3, %r14b
setb %dl
movzbl %r14b, %esi
leal (,%rsi,8), %ecx
movl $0x1, %edi
shrl %cl, %edi
andb %al, %dl
testb %dl, %dl
cmovel %esi, %edi
cmpl $0x20, %r13d
sete %al
incb %al
movzbl %al, %eax
cmpb $0x1, %dil
cmovnel %edi, %eax
je 0x2a8e1
xorb $0x1, %r14b
andb %r14b, %dl
je 0x2a911
movl 0x10(%rsp), %edx
movl %edx, 0xc(%rsp)
movl 0x18(%rsp), %ecx
movl %ecx, 0x10(%rsp)
leal 0x1(%rbp), %ecx
cmpb $0x0, (%r15,%rdx)
movl %eax, %r14d
movl %ebx, %r13d
jne 0x2a883
jmp 0x2aa23
movl 0x38(%rsp), %r13d
movl 0x3c(%rsp), %esi
jmp 0x2a91b
movl %eax, 0x1c(%rsp)
movl %r13d, %esi
movl %ebp, %r13d
movq 0x50(%rsp), %rdi
movl %ebx, %edx
movl %esi, %r14d
callq 0x27d87
movl %r14d, %r10d
movl 0x40(%rsp), %edi
addl %eax, %edi
cmpw 0x44(%rsp), %di
movl 0xc(%rsp), %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovgl %edx, %ecx
movl %r12d, %esi
movl %r13d, %r11d
cmovgl %r13d, %esi
movl 0x24(%rsp), %r9d
cmpl $-0x1, %r9d
cmovel %ecx, %r9d
cmovel %esi, %r12d
movzwl %di, %ecx
cmpl $0x20, %r14d
movl 0x20(%rsp), %r13d
leaq 0x1858e(%rip), %r8      # 0x42f00
ja 0x2a987
movl %r10d, %esi
movabsq $0x100002400, %rdi      # imm = 0x100002400
btq %rsi, %rdi
jb 0x2aa06
leal 0x1(%rbp), %r14d
movl $0x1, %esi
cmpq $0x7, %rsi
je 0x2a9a5
movsbl (%rsi,%r8), %edi
incq %rsi
cmpl %edi, %r10d
jne 0x2a990
jmp 0x2aa06
cmpl $-0x1, %r9d
movl 0x4(%rsp), %edx
cmovel %ecx, %edx
movl %edx, 0x4(%rsp)
testw %ax, %ax
movl $0x0, %edx
cmovgl 0x34(%rsp), %edx
addl %ecx, %edx
movl 0x10(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0x18(%rsp), %ecx
movl %ecx, 0x10(%rsp)
cmpb $0x0, (%r15,%rax)
movl %ebx, %r10d
movl %r14d, %ecx
jne 0x2a867
incl %ebp
movl %ebx, %r10d
movl %ebp, %r11d
jmp 0x2aa18
movl $0x0, 0x4(%rsp)
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %r11d, %r11d
xorl %ebx, %ebx
xorl %r12d, %r12d
jmp 0x2aa42
movl %r9d, %eax
notl %eax
orl %eax, %edx
movl 0x4(%rsp), %eax
cmovel %ecx, %eax
movl %eax, 0x4(%rsp)
movq 0x28(%rsp), %r14
movl 0x14(%rsp), %ebp
jmp 0x2aa42
incl %ebp
movl %eax, 0x1c(%rsp)
movl %ebx, %r10d
movl %ebp, %r11d
movq 0x28(%rsp), %r14
movl 0x14(%rsp), %ebp
movl 0x20(%rsp), %r13d
movl 0x24(%rsp), %r9d
cmpl $-0x1, %r9d
je 0x2aa5f
cmpl $0xb, %r11d
leaq 0xc(%rsp), %rbx
ja 0x2aa7a
cmpl $0x0, 0x48(%rsp)
movl $0x0, %eax
jmp 0x2aa8a
testl %r11d, %r11d
je 0x2aa70
xorl $0xd, %r10d
xorl $0xa, %ebx
orl %r10d, %ebx
jne 0x2aac1
movl 0x10(%rsp), %eax
movl %eax, 0xc(%rsp)
jmp 0x2aac1
cmpl $0x2, %r12d
movl $0x0, %eax
ja 0x2aa97
cmpl $0x0, 0x48(%rsp)
movl 0x4(%rsp), %edx
cmovnel %eax, %edx
cmovnel %eax, %r9d
jmp 0x2aacb
movl %r9d, 0xc(%rsp)
subl %r11d, %r12d
leal 0x3(%r12), %eax
testl %eax, %eax
jle 0x2aac1
addl $0x4, %r12d
movq %r15, %rdi
movq %rbx, %rsi
callq *0x28b80(%rip)          # 0x53638
decl %r12d
cmpl $0x1, %r12d
jg 0x2aaac
movzwl 0xc(%rsp), %r9d
movl 0x4(%rsp), %edx
testw %r9w, %r9w
je 0x2ab0b
movzwl %r9w, %eax
addl 0x8(%rsp), %eax
movl %eax, 0x8(%rsp)
movzbl (%r14), %ecx
cmpl $0xa, %ecx
je 0x2ab20
cmpl $0xd, %ecx
je 0x2ab20
movl %eax, %ecx
movzbl (%r14,%rcx), %ecx
cmpl $0xd, %ecx
je 0x2ab03
subl %edx, %r13d
cmpl $0xa, %ecx
jne 0x2a7e4
incl %eax
movl %eax, 0x8(%rsp)
jmp 0x2ab20
cmpl $0x0, 0x8(%rsp)
jne 0x2ab20
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq *0x28b10(%rip)          # 0x53630
cmpl $0x0, 0x8(%rsp)
jne 0x2ab35
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq *0x28afb(%rip)          # 0x53630
movzwl 0x8(%rsp), %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq