// File: /workspace/github_c_makefile_star2_O3/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: DateFormat
static sxi32 DateFormat(jx9_context *pCtx, const char *zIn, int nLen, Sytm *pTm)
{
	const char *zEnd = &zIn[nLen];
	const char *zCur;
	/* Start the format process */
	for(;;){
		if( zIn >= zEnd ){
			/* No more input to process */
			break;
		}
		switch(zIn[0]){
		case 'd':
			/* Day of the month, 2 digits with leading zeros */
			jx9_result_string_format(pCtx, "%02d", pTm->tm_mday);
			break;
		case 'D':
			/*A textual representation of a day, three letters*/
			zCur = SyTimeGetDay(pTm->tm_wday);
			jx9_result_string(pCtx, zCur, 3);
			break;
		case 'j':
			/*	Day of the month without leading zeros */
			jx9_result_string_format(pCtx, "%d", pTm->tm_mday);
			break;
		case 'l':
			/* A full textual representation of the day of the week */
			zCur = SyTimeGetDay(pTm->tm_wday);
			jx9_result_string(pCtx, zCur, -1/*Compute length automatically*/);
			break;
		case 'N':{
			/* ISO-8601 numeric representation of the day of the week */
			jx9_result_string_format(pCtx, "%d", aISO8601[pTm->tm_wday % 7 ]);
			break;
				 }
		case 'w':
			/*Numeric representation of the day of the week*/
			jx9_result_string_format(pCtx, "%d", pTm->tm_wday);
			break;
		case 'z':
			/*The day of the year*/
			jx9_result_string_format(pCtx, "%d", pTm->tm_yday);
			break;
		case 'F':
			/*A full textual representation of a month, such as January or March*/
			zCur = SyTimeGetMonth(pTm->tm_mon);
			jx9_result_string(pCtx, zCur, -1/*Compute length automatically*/);
			break;
		case 'm':
			/*Numeric representation of a month, with leading zeros*/
			jx9_result_string_format(pCtx, "%02d", pTm->tm_mon + 1);
			break;
		case 'M':
			/*A short textual representation of a month, three letters*/
			zCur = SyTimeGetMonth(pTm->tm_mon);
			jx9_result_string(pCtx, zCur, 3);
			break;
		case 'n':
			/*Numeric representation of a month, without leading zeros*/
			jx9_result_string_format(pCtx, "%d", pTm->tm_mon + 1);
			break;
		case 't':{
			static const int aMonDays[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
			int nDays = aMonDays[pTm->tm_mon % 12 ];
			if( pTm->tm_mon == 1 /* 'February' */ && !IS_LEAP_YEAR(pTm->tm_year) ){
				nDays = 28;
			}
			/*Number of days in the given month*/
			jx9_result_string_format(pCtx, "%d", nDays);
			break;
				 }
		case 'L':{
			int isLeap = IS_LEAP_YEAR(pTm->tm_year);
			/* Whether it's a leap year */
			jx9_result_string_format(pCtx, "%d", isLeap);
			break;
				 }
		case 'o':
			/* ISO-8601 year number.*/
			jx9_result_string_format(pCtx, "%4d", pTm->tm_year);
			break;
		case 'Y':
			/*	A full numeric representation of a year, 4 digits */
			jx9_result_string_format(pCtx, "%4d", pTm->tm_year);
			break;
		case 'y':
			/*A two digit representation of a year*/
			jx9_result_string_format(pCtx, "%02d", pTm->tm_year%100);
			break;
		case 'a':
			/*	Lowercase Ante meridiem and Post meridiem */
			jx9_result_string(pCtx, pTm->tm_hour > 12 ? "pm" : "am", 2);
			break;
		case 'A':
			/*	Uppercase Ante meridiem and Post meridiem */
			jx9_result_string(pCtx, pTm->tm_hour > 12 ? "PM" : "AM", 2);
			break;
		case 'g':
			/*	12-hour format of an hour without leading zeros*/
			jx9_result_string_format(pCtx, "%d", 1+(pTm->tm_hour%12));
			break;
		case 'G':
			/* 24-hour format of an hour without leading zeros */
			jx9_result_string_format(pCtx, "%d", pTm->tm_hour);
			break;
		case 'h':
			/* 12-hour format of an hour with leading zeros */
			jx9_result_string_format(pCtx, "%02d", 1+(pTm->tm_hour%12));
			break;
		case 'H':
			/*	24-hour format of an hour with leading zeros */
			jx9_result_string_format(pCtx, "%02d", pTm->tm_hour);
			break;
		case 'i':
			/* 	Minutes with leading zeros */
			jx9_result_string_format(pCtx, "%02d", pTm->tm_min);
			break;
		case 's':
			/* 	second with leading zeros */
			jx9_result_string_format(pCtx, "%02d", pTm->tm_sec);
			break;
		case 'u':
			/* 	Microseconds */
			jx9_result_string_format(pCtx, "%u", pTm->tm_sec * SX_USEC_PER_SEC);
			break;
		case 'S':{
			/* English ordinal suffix for the day of the month, 2 characters */
			static const char zSuffix[] = "thstndrdthththththth";
			int v = pTm->tm_mday;
			jx9_result_string(pCtx, &zSuffix[2 * (int)(v / 10 % 10 != 1 ? v % 10 : 0)], (int)sizeof(char) * 2);
			break;
				 }
		case 'e':
			/* 	Timezone identifier */
			zCur = pTm->tm_zone;
			if( zCur == 0 ){
				/* Assume GMT */
				zCur = "GMT";
			}
			jx9_result_string(pCtx, zCur, -1);
			break;
		case 'I':
			/* Whether or not the date is in daylight saving time */
#ifdef __WINNT__
#ifdef _MSC_VER
#ifndef _WIN32_WCE
			_get_daylight(&pTm->tm_isdst);
#endif
#endif
#endif
			jx9_result_string_format(pCtx, "%d", pTm->tm_isdst == 1);
			break;
		case 'r':
			/* RFC 2822 formatted date 	Example: Thu, 21 Dec 2000 16:01:07 */
			jx9_result_string_format(pCtx, "%.3s, %02d %.3s %4d %02d:%02d:%02d", 
				SyTimeGetDay(pTm->tm_wday), 
				pTm->tm_mday, 
				SyTimeGetMonth(pTm->tm_mon), 
				pTm->tm_year, 
				pTm->tm_hour, 
				pTm->tm_min, 
				pTm->tm_sec
				);
			break;
		case 'U':{
			time_t tt;
			/* Seconds since the Unix Epoch */
			time(&tt);
			jx9_result_string_format(pCtx, "%u", (unsigned int)tt);
			break;
				 }
		case 'O':
		case 'P':
			/* Difference to Greenwich time (GMT) in hours */
			jx9_result_string_format(pCtx, "%+05d", pTm->tm_gmtoff);
			break;
		case 'Z':
			/* Timezone offset in seconds. The offset for timezones west of UTC
			 * is always negative, and for those east of UTC is always positive.
			 */
			jx9_result_string_format(pCtx, "%+05d", pTm->tm_gmtoff);
			break;
		case 'c':
			/* 	ISO 8601 date */
			jx9_result_string_format(pCtx, "%4d-%02d-%02dT%02d:%02d:%02d%+05d", 
				pTm->tm_year, 
				pTm->tm_mon+1, 
				pTm->tm_mday, 
				pTm->tm_hour, 
				pTm->tm_min, 
				pTm->tm_sec, 
				pTm->tm_gmtoff
				);
			break;
		case '\\':
			zIn++;
			/* Expand verbatim */
			if( zIn < zEnd ){
				jx9_result_string(pCtx, zIn, (int)sizeof(char));
			}
			break;
		default:
			/* Unknown format specifer, expand verbatim */
			jx9_result_string(pCtx, zIn, (int)sizeof(char));
			break;
		}
		/* Point to the next character */
		zIn++;
	}
	return SXRET_OK;
}

// Assembly:
testl %edx, %edx
jle 0x5c862
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movslq %edx, %r13
addq %rsi, %r13
leaq 0x166e6(%rip), %r12     # 0x72a5c
movzbl (%r14), %eax
addl $-0x41, %eax
cmpl $0x39, %eax
ja 0x5c7ed
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x30(%rbx), %rdx
leaq 0x1acff(%rip), %rsi     # 0x77099
movq %r15, %rdi
xorl %eax, %eax
callq 0x44e00
jmp 0x5c848
movl 0x14(%rbx), %edx
leaq 0x1ac97(%rip), %rsi     # 0x7704a
jmp 0x5c83e
movl 0x18(%rbx), %edx
jmp 0x5c837
movl 0x14(%rbx), %edx
movl 0x10(%rbx), %ecx
incl %ecx
movl 0xc(%rbx), %r8d
movl 0x8(%rbx), %r9d
movl (%rbx), %r10d
movl 0x4(%rbx), %r11d
subq $0x8, %rsp
leaq 0x1ac9b(%rip), %rsi     # 0x7707d
movq %r15, %rdi
xorl %eax, %eax
pushq 0x30(%rbx)
pushq %r10
pushq %r11
callq 0x44e00
jmp 0x5c592
movslq 0x8(%rbx), %rdx
imulq $0x2aaaaaab, %rdx, %rax # imm = 0x2AAAAAAB
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x21, %rax
addl %ecx, %eax
shll $0x2, %eax
leal (%rax,%rax,2), %eax
subl %eax, %edx
incl %edx
leaq 0x15bd4(%rip), %rsi     # 0x71ff5
jmp 0x5c5c4
movslq 0x18(%rbx), %rax
imulq $-0x6db6db6d, %rax, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x2, %ecx
addl %edx, %ecx
leal (,%rcx,8), %edx
subl %edx, %ecx
addl %eax, %ecx
movslq %ecx, %rax
leaq 0x36a7a(%rip), %rcx     # 0x92ed0
jmp 0x5c6b8
movslq 0x14(%rbx), %rdx
imulq $0x51eb851f, %rdx, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x25, %rax
addl %ecx, %eax
imull $0x64, %eax, %eax
subl %eax, %edx
jmp 0x5c5bd
movl 0x4(%rbx), %edx
jmp 0x5c829
movl 0x14(%rbx), %eax
imull $0xc28f5c29, %eax, %ecx # imm = 0xC28F5C29
addl $0x51eb850, %ecx        # imm = 0x51EB850
movl %ecx, %edx
rorl $0x4, %edx
cmpl $0xa3d70b, %edx         # imm = 0xA3D70B
jb 0x5c832
rorl $0x2, %ecx
xorl %edx, %edx
cmpl $0x28f5c29, %ecx        # imm = 0x28F5C29
jb 0x5c837
testb $0x3, %al
jmp 0x5c709
movslq 0x10(%rbx), %rax
imulq $0x2aaaaaab, %rax, %rcx # imm = 0x2AAAAAAB
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x21, %rcx
addl %edx, %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
cltq
leaq 0x36a2a(%rip), %rcx     # 0x92f10
jmp 0x5c6f1
movl 0x8(%rbx), %edx
jmp 0x5c837
movl 0x8(%rbx), %edx
jmp 0x5c829
movslq 0x18(%rbx), %rax
imulq $-0x6db6db6d, %rax, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x2, %ecx
addl %edx, %ecx
leal (,%rcx,8), %edx
subl %edx, %ecx
addl %eax, %ecx
movslq %ecx, %rax
leaq 0x369a5(%rip), %rcx     # 0x92ed0
movq (%rcx,%rax,8), %rdx
movl 0xc(%rbx), %ecx
movslq 0x10(%rbx), %rax
imulq $0x2aaaaaab, %rax, %rsi # imm = 0x2AAAAAAB
movq %rsi, %rdi
shrq $0x3f, %rdi
shrq $0x21, %rsi
addl %edi, %esi
shll $0x2, %esi
leal (%rsi,%rsi,2), %esi
subl %esi, %eax
cltq
leaq 0x369b5(%rip), %rsi     # 0x92f10
movq (%rsi,%rax,8), %r8
movl 0x14(%rbx), %r9d
movl 0x8(%rbx), %r10d
movl (%rbx), %r11d
movq %r15, %rdi
movq %r12, %r15
movl 0x4(%rbx), %r12d
subq $0x8, %rsp
leaq 0x1aadb(%rip), %rsi     # 0x7705a
xorl %eax, %eax
pushq %r11
pushq %r12
movq %r15, %r12
movq %rdi, %r15
pushq %r10
callq 0x44e00
addq $0x20, %rsp
jmp 0x5c848
movslq 0x8(%rbx), %rdx
imulq $0x2aaaaaab, %rdx, %rax # imm = 0x2AAAAAAB
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x21, %rax
addl %ecx, %eax
shll $0x2, %eax
leal (%rax,%rax,2), %eax
subl %eax, %edx
incl %edx
leaq 0x1ab0d(%rip), %rsi     # 0x770d1
movq %r15, %rdi
jmp 0x5c841
movslq 0xc(%rbx), %rax
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
leal (%rcx,%rcx), %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %eax
movslq %ecx, %rcx
imulq $0x66666667, %rcx, %rdx # imm = 0x66666667
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x22, %rdx
addl %esi, %edx
addl %edx, %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %ecx
addl %eax, %eax
xorl %edx, %edx
cmpl $0x1, %ecx
cltq
cmovneq %rax, %rdx
leaq 0x16932(%rip), %rsi     # 0x72f50
addq %rdx, %rsi
jmp 0x5c7d5
movl 0xc(%rbx), %edx
jmp 0x5c829
cmpl $0xd, 0x8(%rbx)
leaq 0x1aa18(%rip), %rax     # 0x77051
leaq 0x1aa14(%rip), %rsi     # 0x77054
jmp 0x5c7d1
movl (%rbx), %edx
jmp 0x5c829
imull $0xf4240, (%rbx), %edx  # imm = 0xF4240
jmp 0x5c7b6
movslq 0x18(%rbx), %rax
imulq $-0x6db6db6d, %rax, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x2, %ecx
addl %edx, %ecx
leal (,%rcx,8), %edx
subl %edx, %ecx
addl %eax, %ecx
movslq %ecx, %rax
leaq 0x16919(%rip), %rcx     # 0x72fa0
movl (%rcx,%rax,4), %edx
jmp 0x5c837
movslq 0x10(%rbx), %rax
imulq $0x2aaaaaab, %rax, %rcx # imm = 0x2AAAAAAB
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x21, %rcx
addl %edx, %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
cltq
leaq 0x36858(%rip), %rcx     # 0x92f10
movq (%rcx,%rax,8), %rsi
jmp 0x5c80d
movslq 0x18(%rbx), %rax
imulq $-0x6db6db6d, %rax, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x2, %ecx
addl %edx, %ecx
leal (,%rcx,8), %edx
subl %edx, %ecx
addl %eax, %ecx
movslq %ecx, %rax
leaq 0x367df(%rip), %rcx     # 0x92ed0
movq (%rcx,%rax,8), %rsi
movq 0x8(%r15), %rdi
movl $0x3, %edx
jmp 0x5c816
xorl %edx, %edx
cmpl $0x1, 0x20(%rbx)
sete %dl
jmp 0x5c837
movl 0xc(%rbx), %edx
jmp 0x5c837
movslq 0x10(%rbx), %rax
imulq $0x2aaaaaab, %rax, %rcx # imm = 0x2AAAAAAB
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x21, %rcx
addl %edx, %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,2), %ecx
movl %eax, %edx
subl %ecx, %edx
movslq %edx, %rcx
leaq 0x1682b(%rip), %rdx     # 0x72f70
movl (%rdx,%rcx,4), %edx
cmpq $0x1, %rax
jne 0x5c837
movl 0x14(%rbx), %ecx
imull $0xc28f5c29, %ecx, %eax # imm = 0xC28F5C29
addl $0x51eb850, %eax        # imm = 0x51EB850
movl %eax, %esi
rorl $0x4, %esi
cmpl $0xa3d70b, %esi         # imm = 0xA3D70B
jb 0x5c837
rorl $0x2, %eax
testb $0x3, %cl
movl $0x1c, %ecx
cmovnel %ecx, %edx
cmpl $0x28f5c29, %eax        # imm = 0x28F5C29
cmovbl %ecx, %edx
jmp 0x5c837
movq %rbx, -0x30(%rbp)
movq %r13, %rbx
movq %r15, %r13
movq %r12, %r15
leaq -0x38(%rbp), %r12
movq %r12, %rdi
callq 0xc820
movl (%r12), %edx
movq %r15, %r12
movq %r13, %r15
movq %rbx, %r13
movq -0x30(%rbp), %rbx
leaq 0x1a89a(%rip), %rsi     # 0x77057
jmp 0x5c83e
cmpl $0xd, 0x8(%rbx)
leaq 0x1a884(%rip), %rax     # 0x7704e
leaq 0x14d1d(%rip), %rsi     # 0x714ee
cmovgeq %rax, %rsi
movq 0x8(%r15), %rdi
movl $0x2, %edx
jmp 0x5c816
movl 0x1c(%rbx), %edx
jmp 0x5c837
incq %r14
cmpq %r13, %r14
jae 0x5c848
movq 0x8(%r15), %rdi
movq %r14, %rsi
movl $0x1, %edx
jmp 0x5c816
movq 0x28(%rbx), %rax
testq %rax, %rax
leaq 0x1497b(%rip), %rsi     # 0x71184
cmovneq %rax, %rsi
movq 0x8(%r15), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x302f6
jmp 0x5c848
movl 0x10(%rbx), %edx
incl %edx
jmp 0x5c837
movl 0x10(%rbx), %edx
incl %edx
leaq 0x1a8a1(%rip), %rsi     # 0x770d1
jmp 0x5c83e
movl $0x1, %edx
leaq 0x157b7(%rip), %rsi     # 0x71ff5
movq %r15, %rdi
xorl %eax, %eax
callq 0x44e00
incq %r14
cmpq %r13, %r14
jb 0x5c376
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq