// File: /workspace/github_c_makefile_star2_O1/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 0x5e156
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 0x16de6(%rip), %r12     # 0x74a50
movzbl (%r14), %eax
addl $-0x41, %eax
cmpl $0x39, %eax
ja 0x5e0e1
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x30(%rbx), %rdx
leaq 0x1b400(%rip), %rsi     # 0x7908e
movq %r15, %rdi
xorl %eax, %eax
callq 0x45c53
jmp 0x5e13c
movl 0x14(%rbx), %edx
leaq 0x1b398(%rip), %rsi     # 0x7903f
jmp 0x5e132
movl 0x18(%rbx), %edx
jmp 0x5e12b
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 0x1b39c(%rip), %rsi     # 0x79072
movq %r15, %rdi
xorl %eax, %eax
pushq 0x30(%rbx)
pushq %r10
pushq %r11
callq 0x45c53
jmp 0x5de86
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 0x162f0(%rip), %rsi     # 0x74005
jmp 0x5deb8
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 0x37186(%rip), %rcx     # 0x94ed0
jmp 0x5dfac
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 0x5deb1
movl 0x4(%rbx), %edx
jmp 0x5e11d
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 0x5e126
rorl $0x2, %ecx
xorl %edx, %edx
cmpl $0x28f5c29, %ecx        # imm = 0x28F5C29
jb 0x5e12b
testb $0x3, %al
jmp 0x5dffd
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 0x37136(%rip), %rcx     # 0x94f10
jmp 0x5dfe5
movl 0x8(%rbx), %edx
jmp 0x5e12b
movl 0x8(%rbx), %edx
jmp 0x5e11d
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 0x370b1(%rip), %rcx     # 0x94ed0
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 0x370c1(%rip), %rsi     # 0x94f10
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 0x1b1dc(%rip), %rsi     # 0x7904f
xorl %eax, %eax
pushq %r11
pushq %r12
movq %r15, %r12
movq %rdi, %r15
pushq %r10
callq 0x45c53
addq $0x20, %rsp
jmp 0x5e13c
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 0x1b20e(%rip), %rsi     # 0x790c6
movq %r15, %rdi
jmp 0x5e135
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 0x1702e(%rip), %rsi     # 0x74f40
addq %rdx, %rsi
jmp 0x5e0c9
movl 0xc(%rbx), %edx
jmp 0x5e11d
cmpl $0xd, 0x8(%rbx)
leaq 0x1b119(%rip), %rax     # 0x79046
leaq 0x1b115(%rip), %rsi     # 0x79049
jmp 0x5e0c5
movl (%rbx), %edx
jmp 0x5e11d
imull $0xf4240, (%rbx), %edx  # imm = 0xF4240
jmp 0x5e0aa
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 0x17015(%rip), %rcx     # 0x74f90
movl (%rcx,%rax,4), %edx
jmp 0x5e12b
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 0x36f64(%rip), %rcx     # 0x94f10
movq (%rcx,%rax,8), %rsi
jmp 0x5e101
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 0x36eeb(%rip), %rcx     # 0x94ed0
movq (%rcx,%rax,8), %rsi
movq 0x8(%r15), %rdi
movl $0x3, %edx
jmp 0x5e10a
xorl %edx, %edx
cmpl $0x1, 0x20(%rbx)
sete %dl
jmp 0x5e12b
movl 0xc(%rbx), %edx
jmp 0x5e12b
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 0x16f27(%rip), %rdx     # 0x74f60
movl (%rdx,%rcx,4), %edx
cmpq $0x1, %rax
jne 0x5e12b
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 0x5e12b
rorl $0x2, %eax
testb $0x3, %cl
movl $0x1c, %ecx
cmovnel %ecx, %edx
cmpl $0x28f5c29, %eax        # imm = 0x28F5C29
cmovbl %ecx, %edx
jmp 0x5e12b
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 0x1af9b(%rip), %rsi     # 0x7904c
jmp 0x5e132
cmpl $0xd, 0x8(%rbx)
leaq 0x1af85(%rip), %rax     # 0x79043
leaq 0x15429(%rip), %rsi     # 0x734ee
cmovgeq %rax, %rsi
movq 0x8(%r15), %rdi
movl $0x2, %edx
jmp 0x5e10a
movl 0x1c(%rbx), %edx
jmp 0x5e12b
incq %r14
cmpq %r13, %r14
jae 0x5e13c
movq 0x8(%r15), %rdi
movq %r14, %rsi
movl $0x1, %edx
jmp 0x5e10a
movq 0x28(%rbx), %rax
testq %rax, %rax
leaq 0x15087(%rip), %rsi     # 0x73184
cmovneq %rax, %rsi
movq 0x8(%r15), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3087c
jmp 0x5e13c
movl 0x10(%rbx), %edx
incl %edx
jmp 0x5e12b
movl 0x10(%rbx), %edx
incl %edx
leaq 0x1afa2(%rip), %rsi     # 0x790c6
jmp 0x5e132
movl $0x1, %edx
leaq 0x15ed3(%rip), %rsi     # 0x74005
movq %r15, %rdi
xorl %eax, %eax
callq 0x45c53
incq %r14
cmpq %r13, %r14
jb 0x5dc6a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq