// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/pp.c
// Function: scanformat
static const char *scanformat(
    const char *strfrmt,
    char *form,
    char width[3],
    char precision[3]) {
    const char *p = strfrmt;

    /* Parse strfrmt */
    memset(width, '\0', 3);
    memset(precision, '\0', 3);
    while (*p != '\0' && strchr(FMT_FLAGS, *p) != NULL)
        p++; /* skip flags */
    if ((size_t)(p - strfrmt) >= sizeof(FMT_FLAGS)) janet_panic("invalid format (repeated flags)");
    if (isdigit((int)(*p)))
        width[0] = *p++; /* skip width */
    if (isdigit((int)(*p)))
        width[1] = *p++; /* (2 digits at most) */
    if (*p == '.') {
        p++;
        if (isdigit((int)(*p)))
            precision[0] = *p++; /* skip precision */
        if (isdigit((int)(*p)))
            precision[1] = *p++; /* (2 digits at most) */
    }
    if (isdigit((int)(*p)))
        janet_panic("invalid format (width or precision too long)");

    /* Write to form - replace characters with fixed size stuff */
    *(form++) = '%';
    const char *p2 = strfrmt;
    while (p2 <= p) {
        char *loc = strchr(FMT_REPLACE_INTTYPES, *p2);
        if (loc != NULL && *loc != '\0') {
            const char *mapping = get_fmt_mapping(*p2++);
            size_t len = strlen(mapping);
            memcpy(form, mapping, len);
            form += len;
        } else {
            *(form++) = *(p2++);
        }
    }
    *form = '\0';

    return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rsi, -0x40(%rbp)
movq %rdi, %r14
xorl %r15d, %r15d
andw $0x0, (%rdx)
movq %rdx, -0x38(%rbp)
movb %r15b, 0x2(%rdx)
andw $0x0, (%rcx)
movb %r15b, 0x2(%rcx)
leaq 0x1(%rdi), %rax
pushq $0x6
popq %r12
movq %rax, -0x30(%rbp)
movsbl -0x1(%rax), %r13d
testl %r13d, %r13d
je 0x3bf21
leaq 0x287ec(%rip), %rdi     # 0x646f1
movl %r13d, %esi
movq %r12, %rdx
callq 0x12500
testq %rax, %rax
je 0x3bf21
movq -0x30(%rbp), %rax
incq %rax
incq %r15
jmp 0x3bef0
cmpq $0x6, %r15
jae 0x3c09a
movslq %r13d, %r15
callq 0x12c20
movq (%rax), %rcx
testb $0x8, 0x1(%rcx,%r15,2)
jne 0x3bf44
decq -0x30(%rbp)
jmp 0x3bf55
movq -0x38(%rbp), %rcx
movb %r13b, (%rcx)
movq (%rax), %rcx
movq -0x30(%rbp), %rdx
movb (%rdx), %r13b
movsbq %r13b, %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x3bf7a
movq -0x38(%rbp), %rcx
movb %r13b, 0x1(%rcx)
movq -0x30(%rbp), %rcx
movb 0x1(%rcx), %r13b
incq %rcx
movq %rcx, -0x30(%rbp)
movq (%rax), %rcx
cmpb $0x2e, %r13b
jne 0x3bfc2
movq -0x30(%rbp), %rdx
movsbq 0x1(%rdx), %r13
testb $0x8, 0x1(%rcx,%r13,2)
jne 0x3bf96
incq %rdx
jmp 0x3bfbe
movb %r13b, (%rbx)
movq (%rax), %rcx
movsbq 0x2(%rdx), %r13
testb $0x8, 0x1(%rcx,%r13,2)
jne 0x3bfaf
addq $0x2, %rdx
jmp 0x3bfbe
movb %r13b, 0x1(%rbx)
movq (%rax), %rcx
movb 0x3(%rdx), %r13b
addq $0x3, %rdx
movq %rdx, -0x30(%rbp)
movsbq %r13b, %rax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x3c0a6
movq -0x40(%rbp), %rbx
movb $0x25, (%rbx)
incq %rbx
leaq 0x42b4e(%rip), %r15     # 0x7eb30
movq -0x30(%rbp), %r13
cmpq %r13, %r14
ja 0x3c055
movb (%r14), %r12b
movsbl %r12b, %esi
leaq 0x2874b(%rip), %rdi     # 0x64744
pushq $0x7
popq %rdx
callq 0x12500
testq %rax, %rax
je 0x3c04a
cmpb $0x0, (%rax)
je 0x3c04a
xorl %eax, %eax
leaq 0x10(%rax), %rcx
cmpq $0x90, %rcx
je 0x3c06a
cmpb %r12b, (%rax,%r15)
movq %rcx, %rax
jne 0x3c00d
movq -0x8(%rcx,%r15), %r12
movq %r12, %rdi
callq 0x12310
movq %rax, %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x12670
addq %r13, %rbx
movq -0x30(%rbp), %r13
jmp 0x3c050
movb %r12b, (%rbx)
incq %rbx
incq %r14
jmp 0x3bfe6
movb $0x0, (%rbx)
movq %r13, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x43f7f(%rip), %rax     # 0x7fff0
movq (%rax), %rdi
leaq 0x13f95(%rip), %rsi     # 0x50010
leaq 0x2862e(%rip), %rcx     # 0x646b0
leaq 0x286c2(%rip), %r8      # 0x6474b
movl $0x31d, %edx            # imm = 0x31D
xorl %eax, %eax
callq 0x125e0
callq 0x12100
leaq 0x28656(%rip), %rdi     # 0x646f7
callq 0x177b1
leaq 0x2866a(%rip), %rdi     # 0x64717
callq 0x177b1