// File: /workspace/github_c_makefile_star2_O1/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 0x198dd
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 0x2f09d
cmpl $0x1, %ecx
je 0x2f0d8
cmpl $0xb, %ecx
jne 0x2f219
movq %r12, %rdi
callq 0x4f838
movq %rax, %rbx
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3fedc
cmpl $0x0, -0x30(%rbp)
je 0x2f1fc
movq %rbx, %rdi
movl $0xa, %esi
callq 0x179a7
jmp 0x2f1fc
cmpl $0xc, %ecx
je 0x2f0ed
cmpl $0xe, %ecx
jne 0x2f219
movq %r12, %rdi
callq 0x4f838
movq -0x10(%rax), %r12
cmpq 0x56ed2(%rip), %r12     # 0x85f90
je 0x2f160
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4f95a
jmp 0x2f178
testq %rbx, %rbx
jne 0x2f190
leaq 0x305ce(%rip), %rdi     # 0x5f6b6
callq 0x19263
movq %r12, %rdi
callq 0x4f838
movq %rax, %rbx
xorl %edi, %edi
callq 0x17757
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3fedc
cmpl $0x0, -0x30(%rbp)
je 0x2f129
movq %r12, %rdi
movl $0xa, %esi
callq 0x179a7
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r12, %rdi
callq 0x4f9f2
leaq -0x38(%rbp), %rdx
movq %rax, (%rdx)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x4c2d6
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4f95a
jmp 0x2f181
movq %rax, %rbx
testb $0x20, 0x8(%rax)
jne 0x2f23d
movq %rbx, %rdi
callq 0x2e868
movq (%rbx), %rbx
cmpq 0x56e11(%rip), %r12     # 0x85f90
je 0x2f190
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xa, %edi
callq 0x17757
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3fedc
cmpl $0x0, -0x30(%rbp)
je 0x2f1c4
movq %r12, %rdi
movl $0xa, %esi
callq 0x179a7
movslq 0x10(%r12), %rsi
testq %rsi, %rsi
je 0x2f1e6
movq 0x18(%r12), %rdi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x12a90
cmpq $0x1, %rax
jne 0x2f22a
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 0x4f95a
leaq 0x30483(%rip), %rdi     # 0x5f6a3
movq %r12, %rsi
xorl %eax, %eax
callq 0x1917b
movl 0x10(%r12), %esi
leaq 0x304e2(%rip), %rdi     # 0x5f718
xorl %eax, %eax
callq 0x1917b
leaq 0x304b8(%rip), %rdi     # 0x5f6fc
callq 0x19263