// File: /workspace/github_c_makefile_star2_O3/janet-lang[P]janet/src/core/io.c
// Function: cfun_io_printf_impl_x
static Janet cfun_io_printf_impl_x(int32_t argc, Janet *argv, int newline,
                                   FILE *dflt_file, int32_t offset, Janet x) {
    FILE *f;
    const char *fmt = janet_getcstring(argv, offset);
    switch (janet_type(x)) {
        default:
            janet_panicf("cannot print to %v", x);
        case JANET_BUFFER: {
            /* Special case buffer */
            JanetBuffer *buf = janet_unwrap_buffer(x);
            janet_buffer_format(buf, fmt, offset, argc, argv);
            if (newline) janet_buffer_push_u8(buf, '\n');
            return janet_wrap_nil();
        }
        case JANET_FUNCTION: {
            /* Special case function */
            JanetFunction *fun = janet_unwrap_function(x);
            JanetBuffer *buf = janet_buffer(0);
            janet_buffer_format(buf, fmt, offset, argc, argv);
            if (newline) janet_buffer_push_u8(buf, '\n');
            Janet args[1] = { janet_wrap_buffer(buf) };
            janet_call(fun, 1, args);
            return janet_wrap_nil();
        }
        case JANET_NIL:
            f = dflt_file;
            if (f == NULL) janet_panic("cannot print to nil");
            break;
        case JANET_ABSTRACT: {
            void *abstract = janet_unwrap_abstract(x);
            if (janet_abstract_type(abstract) != &janet_file_type)
                return janet_wrap_nil();
            JanetFile *iofile = abstract;
            if (iofile->flags & JANET_FILE_CLOSED) {
                janet_panic("cannot print to closed file");
            }
            io_assert_writeable(iofile);
            f = iofile->file;
            break;
        }
    }
    JanetBuffer *buf = janet_buffer(10);
    janet_buffer_format(buf, fmt, offset, argc, argv);
    if (newline) janet_buffer_push_u8(buf, '\n');
    if (buf->count) {
        if (1 != fwrite(buf->data, buf->count, 1, f)) {
            janet_panicf("could not print %d bytes to file", buf->count);
        }
    }
    /* Clear buffer to make things easier for GC */
    buf->count = 0;
    buf->capacity = 0;
    janet_free(buf->data);
    buf->data = NULL;
    return janet_wrap_nil();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r12
movl %r8d, %r15d
movq %rcx, %rbx
movl %edx, -0x30(%rbp)
movq %rsi, %r14
movl %edi, -0x2c(%rbp)
movq %rsi, %rdi
movl %r8d, %esi
callq 0x19817
movq %r12, %xmm0
movq %r12, %rdx
shrq $0x2f, %rdx
andl $0xf, %edx
xorl %ecx, %ecx
ucomisd %xmm0, %xmm0
movq %rax, %r13
cmovpl %edx, %ecx
cmpl $0xb, %ecx
jg 0x2eb03
cmpl $0x1, %ecx
je 0x2eb48
cmpl $0xb, %ecx
jne 0x2ec5e
movq %r12, %rdi
callq 0x4ebc4
movq %rax, %rbx
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3f7a8
cmpl $0x0, -0x30(%rbp)
je 0x2ebc1
movq %rbx, %rdi
movl $0xa, %esi
callq 0x17947
jmp 0x2ebc1
cmpl $0xc, %ecx
je 0x2ebde
cmpl $0xe, %ecx
jne 0x2ec5e
movq %r12, %rdi
callq 0x4ebc4
movq %rax, %rbx
movq -0x10(%rax), %rax
cmpq 0x56465(%rip), %rax     # 0x84f90
jne 0x2ebc1
movl 0x8(%rbx), %edi
testb $0x20, %dil
jne 0x2ec8e
callq 0x2e2e5
movq (%rbx), %rbx
jmp 0x2eb51
testq %rbx, %rbx
je 0x2ec6f
movl $0xa, %edi
callq 0x176f7
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3f7a8
cmpl $0x0, -0x30(%rbp)
je 0x2eb85
movq %r12, %rdi
movl $0xa, %esi
callq 0x17947
movslq 0x10(%r12), %rsi
testq %rsi, %rsi
je 0x2ebab
movq 0x18(%r12), %rdi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x12a80
cmpq $0x1, %rax
jne 0x2ec7b
xorl %ebx, %ebx
movq %rbx, 0x10(%r12)
movq 0x18(%r12), %rdi
callq 0x120b0
movq %rbx, 0x18(%r12)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4ece6
movq %r12, %rdi
callq 0x4ebc4
movq %rax, %rbx
xorl %edi, %edi
callq 0x176f7
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3f7a8
cmpl $0x0, -0x30(%rbp)
je 0x2ec1a
movq %r12, %rdi
movl $0xa, %esi
callq 0x17947
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r12, %rdi
callq 0x4ed7e
leaq -0x38(%rbp), %rdx
movq %rax, (%rdx)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x4b70a
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4ece6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2fa3e(%rip), %rdi     # 0x5e6a3
movq %r12, %rsi
xorl %eax, %eax
callq 0x190bb
leaq 0x2fa40(%rip), %rdi     # 0x5e6b6
callq 0x191a3
movl 0x10(%r12), %esi
leaq 0x2fa91(%rip), %rdi     # 0x5e718
xorl %eax, %eax
callq 0x190bb
leaq 0x2fa67(%rip), %rdi     # 0x5e6fc
callq 0x191a3