// File: /workspace/github_c_makefile_star2_O1/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 %rsi, %rbx
movq %rdi, %r14
xorl %eax, %eax
movb %al, 0x2(%rdx)
movq %rdx, -0x38(%rbp)
movw %ax, (%rdx)
movb %al, 0x2(%rcx)
movq %rcx, -0x30(%rbp)
movw %ax, (%rcx)
movb (%rdi), %r13b
testb %r13b, %r13b
je 0x3fc0c
leaq 0x29b0c(%rip), %r12     # 0x696f1
movq %r14, %r15
movsbl %r13b, %esi
movl $0x6, %edx
movq %r12, %rdi
callq 0x12500
testq %rax, %rax
je 0x3fc0f
movb 0x1(%r15), %r13b
incq %r15
testb %r13b, %r13b
jne 0x3fbe8
jmp 0x3fc0f
movq %r14, %r15
movq %r15, %rax
subq %r14, %rax
cmpq $0x6, %rax
jae 0x3fd6e
callq 0x12c30
movq (%rax), %rcx
movsbq %r13b, %rdx
testb $0x8, 0x1(%rcx,%rdx,2)
je 0x3fc3c
incq %r15
movq -0x38(%rbp), %rcx
movb %r13b, (%rcx)
movq (%rax), %rdx
movsbq (%r15), %rcx
testb $0x8, 0x1(%rdx,%rcx,2)
je 0x3fc54
incq %r15
movq -0x38(%rbp), %rdx
movb %cl, 0x1(%rdx)
cmpb $0x2e, (%r15)
jne 0x3fc90
movq (%rax), %rdx
movsbq 0x1(%r15), %rcx
testb $0x8, 0x1(%rdx,%rcx,2)
jne 0x3fc6e
incq %r15
jmp 0x3fc78
addq $0x2, %r15
movq -0x30(%rbp), %rdx
movb %cl, (%rdx)
movq (%rax), %rdx
movsbq (%r15), %rcx
testb $0x8, 0x1(%rdx,%rcx,2)
je 0x3fc90
incq %r15
movq -0x30(%rbp), %rdx
movb %cl, 0x1(%rdx)
movq (%rax), %rax
movsbq (%r15), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x3fd7a
movb $0x25, (%rbx)
incq %rbx
cmpq %r14, %r15
jb 0x3fd54
leaq 0x29a8c(%rip), %r13     # 0x69744
movb (%r14), %r12b
movsbl %r12b, %esi
movl $0x7, %edx
movq %r13, %rdi
callq 0x12500
testq %rax, %rax
je 0x3fce7
cmpb $0x0, (%rax)
je 0x3fce7
cmpb $0x44, %r12b
jne 0x3fcef
xorl %eax, %eax
leaq 0x44e4b(%rip), %rcx     # 0x84b30
jmp 0x3fd18
movb %r12b, (%rbx)
incq %rbx
jmp 0x3fd48
leaq 0x44e3a(%rip), %rdx     # 0x84b30
xorl %eax, %eax
cmpq $0x7, %rax
je 0x3fd1e
leaq 0x10(%rdx), %rcx
incq %rax
cmpb %r12b, 0x10(%rdx)
movq %rcx, %rdx
jne 0x3fcf8
decq %rax
cmpq $0x7, %rax
setae %al
movq 0x8(%rcx), %r13
jmp 0x3fd21
setae %al
testb %al, %al
jne 0x3fd69
movq %r13, %rdi
callq 0x12310
movq %rax, %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x12680
addq %r12, %rbx
leaq 0x299fc(%rip), %r13     # 0x69744
incq %r14
cmpq %r15, %r14
jbe 0x3fcb8
movb $0x0, (%rbx)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x13e4c
leaq 0x29982(%rip), %rdi     # 0x696f7
callq 0x19263
leaq 0x29996(%rip), %rdi     # 0x69717
callq 0x19263