// File: /workspace/github_c_makefile_star2_O2/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:
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, %r12
addq %rsi, %r12
leaq 0x13151(%rip), %r13     # 0x62a40
cmpq %r12, %r14
jae 0x4fc4b
movzbl (%r14), %eax
addl $-0x41, %eax
cmpl $0x39, %eax
ja 0x4fc0b
movslq (%r13,%rax,4), %rax
addq %r13, %rax
pushq $0x64
popq %rdi
pushq $0xc
popq %r8
pushq $0x7
popq %rcx
jmpq *%rax
movq 0x30(%rbx), %rdx
leaq 0x17752(%rip), %rsi     # 0x67079
movq %r15, %rdi
xorl %eax, %eax
callq 0x3bdad
jmp 0x4fc3f
movl 0x14(%rbx), %edx
leaq 0x176ea(%rip), %rsi     # 0x6702a
jmp 0x4fbff
movl 0x18(%rbx), %edx
jmp 0x4fbea
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 0x176ee(%rip), %rsi     # 0x6705d
movq %r15, %rdi
xorl %eax, %eax
pushq 0x30(%rbx)
pushq %r10
pushq %r11
callq 0x3bdad
jmp 0x4fa77
movl 0x8(%rbx), %eax
cltd
idivl %r8d
jmp 0x4fbe8
movl 0x18(%rbx), %eax
cltd
idivl %ecx
movslq %edx, %rax
leaq 0x3653f(%rip), %rcx     # 0x85ee0
jmp 0x4fb06
movl 0x14(%rbx), %eax
cltd
idivl %edi
jmp 0x4fbf8
movl 0x4(%rbx), %edx
jmp 0x4fbf8
movl 0x14(%rbx), %ecx
movl $0x190, %esi            # imm = 0x190
movl %ecx, %eax
cltd
idivl %esi
movl %edx, %eax
pushq $0x1
popq %rdx
testl %eax, %eax
je 0x4fbea
movl %ecx, %eax
cltd
idivl %edi
testl %edx, %edx
je 0x4fc47
xorl %edx, %edx
testb $0x3, %cl
jmp 0x4fb30
movl 0x10(%rbx), %eax
cltd
idivl %r8d
movslq %edx, %rax
leaq 0x36525(%rip), %rcx     # 0x85f20
jmp 0x4fb1f
movl 0x8(%rbx), %edx
jmp 0x4fbea
movl 0x8(%rbx), %edx
jmp 0x4fbf8
movl 0x18(%rbx), %eax
cltd
idivl %ecx
movslq %edx, %rax
leaq 0x364c0(%rip), %rcx     # 0x85ee0
movq (%rcx,%rax,8), %rax
movq %rax, -0x30(%rbp)
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %eax
cltd
idivl %r8d
movslq %edx, %rax
leaq 0x364e4(%rip), %rdx     # 0x85f20
movq (%rdx,%rax,8), %r8
movl 0x14(%rbx), %r9d
movq %r15, %rdi
movl 0x8(%rbx), %r15d
movq %r13, %r11
movl (%rbx), %r13d
movl 0x4(%rbx), %r10d
subq $0x8, %rsp
leaq 0x175da(%rip), %rsi     # 0x6703a
movq -0x30(%rbp), %rdx
xorl %eax, %eax
pushq %r13
movq %r11, %r13
pushq %r10
pushq %r15
movq %rdi, %r15
callq 0x3bdad
addq $0x20, %rsp
jmp 0x4fc3f
movl 0x8(%rbx), %eax
cltd
idivl %r8d
jmp 0x4fbf6
movl 0xc(%rbx), %eax
pushq $0xa
popq %rsi
cltd
idivl %esi
movl %edx, %ecx
cltd
idivl %esi
cmpl $0x1, %edx
je 0x4fc16
addl %ecx, %ecx
movslq %ecx, %rax
jmp 0x4fc18
movl 0xc(%rbx), %edx
jmp 0x4fbf8
cmpl $0xd, 0x8(%rbx)
jge 0x4fc24
leaq 0x1756e(%rip), %rsi     # 0x67034
jmp 0x4fc34
movl (%rbx), %edx
jmp 0x4fbf8
imull $0xf4240, (%rbx), %edx  # imm = 0xF4240
jmp 0x4fb9f
movl 0x18(%rbx), %eax
cltd
idivl %ecx
movslq %edx, %rax
leaq 0x13493(%rip), %rcx     # 0x62f80
movl (%rcx,%rax,4), %edx
jmp 0x4fbea
movl 0x10(%rbx), %eax
cltd
idivl %r8d
movslq %edx, %rax
leaq 0x3641a(%rip), %rcx     # 0x85f20
movq (%rcx,%rax,8), %rsi
jmp 0x4fbe1
movl 0x18(%rbx), %eax
cltd
idivl %ecx
movslq %edx, %rax
leaq 0x363c1(%rip), %rcx     # 0x85ee0
movq (%rcx,%rax,8), %rsi
pushq $0x3
jmp 0x4fc36
xorl %edx, %edx
cmpl $0x1, 0x20(%rbx)
sete %dl
jmp 0x4fbea
movl 0xc(%rbx), %edx
jmp 0x4fbea
movl 0x10(%rbx), %esi
movl %esi, %eax
cltd
idivl %r8d
movslq %edx, %rax
leaq 0x133fd(%rip), %rcx     # 0x62f50
movl (%rcx,%rax,4), %ecx
cmpl $0x1, %esi
jne 0x4fb82
movl 0x14(%rbx), %esi
movl $0x190, %r8d            # imm = 0x190
movl %esi, %eax
cltd
idivl %r8d
testl %edx, %edx
je 0x4fb82
movl %esi, %eax
cltd
idivl %edi
testb $0x3, %sil
pushq $0x1c
popq %rax
cmovnel %eax, %ecx
testl %edx, %edx
cmovel %eax, %ecx
leaq 0x1246c(%rip), %rsi     # 0x61ff5
movq %r15, %rdi
movl %ecx, %edx
jmp 0x4fc02
leaq -0x38(%rbp), %rdi
callq 0xc850
leaq -0x38(%rbp), %rax
movl (%rax), %edx
leaq 0x17491(%rip), %rsi     # 0x67037
jmp 0x4fbff
cmpl $0xd, 0x8(%rbx)
jge 0x4fc2d
leaq 0x1190f(%rip), %rsi     # 0x614c4
jmp 0x4fc34
movl 0x1c(%rbx), %edx
jmp 0x4fbea
incq %r14
cmpq %r12, %r14
jae 0x4fc3f
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
jmp 0x4fc3a
movq 0x28(%rbx), %rax
testq %rax, %rax
leaq 0x1157d(%rip), %rsi     # 0x6115a
cmovneq %rax, %rsi
pushq $-0x1
jmp 0x4fc36
movl 0x10(%rbx), %edx
incl %edx
leaq 0x12404(%rip), %rsi     # 0x61ff5
jmp 0x4fbff
movl 0x10(%rbx), %edx
incl %edx
leaq 0x174b2(%rip), %rsi     # 0x670b1
movq %r15, %rdi
xorl %eax, %eax
callq 0x3bdad
jmp 0x4fc3f
movq %r15, %rdi
movq %r14, %rsi
pushq $0x1
popq %rdx
jmp 0x4fc3a
xorl %eax, %eax
leaq 0x13311(%rip), %rsi     # 0x62f30
addq %rax, %rsi
jmp 0x4fc34
leaq 0x17406(%rip), %rsi     # 0x67031
jmp 0x4fc34
leaq 0x173fa(%rip), %rsi     # 0x6702e
pushq $0x2
popq %rdx
movq %r15, %rdi
callq 0x29903
incq %r14
jmp 0x4f8ef
xorl %edx, %edx
jmp 0x4fbea
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq