// File: /workspace/github_c_makefile_star2_O2/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 0x17dae
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 $0x1, %ecx
je 0x2c432
cmpl $0xb, %ecx
je 0x2c4a7
cmpl $0xc, %ecx
je 0x2c3b6
cmpl $0xe, %ecx
jne 0x2c4f4
movq %r12, %rdi
callq 0x4b1f1
movq %rax, %rbx
movq -0x10(%rax), %rax
cmpq 0x53bfa(%rip), %rax     # 0x7ff90
jne 0x2c4d7
testb $0x20, 0x8(%rbx)
jne 0x2c524
movq %rbx, %rdi
callq 0x2bc4c
movq (%rbx), %rbx
jmp 0x2c43b
movq %r12, %rdi
callq 0x4b1f1
movq %rax, %rbx
xorl %edi, %edi
callq 0x15f78
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3c243
cmpl $0x0, -0x30(%rbp)
je 0x2c3f0
pushq $0xa
popq %rsi
movq %r12, %rdi
callq 0x161be
movabsq $-0x2800000000000, %rsi # imm = 0xFFFD800000000000
movq %r12, %rdi
callq 0x4b3ab
leaq -0x38(%rbp), %rdx
movq %rax, (%rdx)
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x47bff
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4b313
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
je 0x2c505
pushq $0xa
popq %rdi
callq 0x15f78
movq %rax, %r12
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3c243
cmpl $0x0, -0x30(%rbp)
je 0x2c46b
pushq $0xa
popq %rsi
movq %r12, %rdi
callq 0x161be
movslq 0x10(%r12), %rsi
testq %rsi, %rsi
je 0x2c48f
movq 0x18(%r12), %rdi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x12a80
cmpq $0x1, %rax
jne 0x2c511
andq $0x0, 0x10(%r12)
movq 0x18(%r12), %rdi
callq 0x120b0
andq $0x0, 0x18(%r12)
jmp 0x2c4d7
movq %r12, %rdi
callq 0x4b1f1
movq %rax, %rbx
movq %rax, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
movq %r14, %r8
callq 0x3c243
cmpl $0x0, -0x30(%rbp)
je 0x2c4d7
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0x161be
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4b313
leaq 0x2e1a8(%rip), %rdi     # 0x5a6a3
movq %r12, %rsi
xorl %eax, %eax
callq 0x176c9
leaq 0x2e1aa(%rip), %rdi     # 0x5a6b6
callq 0x177b1
movl 0x10(%r12), %esi
leaq 0x2e1fb(%rip), %rdi     # 0x5a718
xorl %eax, %eax
callq 0x176c9
leaq 0x2e1d1(%rip), %rdi     # 0x5a6fc
callq 0x177b1