// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/pp.c
// Function: janet_formatbv
void janet_formatbv(JanetBuffer *b, const char *format, va_list args) {
    const char *format_end = format + strlen(format);
    const char *c = format;
    int32_t startlen = b->count;
    while (c < format_end) {
        if (*c != '%') {
            janet_buffer_push_u8(b, (uint8_t) *c++);
        } else if (*++c == '%') {
            janet_buffer_push_u8(b, (uint8_t) *c++);
        } else {
            char form[MAX_FORMAT], item[MAX_ITEM];
            char width[3], precision[3];
            int nb = 0; /* number of bytes in added item */
            c = scanformat(c, form, width, precision);
            switch (*c++) {
                case 'c': {
                    int n = va_arg(args, int);
                    nb = snprintf(item, MAX_ITEM, form, n);
                    break;
                }
                case 'd':
                case 'i': {
                    int64_t n = (int64_t) va_arg(args, int32_t);
                    nb = snprintf(item, MAX_ITEM, form, n);
                    break;
                }
                case 'D':
                case 'I': {
                    int64_t n = va_arg(args, int64_t);
                    nb = snprintf(item, MAX_ITEM, form, n);
                    break;
                }
                case 'x':
                case 'X':
                case 'o':
                case 'u': {
                    uint64_t n = va_arg(args, uint64_t);
                    nb = snprintf(item, MAX_ITEM, form, n);
                    break;
                }
                case 'a':
                case 'A':
                case 'e':
                case 'E':
                case 'f':
                case 'g':
                case 'G': {
                    double d = va_arg(args, double);
                    nb = snprintf(item, MAX_ITEM, form, d);
                    break;
                }
                case 's':
                case 'S': {
                    const char *str = va_arg(args, const char *);
                    int32_t len = c[-1] == 's'
                                  ? (int32_t) strlen(str)
                                  : janet_string_length((JanetString) str);
                    if (form[2] == '\0')
                        janet_buffer_push_bytes(b, (const uint8_t *) str, len);
                    else {
                        if (len != (int32_t) strlen((const char *) str))
                            janet_panic("string contains zeros");
                        if (!strchr(form, '.') && len >= 100) {
                            janet_panic("no precision and string is too long to be formatted");
                        } else {
                            nb = snprintf(item, MAX_ITEM, form, str);
                        }
                    }
                    break;
                }
                case 'V':
                    janet_to_string_b(b, va_arg(args, Janet));
                    break;
                case 'v':
                    janet_description_b(b, va_arg(args, Janet));
                    break;
                case 't':
                    janet_buffer_push_cstring(b, typestr(va_arg(args, Janet)));
                    break;
                case 'T': {
                    int types = va_arg(args, int);
                    pushtypes(b, types);
                    break;
                }
                case 'M':
                case 'm':
                case 'N':
                case 'n':
                case 'Q':
                case 'q':
                case 'P':
                case 'p': { /* janet pretty , precision = depth */
                    int depth = atoi(precision);
                    if (depth < 1) depth = JANET_RECURSION_GUARD;
                    char d = c[-1];
                    int has_color = (d == 'P') || (d == 'Q') || (d == 'M') || (d == 'N');
                    int has_oneline = (d == 'Q') || (d == 'q') || (d == 'N') || (d == 'n');
                    int has_notrunc = (d == 'M') || (d == 'm') || (d == 'N') || (d == 'n');
                    int flags = 0;
                    flags |= has_color ? JANET_PRETTY_COLOR : 0;
                    flags |= has_oneline ? JANET_PRETTY_ONELINE : 0;
                    flags |= has_notrunc ? JANET_PRETTY_NOTRUNC : 0;
                    janet_pretty_(b, depth, flags, va_arg(args, Janet), startlen);
                    break;
                }
                case 'j': {
                    int depth = atoi(precision);
                    if (depth < 1)
                        depth = JANET_RECURSION_GUARD;
                    janet_jdn_(b, depth, va_arg(args, Janet), startlen);
                    break;
                }
                default: {
                    /* also treat cases 'nLlh' */
                    janet_panicf("invalid conversion '%s' to 'format'",
                                 form);
                }
            }
            if (nb >= MAX_ITEM)
                janet_panic("format buffer overflow");
            if (nb > 0)
                janet_buffer_push_bytes(b, (uint8_t *) item, nb);
        }

    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r14
movq %rsi, %rdi
callq 0x12310
movq %rax, %r15
addq %r13, %r15
movl 0x10(%r14), %eax
movl %eax, -0x30(%rbp)
movq %rbx, -0x68(%rbp)
cmpq %r15, %r13
jae 0x3be6e
movb (%r13), %al
leaq 0x1(%r13), %r12
cmpb $0x25, %al
jne 0x3ba33
cmpb $0x25, (%r12)
jne 0x3ba43
addq $0x2, %r13
movq %r14, %rdi
pushq $0x25
popq %rsi
callq 0x161be
jmp 0x3ba06
movzbl %al, %esi
movq %r14, %rdi
callq 0x161be
movq %r12, %r13
jmp 0x3ba06
movq %r12, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x33(%rbp), %rdx
leaq -0x2b(%rbp), %rcx
callq 0x3beb6
movq %rax, %r13
movzbl (%rax), %r12d
leal -0x41(%r12), %eax
cmpl $0x37, %eax
ja 0x3bea4
leaq 0x288b5(%rip), %rcx     # 0x64328
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x2b(%rbp), %rdi
callq 0x12a20
testl %eax, %eax
movl $0x400, %ecx            # imm = 0x400
cmovlel %ecx, %eax
leal -0x4d(%r12), %esi
cmpl $0x4, %esi
ja 0x3baa4
pushq $0x19
popq %rcx
btl %esi, %ecx
pushq $0x1
popq %rcx
jb 0x3baad
xorl %ecx, %ecx
cmpl $0x4e, %r12d
sete %cl
leal -0x4e(%r12), %edx
cmpl $0x23, %edx
ja 0x3baca
movabsq $0x800000009, %rdi      # imm = 0x800000009
btq %rdx, %rdi
pushq $0x2
popq %rdx
jb 0x3bad5
xorl %edx, %edx
cmpl $0x6e, %r12d
sete %dl
addl %edx, %edx
cmpl $0x20, %esi
ja 0x3baed
movabsq $0x100000003, %rdi      # imm = 0x100000003
btq %rsi, %rdi
pushq $0x4
popq %rsi
jb 0x3bafa
xorl %esi, %esi
cmpl $0x6e, %r12d
sete %sil
shll $0x2, %esi
movl (%rbx), %r8d
cmpq $0x28, %r8
ja 0x3bb44
movq %r8, %rdi
addq 0x10(%rbx), %rdi
addl $0x8, %r8d
movl %r8d, (%rbx)
jmp 0x3bb50
movl 0x4(%rbx), %ecx
cmpq $0xa0, %rcx
ja 0x3bb6a
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x10, %ecx
movl %ecx, 0x4(%rbx)
jmp 0x3bb76
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3bb96
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3bba2
movq 0x8(%rbx), %rdi
leaq 0x8(%rdi), %r8
movq %r8, 0x8(%rbx)
orl %ecx, %edx
orl %esi, %edx
movq (%rdi), %rcx
movq %r14, %rdi
movl %eax, %esi
movl -0x30(%rbp), %r8d
callq 0x3b8ae
jmp 0x3bc36
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movsd (%rax), %xmm0
movl $0x100, %esi            # imm = 0x100
leaq -0x170(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movb $0x1, %al
callq 0x12390
jmp 0x3bc16
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rcx
jmp 0x3bbff
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3bbf0
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3bbfc
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3bc42
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3bc4e
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3bd67
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3bd73
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movslq (%rax), %rcx
movl $0x100, %esi            # imm = 0x100
leaq -0x170(%rbp), %rdi
leaq -0x60(%rbp), %rdx
xorl %eax, %eax
callq 0x12390
cmpl $0x100, %eax            # imm = 0x100
jge 0x3be80
testl %eax, %eax
jle 0x3bc36
movq %r14, %rdi
leaq -0x170(%rbp), %rsi
movl %eax, %edx
callq 0x16172
incq %r13
movq -0x68(%rbp), %rbx
jmp 0x3ba06
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %r12
cmpb $0x73, (%r13)
jne 0x3bc65
movq %r12, %rdi
callq 0x12310
movq %rax, %rbx
jmp 0x3bc6a
movl -0x8(%r12), %ebx
cmpb $0x0, -0x5e(%rbp)
je 0x3bd5a
movq %r12, %rdi
callq 0x12310
cmpl %eax, %ebx
jne 0x3be8c
leaq -0x60(%rbp), %rdi
pushq $0x2e
popq %rsi
callq 0x12370
testq %rax, %rax
jne 0x3bc9e
cmpl $0x64, %ebx
jge 0x3be98
movl $0x100, %esi            # imm = 0x100
leaq -0x170(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movq %r12, %rcx
jmp 0x3bc0f
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3bdc7
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3bdd3
leaq -0x2b(%rbp), %rdi
callq 0x12a20
testl %eax, %eax
movl $0x400, %ecx            # imm = 0x400
cmovlel %ecx, %eax
movl (%rbx), %edx
cmpq $0x28, %rdx
ja 0x3bde3
movq %rdx, %rcx
addq 0x10(%rbx), %rcx
addl $0x8, %edx
movl %edx, (%rbx)
jmp 0x3bdef
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3be04
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3be10
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3be28
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3be34
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3be44
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3be50
movq %r14, %rdi
movq %r12, %rsi
movl %ebx, %edx
jmp 0x3bc31
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movl (%rax), %r12d
leaq 0x43693(%rip), %rbx     # 0x7f410
pushq $0x1
popq %rax
testl %r12d, %r12d
je 0x3bc36
testb $0x1, %r12b
je 0x3bdbe
testl %eax, %eax
jne 0x3bdb1
cmpl $0x1, %r12d
leaq 0x27839(%rip), %rsi     # 0x635d7
leaq 0x289c2(%rip), %rax     # 0x64767
cmoveq %rax, %rsi
movq %r14, %rdi
callq 0x1614c
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x1614c
xorl %eax, %eax
sarl %r12d
addq $0x8, %rbx
jmp 0x3bd80
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3b65f
jmp 0x3bc36
movq 0x8(%rbx), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rbx)
movq (%rcx), %rdx
movq %r14, %rdi
movl %eax, %esi
movl -0x30(%rbp), %ecx
callq 0x3b944
jmp 0x3bc36
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rdi
callq 0x3c0b2
movq %r14, %rdi
movq %rax, %rsi
callq 0x1614c
jmp 0x3bc36
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3b300
jmp 0x3bc36
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movl (%rax), %ecx
movl $0x100, %esi            # imm = 0x100
leaq -0x170(%rbp), %rdi
leaq -0x60(%rbp), %rdx
xorl %eax, %eax
callq 0x12390
jmp 0x3bc16
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x287b0(%rip), %rdi     # 0x64637
callq 0x177b1
leaq 0x28736(%rip), %rdi     # 0x645c9
callq 0x177b1
leaq 0x28740(%rip), %rdi     # 0x645df
callq 0x177b1
leaq 0x28768(%rip), %rdi     # 0x64613
leaq -0x60(%rbp), %rsi
xorl %eax, %eax
callq 0x176c9