// File: /workspace/github_c_makefile_star2_O3/janet-lang[P]janet/src/core/io.c
// Function: janet_dynprintf
void janet_dynprintf(const char *name, FILE *dflt_file, const char *format, ...) {
    va_list args;
    va_start(args, format);
    Janet x = janet_dyn(name);
    JanetType xtype = janet_type(x);
    switch (xtype) {
        default:
            /* Other values simply do nothing */
            break;
        case JANET_NIL:
        case JANET_ABSTRACT: {
            FILE *f = dflt_file;
            JanetBuffer buffer;
            int32_t len = 0;
            while (format[len]) len++;
            janet_buffer_init(&buffer, len);
            janet_formatbv(&buffer, format, args);
            if (xtype == JANET_ABSTRACT) {
                void *abstract = janet_unwrap_abstract(x);
                if (janet_abstract_type(abstract) != &janet_file_type)
                    break;
                JanetFile *iofile = abstract;
                io_assert_writeable(iofile);
                f = iofile->file;
            }
            fwrite(buffer.data, buffer.count, 1, f);
            janet_buffer_deinit(&buffer);
            break;
        }
        case JANET_FUNCTION: {
            JanetFunction *fun = janet_unwrap_function(x);
            int32_t len = 0;
            while (format[len]) len++;
            JanetBuffer *buf = janet_buffer(len);
            janet_formatbv(buf, format, args);
            Janet args[1] = { janet_wrap_buffer(buf) };
            janet_call(fun, 1, args);
            break;
        }
        case JANET_BUFFER:
            janet_formatbv(janet_unwrap_buffer(x), format, args);
            break;
    }
    va_end(args);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, %rbx
movq %rsi, %r14
leaq -0x110(%rbp), %rdx
movq %rcx, 0x18(%rdx)
movq %r8, 0x20(%rdx)
movq %r9, 0x28(%rdx)
testb %al, %al
je 0x2edf4
movaps %xmm0, -0xe0(%rbp)
movaps %xmm1, -0xd0(%rbp)
movaps %xmm2, -0xc0(%rbp)
movaps %xmm3, -0xb0(%rbp)
movaps %xmm4, -0xa0(%rbp)
movaps %xmm5, -0x90(%rbp)
movaps %xmm6, -0x80(%rbp)
movaps %xmm7, -0x70(%rbp)
movq %rdx, -0x30(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, -0x40(%rbp)
callq 0x19e4d
movq %rax, %r15
movq %rax, %xmm0
shrq $0x2f, %rax
andl $0xf, %eax
xorl %r13d, %r13d
ucomisd %xmm0, %xmm0
cmovpl %eax, %r13d
cmpl $0xb, %r13d
jg 0x2ee5f
cmpl $0x1, %r13d
je 0x2ee73
cmpl $0xb, %r13d
jne 0x2ef42
movq %r15, %rdi
callq 0x4ebc4
leaq -0x40(%rbp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3ef42
jmp 0x2ef42
cmpl $0xc, %r13d
je 0x2eeec
cmpl $0xe, %r13d
jne 0x2ef42
xorl %esi, %esi
cmpb $0x0, (%rbx,%rsi)
leaq 0x1(%rsi), %rsi
jne 0x2ee75
decl %esi
leaq -0x60(%rbp), %r12
movq %r12, %rdi
callq 0x17618
leaq -0x40(%rbp), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3ef42
cmpl $0xe, %r13d
jne 0x2eec9
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %rbx
movq -0x10(%rax), %rax
cmpq 0x560d8(%rip), %rax     # 0x84f90
jne 0x2ef42
movl 0x8(%rbx), %edi
callq 0x2e2e5
movq (%rbx), %r14
leaq -0x60(%rbp), %rbx
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rsi
movl $0x1, %edx
movq %r14, %rcx
callq 0x12a80
movq %rbx, %rdi
callq 0x176e1
jmp 0x2ef42
movq %r15, %rdi
callq 0x4ebc4
movq %rax, %r14
xorl %edi, %edi
cmpb $0x0, (%rbx,%rdi)
leaq 0x1(%rdi), %rdi
jne 0x2eef9
decl %edi
callq 0x176f7
movq %rax, %r15
leaq -0x40(%rbp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3ef42
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r15, %rdi
callq 0x4ed7e
leaq -0x60(%rbp), %rdx
movq %rax, (%rdx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x4b70a
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq