// File: /workspace/github_c_makefile_star2_O1/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 0x65739
movq %rdx, %r14
movq (%rdx), %rax
testb $0x1, 0x9(%rax)
je 0x65739
movq 0x8(%r14), %rdi
testb $0x1, 0x8(%rdi)
jne 0x65786
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x141c4(%rip), %rcx     # 0x7990f
movl $0x2, %edx
callq 0x4153c
xorl %r14d, %r14d
movq 0x8(%rbx), %rbx
movq %rbx, %rdi
callq 0x309f2
movq %r14, (%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 0x65801
cmpl $0xfeac14, 0x34(%r13)   # imm = 0xFEAC14
jne 0x65801
movq (%r13), %rax
testq %rax, %rax
je 0x65818
cmpq $0x0, 0x40(%rax)
je 0x65818
movl %esi, %r15d
leaq -0x2c(%rbp), %r12
movq %r12, %rsi
callq 0x30b04
movl (%r12), %ecx
testl %ecx, %ecx
jle 0x65755
addq $0x8, %r14
leaq -0x40(%rbp), %r12
movq $0x0, 0x8(%r12)
movq %r13, (%r12)
decl %r15d
leaq 0x1181(%rip), %rdi      # 0x6695f
movq %rbx, %rsi
movq %rax, %rdx
movl %r15d, %r8d
movq %r14, %r9
pushq $0x0
pushq %r12
callq 0x5bbf2
addq $0x10, %rsp
movq 0x8(%r12), %r14
jmp 0x65758
movq (%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
leaq 0x13eae(%rip), %rcx     # 0x796c1
jmp 0x6574b
movq (%rbx), %rcx
movq 0x8(%rcx), %rcx
testq %rax, %rax
je 0x65829
movq (%rax), %r8
jmp 0x65830
leaq 0x13f03(%rip), %r8      # 0x79733
leaq 0x13f08(%rip), %rdx     # 0x7973f
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x45d26
jmp 0x65758