// File: /workspace/github_c_makefile_star2_O3/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
testq %rax, %rax
jle 0x3f441
movq %rax, %r15
addq %r13, %r15
movl 0x10(%r14), %eax
movl %eax, -0x30(%rbp)
movq %rbx, -0x68(%rbp)
movb (%r13), %al
leaq 0x1(%r13), %r12
cmpb $0x25, %al
jne 0x3efad
cmpb $0x25, (%r12)
jne 0x3efbd
addq $0x2, %r13
movq %r14, %rdi
movl $0x25, %esi
callq 0x17947
movq %r13, %r12
jmp 0x3f1c3
movzbl %al, %esi
movq %r14, %rdi
callq 0x17947
jmp 0x3f1c3
movq %r12, %rdi
leaq -0x60(%rbp), %rsi
leaq -0x33(%rbp), %rdx
leaq -0x2b(%rbp), %rcx
callq 0x3f489
movq %rax, %r12
movzbl (%rax), %r13d
leal -0x41(%r13), %eax
cmpl $0x37, %eax
ja 0x3f477
leaq 0x2931c(%rip), %rcx     # 0x68308
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(%r13), %esi
cmpl $0x4, %esi
ja 0x3f020
movl $0x1, %ecx
movl $0x19, %edx
btl %esi, %edx
jb 0x3f029
xorl %ecx, %ecx
cmpl $0x4e, %r13d
sete %cl
leal -0x4e(%r13), %edi
cmpl $0x23, %edi
ja 0x3f047
movl $0x2, %edx
movabsq $0x800000009, %r8       # imm = 0x800000009
btq %rdi, %r8
jb 0x3f052
xorl %edx, %edx
cmpl $0x6e, %r13d
sete %dl
addl %edx, %edx
cmpl $0x20, %esi
ja 0x3f06c
movl $0x4, %edi
movabsq $0x100000003, %r8       # imm = 0x100000003
btq %rsi, %r8
jb 0x3f079
xorl %edi, %edi
cmpl $0x6e, %r13d
sete %dil
shll $0x2, %edi
movl (%rbx), %r8d
cmpq $0x28, %r8
ja 0x3f0c3
movq %r8, %rsi
addq 0x10(%rbx), %rsi
addl $0x8, %r8d
movl %r8d, (%rbx)
jmp 0x3f0cf
movl 0x4(%rbx), %ecx
cmpq $0xa0, %rcx
ja 0x3f0e9
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x10, %ecx
movl %ecx, 0x4(%rbx)
jmp 0x3f0f5
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3f115
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3f121
movq 0x8(%rbx), %rsi
leaq 0x8(%rsi), %r8
movq %r8, 0x8(%rbx)
orl %ecx, %edx
orl %edi, %edx
movq (%rsi), %rcx
movq %r14, %rdi
movl %eax, %esi
movl -0x30(%rbp), %r8d
callq 0x3ee13
jmp 0x3f1bc
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 0x3f19c
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rcx
jmp 0x3f185
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3f176
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3f182
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3f1d4
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3f1e0
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3f2fa
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3f306
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 0x3f453
testl %eax, %eax
jle 0x3f1bc
movq %r14, %rdi
leaq -0x170(%rbp), %rsi
movl %eax, %edx
callq 0x178c5
incq %r12
movq -0x68(%rbp), %rbx
movq %r12, %r13
cmpq %r15, %r12
jb 0x3ef81
jmp 0x3f441
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %r13
cmpb $0x73, (%r12)
jne 0x3f1f7
movq %r13, %rdi
callq 0x12310
movq %rax, %rbx
jmp 0x3f1fb
movl -0x8(%r13), %ebx
cmpb $0x0, -0x5e(%rbp)
je 0x3f2ed
movq %r13, %rdi
callq 0x12310
cmpl %eax, %ebx
jne 0x3f45f
leaq -0x60(%rbp), %rdi
movl $0x2e, %esi
callq 0x12370
testq %rax, %rax
jne 0x3f231
cmpl $0x64, %ebx
jge 0x3f46b
movl $0x100, %esi            # imm = 0x100
leaq -0x170(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movq %r13, %rcx
jmp 0x3f195
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3f36a
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3f376
leaq -0x2b(%rbp), %rdi
callq 0x12a20
testl %eax, %eax
movl $0x400, %ecx            # imm = 0x400
cmovlel %ecx, %eax
movl (%rbx), %edx
cmpq $0x28, %rdx
ja 0x3f386
movq %rdx, %rcx
addq 0x10(%rbx), %rcx
addl $0x8, %edx
movl %edx, (%rbx)
jmp 0x3f392
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3f3a7
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3f3b3
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3f3fb
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3f407
movl (%rbx), %ecx
cmpq $0x28, %rcx
ja 0x3f417
movq %rcx, %rax
addq 0x10(%rbx), %rax
addl $0x8, %ecx
movl %ecx, (%rbx)
jmp 0x3f423
movq %r14, %rdi
movq %r13, %rsi
movl %ebx, %edx
jmp 0x3f1b7
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movl (%rax), %r13d
testl %r13d, %r13d
je 0x3f1bc
movl $0x1, %eax
leaq 0x450f2(%rip), %rbx     # 0x84410
testb $0x1, %r13b
je 0x3f353
testl %eax, %eax
jne 0x3f346
cmpl $0x1, %r13d
leaq 0x28284(%rip), %rsi     # 0x675b7
leaq 0x2940d(%rip), %rax     # 0x68747
cmoveq %rax, %rsi
movq %r14, %rdi
callq 0x17878
movq (%rbx), %rsi
movq %r14, %rdi
callq 0x17878
xorl %eax, %eax
movl %r13d, %ecx
sarl %ecx
addq $0x8, %rbx
cmpl $0x2, %r13d
movl %ecx, %r13d
jae 0x3f31e
jmp 0x3f1bc
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3eb9c
jmp 0x3f1bc
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 0x3eeb1
jmp 0x3f1bc
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rdi
movq %rdi, %xmm0
movq %rdi, %rax
shrq $0x2f, %rax
andl $0xf, %eax
ucomisd %xmm0, %xmm0
movl $0x0, %ecx
cmovnpl %ecx, %eax
cmpl $0xe, %eax
jne 0x3f3e1
callq 0x4ebc4
movq -0x10(%rax), %rax
jmp 0x3f3eb
shll $0x3, %eax
addq 0x45bb5(%rip), %rax     # 0x84fa0
movq (%rax), %rsi
movq %r14, %rdi
callq 0x17878
jmp 0x3f1bc
movq 0x8(%rbx), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3e828
jmp 0x3f1bc
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 0x3f19c
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x291bd(%rip), %rdi     # 0x68617
callq 0x191a3
leaq 0x29143(%rip), %rdi     # 0x685a9
callq 0x191a3
leaq 0x2914d(%rip), %rdi     # 0x685bf
callq 0x191a3
leaq 0x29175(%rip), %rdi     # 0x685f3
leaq -0x60(%rbp), %rsi
xorl %eax, %eax
callq 0x190bb