// File: /workspace/github_c_makefile_star2_O0/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9Builtin_idate
static int jx9Builtin_idate(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
	const char *zFormat;
	jx9_int64 iVal = 0;
	int nLen;
	Sytm sTm;
	if( nArg < 1 || !jx9_value_is_string(apArg[0]) ){
		/* Missing/Invalid argument, return -1 */
		jx9_result_int(pCtx, -1);
		return JX9_OK;
	}
	zFormat = jx9_value_to_string(apArg[0], &nLen);
	if( nLen < 1 ){
		/* Don't bother processing return -1*/
		jx9_result_int(pCtx, -1);
	}
	if( nArg < 2 ){
#ifdef __WINNT__
		SYSTEMTIME sOS;
		GetSystemTime(&sOS);
		SYSTEMTIME_TO_SYTM(&sOS, &sTm);
#else
		struct tm *pTm;
		time_t t;
		time(&t);
		pTm = localtime(&t);
		STRUCT_TM_TO_SYTM(pTm, &sTm);
#endif
	}else{
		/* Use the given timestamp */
		time_t t;
		struct tm *pTm;
		if( jx9_value_is_int(apArg[1]) ){
			t = (time_t)jx9_value_to_int64(apArg[1]);
			pTm = localtime(&t);
			if( pTm == 0 ){
				time(&t);
			}
		}else{
			time(&t);
		}
		pTm = localtime(&t);
		STRUCT_TM_TO_SYTM(pTm, &sTm);
	}
	/* Perform the requested operation */
	switch(zFormat[0]){
	case 'd':
		/* Day of the month */
		iVal = sTm.tm_mday;
		break;
	case 'h':
		/*	Hour (12 hour format)*/
		iVal = 1 + (sTm.tm_hour % 12);
		break;
	case 'H':
		/* Hour (24 hour format)*/
		iVal = sTm.tm_hour;
		break;
	case 'i':
		/*Minutes*/
		iVal = sTm.tm_min;
		break;
	case 'I':
		/*	returns 1 if DST is activated, 0 otherwise */
#ifdef __WINNT__
#ifdef _MSC_VER
#ifndef _WIN32_WCE
			_get_daylight(&sTm.tm_isdst);
#endif
#endif
#endif
		iVal = sTm.tm_isdst;
		break;
	case 'L':
		/* 	returns 1 for leap year, 0 otherwise */
		iVal = IS_LEAP_YEAR(sTm.tm_year);
		break;
	case 'm':
		/* Month number*/
		iVal = sTm.tm_mon;
		break;
	case 's':
		/*Seconds*/
		iVal = sTm.tm_sec;
		break;
	case 't':{
		/*Days in current month*/
		static const int aMonDays[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
		int nDays = aMonDays[sTm.tm_mon % 12 ];
		if( sTm.tm_mon == 1 /* 'February' */ && !IS_LEAP_YEAR(sTm.tm_year) ){
			nDays = 28;
		}
		iVal = nDays;
		break;
			 }
	case 'U':
		/*Seconds since the Unix Epoch*/
		iVal = (jx9_int64)time(0);
		break;
	case 'w':
		/*	Day of the week (0 on Sunday) */
		iVal = sTm.tm_wday;
		break;
	case 'W': {
		/* ISO-8601 week number of year, weeks starting on Monday */
		static const int aISO8601[] = { 7 /* Sunday */, 1 /* Monday */, 2, 3, 4, 5, 6 };
		iVal = aISO8601[sTm.tm_wday % 7 ];
		break;
			  }
	case 'y':
		/* Year (2 digits) */
		iVal = sTm.tm_year % 100;
		break;
	case 'Y':
		/* Year (4 digits) */
		iVal = sTm.tm_year;
		break;
	case 'z':
		/* Day of the year */
		iVal = sTm.tm_yday;
		break;
	case 'Z':
		/*Timezone offset in seconds*/
		iVal = sTm.tm_gmtoff;
		break;
	default:
		/* unknown format, throw a warning */
		jx9_context_throw_error(pCtx, JX9_CTX_WARNING, "Unknown date format token");
		break;
	}
	/* Return the time value */
	jx9_result_int64(pCtx, iVal);
	return JX9_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
cmpl $0x1, -0x14(%rbp)
jl 0x97f45
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x57480
cmpl $0x0, %eax
jne 0x97f5f
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x56fb0
movl $0x0, -0x4(%rbp)
jmp 0x98342
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x34(%rbp), %rsi
callq 0x56e20
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x34(%rbp)
jge 0x97f87
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x56fb0
cmpl $0x2, -0x14(%rbp)
jge 0x9801a
leaq -0x80(%rbp), %rdi
callq 0xd980
leaq -0x80(%rbp), %rdi
callq 0xd8b0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x78(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x6c(%rbp)
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x78(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x78(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x78(%rbp), %rax
movl 0x14(%rax), %eax
addl $0x76c, %eax            # imm = 0x76C
movl %eax, -0x5c(%rbp)
movq -0x78(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x78(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x78(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
jmp 0x98113
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x57390
cmpl $0x0, %eax
je 0x9806b
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x56d50
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xd8b0
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x98069
leaq -0x88(%rbp), %rdi
callq 0xd980
jmp 0x98077
leaq -0x88(%rbp), %rdi
callq 0xd980
leaq -0x88(%rbp), %rdi
callq 0xd8b0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x90(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x6c(%rbp)
movq -0x90(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x70(%rbp)
movq -0x90(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x90(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x90(%rbp), %rax
movl 0x14(%rax), %eax
addl $0x76c, %eax            # imm = 0x76C
movl %eax, -0x5c(%rbp)
movq -0x90(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x90(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x90(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
addl $-0x48, %eax
movl %eax, %ecx
movq %rcx, -0xa0(%rbp)
subl $0x32, %eax
ja 0x98319
movq -0xa0(%rbp), %rax
leaq 0x28bb7(%rip), %rcx     # 0xc0cf4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq -0x64(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movl -0x68(%rbp), %eax
movl $0xc, %ecx
cltd
idivl %ecx
addl $0x1, %edx
movslq %edx, %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movslq -0x68(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movslq -0x6c(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movslq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movl -0x5c(%rbp), %eax
movl $0x190, %ecx            # imm = 0x190
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x981ec
movl -0x5c(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x981d4
movl -0x5c(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0xa4(%rbp)
jmp 0x981de
xorl %eax, %eax
movl %eax, -0xa4(%rbp)
jmp 0x981de
movl -0xa4(%rbp), %eax
movl %eax, -0xa8(%rbp)
jmp 0x981f9
movl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x981f9
movl -0xa8(%rbp), %eax
cltq
movq %rax, -0x30(%rbp)
jmp 0x9832e
movslq -0x60(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movslq -0x70(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movl -0x60(%rbp), %eax
movl $0xc, %ecx
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x293f7(%rip), %rax     # 0xc1630
movl (%rax,%rcx,4), %eax
movl %eax, -0x94(%rbp)
cmpl $0x1, -0x60(%rbp)
jne 0x982a2
movl -0x5c(%rbp), %eax
movl $0x190, %ecx            # imm = 0x190
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x98290
movl -0x5c(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x98288
movl -0x5c(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x98280
xorl %eax, %eax
testb $0x1, %al
jne 0x982a2
jmp 0x98298
movb $0x1, %al
testb $0x1, %al
jne 0x982a2
jmp 0x98298
xorl %eax, %eax
testb $0x1, %al
jne 0x982a2
jmp 0x98298
movb $0x1, %al
testb $0x1, %al
jne 0x982a2
jmp 0x98298
movl $0x1c, -0x94(%rbp)
movslq -0x94(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
xorl %eax, %eax
movl %eax, %edi
callq 0xd980
movq %rax, -0x30(%rbp)
jmp 0x9832e
movslq -0x58(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movl -0x58(%rbp), %eax
movl $0x7, %ecx
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x29383(%rip), %rax     # 0xc1660
movslq (%rax,%rcx,4), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movl -0x5c(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movslq %edx, %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movslq -0x5c(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movslq -0x54(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9832e
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x2d2a2(%rip), %rdx     # 0xc55cb
callq 0x580b0
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x57010
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nop