// File: /workspace/github_c_makefile_star2_O3/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), %r11d
movl 0x58(%rsp), %r14d
movl 0x50(%rsp), %r15d
movb 0x40(%rsp), %bpl
testb $0x2, %r11b
jne 0x2cc21
testl %r14d, %r14d
je 0x2cbbb
testb $0x1, %r11b
je 0x2cbbe
testb $0xc, %r11b
setne %al
orb %bpl, %al
movzbl %al, %eax
subl %eax, %r14d
jmp 0x2cbbe
xorl %r14d, %r14d
cmpl $0x20, %r15d
movl $0x20, %r12d
cmovbl %r15d, %r12d
movq %r12, %rdx
subq %r9, %rdx
jbe 0x2cc15
addq %rbx, %r9
movq %rdi, (%rsp)
movq %r9, %rdi
movl $0x30, %esi
movq %rcx, %r13
movq %r8, %r15
movq %r14, %rbp
movq %r10, %r14
callq 0x20a0
movq (%rsp), %rdi
movl 0x60(%rsp), %r11d
movq %r14, %r10
movq %rbp, %r14
movb 0x40(%rsp), %bpl
movq %r15, %r8
movl 0x50(%rsp), %r15d
movq %r13, %rcx
jmp 0x2cc18
movq %r9, %r12
testb $0x1, %r11b
jne 0x2cc8c
movq %r12, %r9
testb $0x10, %r11b
je 0x2ccca
movl 0x48(%rsp), %eax
movl %r11d, %esi
shrl $0xa, %esi
andl $0x1, %esi
testq %r9, %r9
sete %dl
orb %sil, %dl
jne 0x2cc69
movl %r15d, %edx
cmpq %rdx, %r9
je 0x2cc53
movl %r14d, %edx
cmpq %rdx, %r9
jne 0x2cc69
leaq -0x1(%r9), %rdx
addq $-0x2, %r9
testq %rdx, %rdx
cmoveq %rdx, %r9
cmpl $0x10, %eax
cmovneq %rdx, %r9
cmpl $0x10, %eax
jne 0x2cca8
testb $0x20, %r11b
jne 0x2cc7c
movb $0x78, %al
cmpq $0x20, %r9
jb 0x2ccb5
testb $0x20, %r11b
je 0x2ccbc
movb $0x58, %al
cmpq $0x20, %r9
jb 0x2ccb5
jmp 0x2ccbc
cmpl $0x20, %r14d
movl $0x20, %eax
cmovbl %r14d, %eax
cmpq %rax, %r12
jae 0x2cc1e
movb $0x30, (%rbx,%r12)
incq %r12
jmp 0x2cc99
cmpl $0x2, %eax
jne 0x2ccbc
movb $0x62, %al
cmpq $0x1f, %r9
ja 0x2ccbc
movb %al, (%rbx,%r9)
incq %r9
cmpq $0x1f, %r9
ja 0x2ccee
movb $0x30, (%rbx,%r9)
incq %r9
cmpq $0x1f, %r9
ja 0x2ccee
movb $0x2d, %al
testb %bpl, %bpl
jne 0x2cce7
movb $0x2b, %al
testb $0x4, %r11b
jne 0x2cce7
movb $0x20, %al
testb $0x8, %r11b
je 0x2ccee
movb %al, (%rbx,%r9)
incq %r9
movq %r10, %rsi
movq %r8, %rdx
movq %rbx, %r8
pushq %r11
pushq %r14
callq 0x2cd0f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq