// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_fprintf
static int jx9Builtin_fprintf(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	fprintf_data sFdata;
	const char *zFormat;
	io_private *pDev;
	int nLen;
	if( nArg < 2 || !jx9_value_is_resource(apArg[0]) || !jx9_value_is_string(apArg[1]) ){
		/* Missing/Invalid arguments, return zero */
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "Invalid arguments");
		jx9_result_int(pCtx, 0);
		return JX9_OK;
	}
	/* Extract our private data */
	pDev = (io_private *)jx9_value_to_resource(apArg[0]);
	/* Make sure we are dealing with a valid io_private instance */
	if( IO_PRIVATE_INVALID(pDev) ){
		/*Expecting an IO handle */
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "Expecting an IO handle");
		jx9_result_int(pCtx, 0);
		return JX9_OK;
	}
	/* Point to the target IO stream device */
	if( pDev->pStream == 0  || pDev->pStream->xWrite == 0 ){
		jx9_context_throw_error_format(pCtx, JX9_CTX_WARNING, 
			"IO routine(%s) not implemented in the underlying stream(%s) device", 
			jx9_function_name(pCtx), pDev->pStream ? pDev->pStream->zName : "null_stream"
			);
		jx9_result_int(pCtx, 0);
		return JX9_OK;
	}
	/* Extract the string format */
	zFormat = jx9_value_to_string(apArg[1], &nLen);
	if( nLen < 1 ){
		/* Empty string, return zero */
		jx9_result_int(pCtx, 0);
		return JX9_OK;
	}
	/* Prepare our private data */
	sFdata.nCount = 0;
	sFdata.pIO = pDev;
	/* Format the string */
	jx9InputFormat(fprintfConsumer, pCtx, zFormat, nLen, nArg - 1, &apArg[1], (void *)&sFdata, FALSE);
	/* Return total number of bytes written */
	jx9_result_int64(pCtx, sFdata.nCount);
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
cmpl $0x2, %esi
jl 0x63c83
movq %rdx, %r14
movq (%rdx), %rax
testb $0x1, 0x9(%rax)
je 0x63c83
movq 0x8(%r14), %rdi
testb $0x1, 0x8(%rdi)
jne 0x63cd1
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x13c85(%rip), %rcx     # 0x7791a
movl $0x2, %edx
callq 0x40afa
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq $0x0, (%rbx)
movl $0xfffffe90, %eax       # imm = 0xFFFFFE90
andl 0x8(%rbx), %eax
orl $0x2, %eax
movl %eax, 0x8(%rbx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rax), %r13
testq %r13, %r13
je 0x63d6b
cmpl $0xfeac14, 0x34(%r13)   # imm = 0xFEAC14
jne 0x63d6b
movq (%r13), %rax
testq %rax, %rax
je 0x63d82
cmpq $0x0, 0x40(%rax)
je 0x63d8b
movl %esi, %r15d
leaq -0x2c(%rbp), %r12
movq %r12, %rsi
callq 0x30577
movl (%r12), %ecx
testl %ecx, %ecx
jle 0x63c9f
addq $0x8, %r14
leaq -0x40(%rbp), %r12
movq $0x0, 0x8(%r12)
movq %r13, (%r12)
decl %r15d
leaq 0x105c(%rip), %rdi      # 0x64d95
movq %rbx, %rsi
movq %rax, %rdx
movl %r15d, %r8d
movq %r14, %r9
pushq $0x0
pushq %r12
callq 0x5a243
addq $0x10, %rsp
movq 0x8(%r12), %r14
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x30465
movq %r14, (%rbx)
jmp 0x63cb2
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x1394f(%rip), %rcx     # 0x776cc
jmp 0x63c95
leaq 0x139b5(%rip), %r8      # 0x7773e
jmp 0x63d8e
movq (%rax), %r8
movq (%rbx), %rax
movq 0x8(%rax), %rcx
leaq 0x139ae(%rip), %rdx     # 0x7774a
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x44ed3
jmp 0x63c9f