// File: /workspace/github_c_makefile_star2_O2/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 0x2c684
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 0x1839c
movq %rax, %r15
movq %rax, %xmm0
shrq $0x2f, %rax
andl $0xf, %eax
xorl %r13d, %r13d
ucomisd %xmm0, %xmm0
cmovpl %eax, %r13d
cmpl $0xe, %r13d
je 0x2c6e1
cmpl $0xb, %r13d
je 0x2c758
cmpl $0xc, %r13d
je 0x2c771
cmpl $0x1, %r13d
jne 0x2c7c5
xorl %esi, %esi
cmpb $0x0, (%rbx,%rsi)
leaq 0x1(%rsi), %rsi
jne 0x2c6e3
decl %esi
leaq -0x60(%rbp), %r12
movq %r12, %rdi
callq 0x15e80
leaq -0x40(%rbp), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3b9d0
cmpl $0xe, %r13d
jne 0x2c737
movq %r15, %rdi
callq 0x4b1f1
movq %rax, %rbx
movq -0x10(%rax), %rax
cmpq 0x5386a(%rip), %rax     # 0x7ff90
jne 0x2c7c5
movq %rbx, %rdi
callq 0x2bc4c
movq (%rbx), %r14
leaq -0x60(%rbp), %rbx
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x12a80
movq %rbx, %rdi
callq 0x15f62
jmp 0x2c7c5
movq %r15, %rdi
callq 0x4b1f1
leaq -0x40(%rbp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3b9d0
jmp 0x2c7c5
movq %r15, %rdi
callq 0x4b1f1
movq %rax, %r14
xorl %edi, %edi
cmpb $0x0, (%rbx,%rdi)
leaq 0x1(%rdi), %rdi
jne 0x2c77e
decl %edi
callq 0x15f78
movq %rax, %r15
leaq -0x40(%rbp), %rdx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3b9d0
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r15, %rdi
callq 0x4b3ab
leaq -0x60(%rbp), %rdx
movq %rax, (%rdx)
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x47bff
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq