// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/pp.c
// Function: janet_buffer_format
void janet_buffer_format(
    JanetBuffer *b,
    const char *strfrmt,
    int32_t argstart,
    int32_t argc,
    Janet *argv) {
    size_t sfl = strlen(strfrmt);
    const char *strfrmt_end = strfrmt + sfl;
    int32_t arg = argstart;
    int32_t startlen = b->count;
    while (strfrmt < strfrmt_end) {
        if (*strfrmt != '%')
            janet_buffer_push_u8(b, (uint8_t) * strfrmt++);
        else if (*++strfrmt == '%')
            janet_buffer_push_u8(b, (uint8_t) * strfrmt++); /* %% */
        else { /* format item */
            char form[MAX_FORMAT], item[MAX_ITEM];
            char width[3], precision[3];
            int nb = 0; /* number of bytes in added item */
            if (++arg >= argc)
                janet_panic("not enough values for format");
            strfrmt = scanformat(strfrmt, form, width, precision);
            switch (*strfrmt++) {
                case 'c': {
                    nb = snprintf(item, MAX_ITEM, form, (int)
                                  janet_getinteger(argv, arg));
                    break;
                }
                case 'D':
                case 'I':
                case 'd':
                case 'i': {
                    int64_t n = janet_getinteger64(argv, arg);
                    nb = snprintf(item, MAX_ITEM, form, n);
                    break;
                }
                case 'x':
                case 'X':
                case 'o':
                case 'u': {
                    uint64_t n = janet_getuinteger64(argv, arg);
                    nb = snprintf(item, MAX_ITEM, form, n);
                    break;
                }
                case 'a':
                case 'A':
                case 'e':
                case 'E':
                case 'f':
                case 'g':
                case 'G': {
                    double d = janet_getnumber(argv, arg);
                    nb = snprintf(item, MAX_ITEM, form, d);
                    break;
                }
                case 's': {
                    JanetByteView bytes = janet_getbytes(argv, arg);
                    const uint8_t *s = bytes.bytes;
                    int32_t l = bytes.len;
                    if (form[2] == '\0')
                        janet_buffer_push_bytes(b, s, l);
                    else {
                        if (l != (int32_t) strnlen((const char *) s, l))
                            janet_panic("string contains zeros");
                        if (!strchr(form, '.') && l >= 100) {
                            janet_panic("no precision and string is too long to be formatted");
                        } else {
                            nb = snprintf(item, MAX_ITEM, form, s);
                        }
                    }
                    break;
                }
                case 'V': {
                    janet_to_string_b(b, argv[arg]);
                    break;
                }
                case 'v': {
                    janet_description_b(b, argv[arg]);
                    break;
                }
                case 't':
                    janet_buffer_push_cstring(b, typestr(argv[arg]));
                    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 = strfrmt[-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, argv[arg], startlen);
                    break;
                }
                case 'j': {
                    int depth = atoi(precision);
                    if (depth < 1)
                        depth = JANET_RECURSION_GUARD;
                    janet_jdn_(b, depth, argv[arg], 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
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12310
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x5c568
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
je 0x5bff0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %esi
callq 0x18820
jmp 0x5c563
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl 0x1(%rax), %eax
cmpl $0x25, %eax
jne 0x5c028
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %esi
callq 0x18820
jmp 0x5c561
movl $0x0, -0x16c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl -0x18(%rbp), %eax
jl 0x5c04c
leaq 0x39a6b(%rip), %rdi     # 0x95ab2
callq 0x1ad60
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x163(%rbp), %rdx
leaq -0x166(%rbp), %rcx
callq 0x5ba20
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x1c8(%rbp)
subl $0x37, %eax
ja 0x5c516
movq -0x1c8(%rbp), %rax
leaq 0x396d1(%rip), %rcx     # 0x95770
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x160(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x20(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x1c7c0
movq -0x1d8(%rbp), %rdi
movq -0x1d0(%rbp), %rdx
movl %eax, %ecx
movl $0x100, %esi            # imm = 0x100
movb $0x0, %al
callq 0x12390
movl %eax, -0x16c(%rbp)
jmp 0x5c528
movq -0x20(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x1c910
movq %rax, -0x178(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movq -0x178(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
movb $0x0, %al
callq 0x12390
movl %eax, -0x16c(%rbp)
jmp 0x5c528
movq -0x20(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x1c940
movq %rax, -0x180(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movq -0x180(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
movb $0x0, %al
callq 0x12390
movl %eax, -0x16c(%rbp)
jmp 0x5c528
movq -0x20(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x1b040
movsd %xmm0, -0x188(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movsd -0x188(%rbp), %xmm0
movl $0x100, %esi            # imm = 0x100
movb $0x1, %al
callq 0x12390
movl %eax, -0x16c(%rbp)
jmp 0x5c528
movq -0x20(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x1c4d0
movq %rax, -0x198(%rbp)
movl %edx, -0x190(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movl -0x190(%rbp), %eax
movl %eax, -0x1a4(%rbp)
movsbl -0x5e(%rbp), %eax
cmpl $0x0, %eax
jne 0x5c201
movq -0x8(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
movl -0x1a4(%rbp), %edx
callq 0x18790
jmp 0x5c288
movl -0x1a4(%rbp), %eax
movl %eax, -0x1dc(%rbp)
movq -0x1a0(%rbp), %rdi
movslq -0x1a4(%rbp), %rsi
callq 0x12430
movq %rax, %rcx
movl -0x1dc(%rbp), %eax
cmpl %ecx, %eax
je 0x5c239
leaq 0x397f9(%rip), %rdi     # 0x95a2d
callq 0x1ad60
leaq -0x60(%rbp), %rdi
movl $0x2e, %esi
callq 0x12370
cmpq $0x0, %rax
jne 0x5c262
cmpl $0x64, -0x1a4(%rbp)
jl 0x5c262
leaq 0x397e6(%rip), %rdi     # 0x95a43
callq 0x1ad60
leaq -0x160(%rbp), %rdi
leaq -0x60(%rbp), %rdx
movq -0x1a0(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
movb $0x0, %al
callq 0x12390
movl %eax, -0x16c(%rbp)
jmp 0x5c288
jmp 0x5c528
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x5a400
jmp 0x5c528
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x5a990
jmp 0x5c528
movq -0x8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5bcc0
movq -0x1e8(%rbp), %rdi
movq %rax, %rsi
callq 0x18750
jmp 0x5c528
leaq -0x166(%rbp), %rdi
callq 0x12a30
movl %eax, -0x1a8(%rbp)
cmpl $0x1, -0x1a8(%rbp)
jge 0x5c316
movl $0x400, -0x1a8(%rbp)    # imm = 0x400
movq -0x10(%rbp), %rax
movb -0x1(%rax), %al
movb %al, -0x1a9(%rbp)
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x50, %ecx
movb %al, -0x1e9(%rbp)
je 0x5c372
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x51, %ecx
movb %al, -0x1e9(%rbp)
je 0x5c372
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x4d, %ecx
movb %al, -0x1e9(%rbp)
je 0x5c372
movsbl -0x1a9(%rbp), %eax
cmpl $0x4e, %eax
sete %al
movb %al, -0x1e9(%rbp)
movb -0x1e9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1b0(%rbp)
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x51, %ecx
movb %al, -0x1ea(%rbp)
je 0x5c3d2
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x71, %ecx
movb %al, -0x1ea(%rbp)
je 0x5c3d2
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x4e, %ecx
movb %al, -0x1ea(%rbp)
je 0x5c3d2
movsbl -0x1a9(%rbp), %eax
cmpl $0x6e, %eax
sete %al
movb %al, -0x1ea(%rbp)
movb -0x1ea(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1b4(%rbp)
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x4d, %ecx
movb %al, -0x1eb(%rbp)
je 0x5c432
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x6d, %ecx
movb %al, -0x1eb(%rbp)
je 0x5c432
movsbl -0x1a9(%rbp), %ecx
movb $0x1, %al
cmpl $0x4e, %ecx
movb %al, -0x1eb(%rbp)
je 0x5c432
movsbl -0x1a9(%rbp), %eax
cmpl $0x6e, %eax
sete %al
movb %al, -0x1eb(%rbp)
movb -0x1eb(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1b8(%rbp)
movl $0x0, -0x1bc(%rbp)
movl -0x1b0(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl -0x1bc(%rbp), %eax
movl %eax, -0x1bc(%rbp)
movl -0x1b4(%rbp), %edx
xorl %eax, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl -0x1bc(%rbp), %eax
movl %eax, -0x1bc(%rbp)
movl -0x1b8(%rbp), %edx
xorl %eax, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl -0x1bc(%rbp), %eax
movl %eax, -0x1bc(%rbp)
movq -0x8(%rbp), %rdi
movl -0x1a8(%rbp), %esi
movl -0x1bc(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl -0x38(%rbp), %r8d
movq (%rax,%rcx,8), %rcx
callq 0x5ad40
jmp 0x5c528
leaq -0x166(%rbp), %rdi
callq 0x12a30
movl %eax, -0x1c0(%rbp)
cmpl $0x1, -0x1c0(%rbp)
jge 0x5c4f6
movl $0x400, -0x1c0(%rbp)    # imm = 0x400
movq -0x8(%rbp), %rdi
movl -0x1c0(%rbp), %esi
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rdx
movl -0x38(%rbp), %ecx
movq (%rax,%rdx,8), %rdx
callq 0x5ae50
jmp 0x5c528
leaq -0x60(%rbp), %rsi
leaq 0x39556(%rip), %rdi     # 0x95a77
movb $0x0, %al
callq 0x1ac40
cmpl $0x100, -0x16c(%rbp)    # imm = 0x100
jl 0x5c540
leaq 0x39560(%rip), %rdi     # 0x95a9b
callq 0x1ad60
cmpl $0x0, -0x16c(%rbp)
jle 0x5c55f
movq -0x8(%rbp), %rdi
leaq -0x160(%rbp), %rsi
movl -0x16c(%rbp), %edx
callq 0x18790
jmp 0x5c561
jmp 0x5c563
jmp 0x5bfb6
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
nopw %cs:(%rax,%rax)