// File: /workspace/github_c_makefile_star2_O1/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 0x2f3a3
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 0x19f23
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 0x2f40e
cmpl $0x1, %r13d
je 0x2f422
cmpl $0xb, %r13d
jne 0x2f4f6
movq %r15, %rdi
callq 0x4f838
leaq -0x40(%rbp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3f635
jmp 0x2f4f6
cmpl $0xc, %r13d
je 0x2f4a0
cmpl $0xe, %r13d
jne 0x2f4f6
xorl %esi, %esi
cmpb $0x0, (%rbx,%rsi)
leaq 0x1(%rsi), %rsi
jne 0x2f424
decl %esi
leaq -0x60(%rbp), %r12
movq %r12, %rdi
callq 0x17678
leaq -0x40(%rbp), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3f635
cmpl $0xe, %r13d
jne 0x2f47d
movq %r15, %rdi
callq 0x4f838
movq -0x10(%rax), %r15
cmpq 0x56b2c(%rip), %r15     # 0x85f90
jne 0x2f474
movq %rax, %rbx
movq %rax, %rdi
callq 0x2e868
movq (%rbx), %r14
cmpq 0x56b15(%rip), %r15     # 0x85f90
jne 0x2f4f6
leaq -0x60(%rbp), %rbx
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rsi
movl $0x1, %edx
movq %r14, %rcx
callq 0x12a90
movq %rbx, %rdi
callq 0x17741
jmp 0x2f4f6
movq %r15, %rdi
callq 0x4f838
movq %rax, %r14
xorl %edi, %edi
cmpb $0x0, (%rbx,%rdi)
leaq 0x1(%rdi), %rdi
jne 0x2f4ad
decl %edi
callq 0x17757
movq %rax, %r15
leaq -0x40(%rbp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3f635
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r15, %rdi
callq 0x4f9f2
leaq -0x60(%rbp), %rdx
movq %rax, (%rdx)
movq %r14, %rdi
movl $0x1, %esi
callq 0x4c2d6
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq