// File: /workspace/github_c_makefile_star2_O3/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 %rdx, %r13
movq %rsi, -0x38(%rbp)
movq %rdi, %r14
xorl %r12d, %r12d
movb %r12b, 0x2(%rdx)
movw %r12w, (%rdx)
movb %r12b, 0x2(%rcx)
movq %rcx, -0x30(%rbp)
movw %r12w, (%rcx)
movb (%rdi), %bl
movq %rdi, %r15
testb %bl, %bl
je 0x3f4f6
leaq 0x29206(%rip), %r12     # 0x686d1
movq %r14, %r15
movsbl %bl, %esi
movl $0x6, %edx
movq %r12, %rdi
callq 0x12500
testq %rax, %rax
je 0x3f4f3
movb 0x1(%r15), %bl
incq %r15
testb %bl, %bl
jne 0x3f4ce
xorl %r12d, %r12d
jmp 0x3f4f6
movl %ebx, %r12d
movq %r15, %rax
subq %r14, %rax
cmpq $0x6, %rax
jae 0x3f63a
callq 0x12c20
movq (%rax), %rcx
movsbq %r12b, %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x3f541
movb %r12b, (%r13)
movq (%rax), %rcx
movsbq 0x1(%r15), %r12
testb $0x8, 0x1(%rcx,%r12,2)
jne 0x3f532
incq %r15
jmp 0x3f541
movb %r12b, 0x1(%r13)
movb 0x2(%r15), %r12b
addq $0x2, %r15
movq (%rax), %rcx
movq -0x30(%rbp), %rdx
cmpb $0x2e, %r12b
movq -0x38(%rbp), %r13
jne 0x3f589
movsbq 0x1(%r15), %r12
testb $0x8, 0x1(%rcx,%r12,2)
jne 0x3f561
incq %r15
jmp 0x3f589
movb %r12b, (%rdx)
movq (%rax), %rcx
movsbq 0x2(%r15), %r12
testb $0x8, 0x1(%rcx,%r12,2)
jne 0x3f57a
addq $0x2, %r15
jmp 0x3f589
movb %r12b, 0x1(%rdx)
movq (%rax), %rcx
movb 0x3(%r15), %r12b
addq $0x3, %r15
movsbq %r12b, %rax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x3f646
movb $0x25, (%r13)
incq %r13
cmpq %r14, %r15
jb 0x3f61e
leaq 0x44584(%rip), %rbx     # 0x83b30
movb (%r14), %r12b
movsbl %r12b, %esi
movl $0x7, %edx
leaq 0x29165(%rip), %rdi     # 0x68724
callq 0x12500
testq %rax, %rax
je 0x3f5e8
cmpb $0x0, (%rax)
je 0x3f5e8
movq %r13, -0x38(%rbp)
xorl %eax, %eax
cmpb %r12b, (%rax,%rbx)
je 0x3f5f1
addq $0x10, %rax
cmpq $0x80, %rax
jne 0x3f5d4
jmp 0x3f635
movb %r12b, (%r13)
incq %r13
jmp 0x3f616
movq 0x8(%rax,%rbx), %r13
movq %r13, %rdi
callq 0x12310
movq %rax, %r12
movq -0x38(%rbp), %rdi
movq %r13, %rsi
movq %rdi, %r13
movq %rax, %rdx
callq 0x12670
addq %r12, %r13
incq %r14
cmpq %r15, %r14
jbe 0x3f5ac
movb $0x0, (%r13)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x13e3c
leaq 0x29096(%rip), %rdi     # 0x686d7
callq 0x191a3
leaq 0x290aa(%rip), %rdi     # 0x686f7
callq 0x191a3