// File: /workspace/github_c_makefile_star2_O2/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 %rbx
pushq %rax
movl 0x50(%rsp), %r10d
movl 0x48(%rsp), %eax
movl 0x40(%rsp), %ebx
movb 0x30(%rsp), %r11b
testb $0x2, %r10b
jne 0x2a341
testl %eax, %eax
je 0x2a306
testb $0x1, %r10b
je 0x2a308
testb $0xc, %r10b
setne %bpl
orb %r11b, %bpl
movzbl %bpl, %ebp
subl %ebp, %eax
jmp 0x2a308
xorl %eax, %eax
cmpl $0x20, %ebx
pushq $0x20
popq %r14
movl %r14d, %r15d
cmovbl %ebx, %r15d
cmpq %r15, %r9
jae 0x2a325
movb $0x30, (%r8,%r9)
incq %r9
jmp 0x2a316
cmpl $0x20, %eax
cmovbl %eax, %r14d
testb $0x1, %r10b
je 0x2a341
cmpq %r14, %r9
jae 0x2a341
movb $0x30, (%r8,%r9)
incq %r9
jmp 0x2a32c
testb $0x10, %r10b
je 0x2a3d1
movl 0x38(%rsp), %ebp
btl $0xa, %r10d
setae %r14b
testq %r9, %r9
setne %r15b
andb %r14b, %r15b
cmpb $0x1, %r15b
jne 0x2a38c
movl %ebx, %ebx
cmpq %rbx, %r9
je 0x2a376
movl %eax, %ebx
cmpq %rbx, %r9
jne 0x2a38c
leaq -0x1(%r9), %rbx
addq $-0x2, %r9
testq %rbx, %rbx
cmoveq %rbx, %r9
cmpl $0x10, %ebp
cmovneq %rbx, %r9
cmpl $0x10, %ebp
jne 0x2a3af
testb $0x20, %r10b
jne 0x2a39f
movb $0x78, %bl
cmpq $0x20, %r9
jb 0x2a3bc
testb $0x20, %r10b
je 0x2a3c3
movb $0x58, %bl
cmpq $0x20, %r9
jb 0x2a3bc
jmp 0x2a3c3
cmpl $0x2, %ebp
jne 0x2a3c3
movb $0x62, %bl
cmpq $0x1f, %r9
ja 0x2a3c3
movb %bl, (%r8,%r9)
incq %r9
cmpq $0x1f, %r9
ja 0x2a3f5
movb $0x30, (%r8,%r9)
incq %r9
cmpq $0x1f, %r9
ja 0x2a3f5
movb $0x2d, %bl
testb %r11b, %r11b
jne 0x2a3ee
movb $0x2b, %bl
testb $0x4, %r10b
jne 0x2a3ee
movb $0x20, %bl
testb $0x8, %r10b
je 0x2a3f5
movb %bl, (%r8,%r9)
incq %r9
pushq %r10
pushq %rax
callq 0x2a408
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq