// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_misc/lv_printf.c
// Function: ntoa_format
static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t maxlen, char* buf, size_t len, bool negative, unsigned int base, unsigned int prec, unsigned int width, unsigned int flags)
{
  // pad leading zeros
  if (!(flags & FLAGS_LEFT)) {
    if (width && (flags & FLAGS_ZEROPAD) && (negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) {
      width--;
    }
    while ((len < prec) && (len < PRINTF_NTOA_BUFFER_SIZE)) {
      buf[len++] = '0';
    }
    while ((flags & FLAGS_ZEROPAD) && (len < width) && (len < PRINTF_NTOA_BUFFER_SIZE)) {
      buf[len++] = '0';
    }
  }

  // handle hash
  if (flags & FLAGS_HASH) {
    if (!(flags & FLAGS_PRECISION) && len && ((len == prec) || (len == width))) {
      len--;
      if (len && (base == 16U)) {
        len--;
      }
    }
    if ((base == 16U) && !(flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) {
      buf[len++] = 'x';
    }
    else if ((base == 16U) && (flags & FLAGS_UPPERCASE) && (len < PRINTF_NTOA_BUFFER_SIZE)) {
      buf[len++] = 'X';
    }
    else if ((base == 2U) && (len < PRINTF_NTOA_BUFFER_SIZE)) {
      buf[len++] = 'b';
    }
    if (len < PRINTF_NTOA_BUFFER_SIZE) {
      buf[len++] = '0';
    }
  }

  if (len < PRINTF_NTOA_BUFFER_SIZE) {
    if (negative) {
      buf[len++] = '-';
    }
    else if (flags & FLAGS_PLUS) {
      buf[len++] = '+';  // ignore the space if the '+' exists
    }
    else if (flags & FLAGS_SPACE) {
      buf[len++] = ' ';
    }
  }

  return _out_rev(out, buffer, idx, maxlen, buf, len, width, flags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rdx, %r8
movq %rsi, %r10
movl 0x60(%rsp), %r14d
movl 0x58(%rsp), %r11d
movl 0x50(%rsp), %r15d
movb 0x40(%rsp), %bpl
testb $0x2, %r14b
jne 0x2c4de
testl %r11d, %r11d
je 0x2c458
testb $0x1, %r14b
je 0x2c45b
testb $0xc, %r14b
setne %al
orb %bpl, %al
movzbl %al, %eax
subl %eax, %r11d
jmp 0x2c45b
xorl %r11d, %r11d
cmpl $0x20, %r15d
movl $0x20, %r12d
cmovbl %r15d, %r12d
movq %r12, %rdx
subq %r9, %rdx
jbe 0x2c4b2
addq %rbx, %r9
movq %rdi, (%rsp)
movq %r9, %rdi
movl $0x30, %esi
movq %rcx, %r13
movq %r8, %r15
movq %r10, %rbp
movq %r11, %r14
callq 0x20a0
movq (%rsp), %rdi
movq %r14, %r11
movl 0x60(%rsp), %r14d
movq %rbp, %r10
movb 0x40(%rsp), %bpl
movq %r15, %r8
movl 0x50(%rsp), %r15d
movq %r13, %rcx
jmp 0x2c4b5
movq %r9, %r12
testb $0x1, %r14b
je 0x2c4db
cmpl $0x20, %r11d
movl $0x20, %eax
cmovbl %r11d, %eax
cmpq %rax, %r12
jae 0x2c4db
movb $0x30, (%rbx,%r12)
incq %r12
testb $0x1, %r14b
jne 0x2c4c8
movq %r12, %r9
testb $0x10, %r14b
je 0x2c56c
movl 0x48(%rsp), %eax
btl $0xa, %r14d
setae %sil
testq %r9, %r9
setne %dl
andb %sil, %dl
cmpb $0x1, %dl
jne 0x2c529
movl %r15d, %edx
cmpq %rdx, %r9
je 0x2c513
movl %r11d, %edx
cmpq %rdx, %r9
jne 0x2c529
leaq -0x1(%r9), %rdx
addq $-0x2, %r9
testq %rdx, %rdx
cmoveq %rdx, %r9
cmpl $0x10, %eax
cmovneq %rdx, %r9
cmpl $0x10, %eax
jne 0x2c54a
testb $0x20, %r14b
jne 0x2c53c
movb $0x78, %dl
cmpq $0x20, %r9
jb 0x2c557
testb $0x20, %r14b
je 0x2c54a
movb $0x58, %dl
cmpq $0x20, %r9
jb 0x2c557
cmpl $0x2, %eax
jne 0x2c55e
movb $0x62, %dl
cmpq $0x1f, %r9
ja 0x2c55e
movb %dl, (%rbx,%r9)
incq %r9
cmpq $0x1f, %r9
ja 0x2c56c
movb $0x30, (%rbx,%r9)
incq %r9
cmpq $0x1f, %r9
ja 0x2c590
movb $0x2d, %al
testb %bpl, %bpl
jne 0x2c589
movb $0x2b, %al
testb $0x4, %r14b
jne 0x2c589
movb $0x20, %al
testb $0x8, %r14b
je 0x2c590
movb %al, (%rbx,%r9)
incq %r9
movq %r10, %rsi
movq %r8, %rdx
movq %rbx, %r8
pushq %r14
pushq %r11
callq 0x2c5b1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq