// File: /workspace/github_c_makefile_star2_O1/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 $0x158, %rsp            # imm = 0x158
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r14
movq %rsi, %rdi
callq 0x12310
testq %rax, %rax
jle 0x3fb61
movq %rax, %rbx
addq %r13, %rbx
movl 0x10(%r14), %eax
movl %eax, -0x30(%rbp)
movb (%r13), %al
leaq 0x1(%r13), %r12
cmpb $0x25, %al
jne 0x3f69b
movb (%r12), %al
cmpb $0x25, %al
jne 0x3f6ab
addq $0x2, %r13
movzbl %al, %esi
movq %r14, %rdi
callq 0x179a7
movq %r13, %r12
jmp 0x3f8c5
movzbl %al, %esi
movq %r14, %rdi
callq 0x179a7
jmp 0x3f8c5
movq %r12, %rdi
leaq -0x70(%rbp), %rsi
leaq -0x43(%rbp), %rdx
leaq -0x2b(%rbp), %rcx
callq 0x3fba9
movq %rax, %r12
movzbl (%rax), %r13d
leal -0x41(%r13), %eax
cmpl $0x37, %eax
ja 0x3fb97
leaq 0x29c4e(%rip), %rcx     # 0x69328
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x2b(%rbp), %rdi
callq 0x12a30
testl %eax, %eax
movl $0x400, %ecx            # imm = 0x400
cmovlel %ecx, %eax
leal -0x4d(%r13), %esi
cmpl $0x4, %esi
ja 0x3f70e
movl $0x1, %ecx
movl $0x19, %edx
btl %esi, %edx
jb 0x3f717
xorl %ecx, %ecx
cmpl $0x4e, %r13d
sete %cl
leal -0x4e(%r13), %edi
cmpl $0x23, %edi
ja 0x3f735
movl $0x2, %edx
movabsq $0x800000009, %r8       # imm = 0x800000009
btq %rdi, %r8
jb 0x3f740
xorl %edx, %edx
cmpl $0x6e, %r13d
sete %dl
addl %edx, %edx
cmpl $0x20, %esi
ja 0x3f75a
movl $0x4, %edi
movabsq $0x100000003, %r8       # imm = 0x100000003
btq %rsi, %r8
jb 0x3f767
xorl %edi, %edi
cmpl $0x6e, %r13d
sete %dil
shll $0x2, %edi
movl (%r15), %r8d
cmpq $0x28, %r8
ja 0x3f7b5
movq %r8, %rsi
addq 0x10(%r15), %rsi
addl $0x8, %r8d
movl %r8d, (%r15)
jmp 0x3f7c1
movl 0x4(%r15), %ecx
cmpq $0xa0, %rcx
ja 0x3f7de
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x10, %ecx
movl %ecx, 0x4(%r15)
jmp 0x3f7ea
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x3f80a
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x3f816
movq 0x8(%r15), %rsi
leaq 0x8(%rsi), %r8
movq %r8, 0x8(%r15)
orl %ecx, %edx
orl %edi, %edx
movq (%rsi), %rcx
movq %r14, %rdi
movl %eax, %esi
movl -0x30(%rbp), %r8d
callq 0x3f509
xorl %r13d, %r13d
jmp 0x3f89e
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movsd (%rax), %xmm0
movl $0x100, %esi            # imm = 0x100
leaq -0x180(%rbp), %rdi
leaq -0x70(%rbp), %rdx
movb $0x1, %al
callq 0x12390
jmp 0x3f89b
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %rcx
jmp 0x3f884
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x3f875
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x3f881
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x3f8d6
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x3f8e2
movl (%r15), %ecx
cmpq $0x28, %rcx
movq %rbx, -0x40(%rbp)
ja 0x3fa16
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x3fa22
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movslq (%rax), %rcx
movl $0x100, %esi            # imm = 0x100
leaq -0x180(%rbp), %rdi
leaq -0x70(%rbp), %rdx
xorl %eax, %eax
callq 0x12390
movl %eax, %r13d
cmpl $0x100, %r13d           # imm = 0x100
jge 0x3fb73
testl %r13d, %r13d
jle 0x3f8c2
movq %r14, %rdi
leaq -0x180(%rbp), %rsi
movl %r13d, %edx
callq 0x17925
incq %r12
movq %r12, %r13
cmpq %rbx, %r12
jb 0x3f670
jmp 0x3fb61
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %r13
cmpb $0x73, (%r12)
jne 0x3f8f6
movq %r13, %rdi
callq 0x12310
jmp 0x3f8fa
movl -0x8(%r13), %eax
cmpb $0x0, -0x6e(%rbp)
je 0x3fa04
movq %r13, -0x38(%rbp)
movq %r13, %rdi
movq %rax, %r13
callq 0x12310
movq %r13, -0x78(%rbp)
cmpl %eax, %r13d
jne 0x3fb7f
leaq -0x70(%rbp), %rdi
movl $0x2e, %esi
callq 0x12370
testq %rax, %rax
jne 0x3f93d
cmpl $0x64, -0x78(%rbp)
jge 0x3fb8b
movl $0x100, %esi            # imm = 0x100
leaq -0x180(%rbp), %rdi
leaq -0x70(%rbp), %rdx
movq -0x38(%rbp), %rcx
jmp 0x3f894
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x3fa8a
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x3fa96
leaq -0x2b(%rbp), %rdi
callq 0x12a30
testl %eax, %eax
movl $0x400, %ecx            # imm = 0x400
cmovlel %ecx, %eax
movl (%r15), %edx
cmpq $0x28, %rdx
ja 0x3faa6
movq %rdx, %rcx
addq 0x10(%r15), %rcx
addl $0x8, %edx
movl %edx, (%r15)
jmp 0x3fab2
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x3fac7
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x3fad3
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x3fb1b
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x3fb27
movl (%r15), %ecx
cmpq $0x28, %rcx
ja 0x3fb37
movq %rcx, %rax
addq 0x10(%r15), %rax
addl $0x8, %ecx
movl %ecx, (%r15)
jmp 0x3fb43
movq %r14, %rdi
movq %r13, %rsi
movl %eax, %edx
callq 0x17925
jmp 0x3f7d6
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movl (%rax), %ebx
xorl %r13d, %r13d
testl %ebx, %ebx
je 0x3fa81
movq %r15, -0x38(%rbp)
movl $0x1, %eax
leaq 0x459d5(%rip), %r15     # 0x85410
testb $0x1, %bl
je 0x3fa6e
testl %eax, %eax
jne 0x3fa61
cmpl $0x1, %ebx
leaq 0x28b89(%rip), %rsi     # 0x685d7
leaq 0x29d12(%rip), %rax     # 0x69767
cmoveq %rax, %rsi
movq %r14, %rdi
callq 0x178d8
movq (%r15), %rsi
movq %r14, %rdi
callq 0x178d8
xorl %eax, %eax
movl %ebx, %ecx
sarl %ecx
addq $0x8, %r15
cmpl $0x2, %ebx
movl %ecx, %ebx
jae 0x3fa3b
movq -0x38(%rbp), %r15
movq -0x40(%rbp), %rbx
jmp 0x3f89e
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3f295
jmp 0x3f7d6
movq 0x8(%r15), %rcx
leaq 0x8(%rcx), %rdx
movq %rdx, 0x8(%r15)
movq (%rcx), %rdx
movq %r14, %rdi
movl %eax, %esi
movl -0x30(%rbp), %ecx
callq 0x3f5a4
jmp 0x3f7d6
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
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 0x3fb01
callq 0x4f838
movq -0x10(%rax), %rax
jmp 0x3fb0b
shll $0x3, %eax
addq 0x46495(%rip), %rax     # 0x85fa0
movq (%rax), %rsi
movq %r14, %rdi
callq 0x178d8
jmp 0x3f7d6
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movq (%rax), %rsi
movq %r14, %rdi
callq 0x3ef10
jmp 0x3f7d6
movq 0x8(%r15), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%r15)
movl (%rax), %ecx
movl $0x100, %esi            # imm = 0x100
leaq -0x180(%rbp), %rdi
leaq -0x70(%rbp), %rdx
xorl %eax, %eax
callq 0x12390
jmp 0x3f89b
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29abd(%rip), %rdi     # 0x69637
callq 0x19263
leaq 0x29a43(%rip), %rdi     # 0x695c9
callq 0x19263
leaq 0x29a4d(%rip), %rdi     # 0x695df
callq 0x19263
leaq 0x29a75(%rip), %rdi     # 0x69613
leaq -0x70(%rbp), %rsi
xorl %eax, %eax
callq 0x1917b