// File: /workspace/github_c_makefile_star2_O2/ArtifexSoftware[P]mujs/./jsdate.c
// Function: parseDateTime
static double parseDateTime(const char *s)
{
	int y = 1970, m = 1, d = 1, H = 0, M = 0, S = 0, ms = 0;
	int tza = 0;
	double t;

	/* Parse ISO 8601 formatted date and time: */
	/* YYYY("-"MM("-"DD)?)?("T"HH":"mm(":"ss("."sss)?)?("Z"|[+-]HH(":"mm)?)?)? */

	if (!toint(&s, 4, &y)) return NAN;
	if (*s == '-') {
		s += 1;
		if (!toint(&s, 2, &m)) return NAN;
		if (*s == '-') {
			s += 1;
			if (!toint(&s, 2, &d)) return NAN;
		}
	}

	if (*s == 'T') {
		s += 1;
		if (!toint(&s, 2, &H)) return NAN;
		if (*s != ':') return NAN;
		s += 1;
		if (!toint(&s, 2, &M)) return NAN;
		if (*s == ':') {
			s += 1;
			if (!toint(&s, 2, &S)) return NAN;
			if (*s == '.') {
				s += 1;
				if (!toint(&s, 3, &ms)) return NAN;
			}
		}
		if (*s == 'Z') {
			s += 1;
			tza = 0;
		} else if (*s == '+' || *s == '-') {
			int tzh = 0, tzm = 0;
			int tzs = *s == '+' ? 1 : -1;
			s += 1;
			if (!toint(&s, 2, &tzh)) return NAN;
			if (*s == ':') {
				s += 1;
				if (!toint(&s, 2, &tzm)) return NAN;
			}
			if (tzh > 23 || tzm > 59) return NAN;
			tza = tzs * (tzh * msPerHour + tzm * msPerMinute);
		} else {
			tza = LocalTZA();
		}
	}

	if (*s) return NAN;

	if (m < 1 || m > 12) return NAN;
	if (d < 1 || d > 31) return NAN;
	if (H < 0 || H > 24) return NAN;
	if (M < 0 || M > 59) return NAN;
	if (S < 0 || S > 59) return NAN;
	if (ms < 0 || ms > 999) return NAN;
	if (H == 24 && (M != 0 || S != 0 || ms != 0)) return NAN;

	/* TODO: DaylightSavingTA on local times */
	t = MakeDate(MakeDay(y, m-1, d), MakeTime(H, M, S, ms));
	return t - tza;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsp, %rax
movq %rdi, (%rax)
leaq 0x2c(%rsp), %rdx
movl $0x7b2, (%rdx)          # imm = 0x7B2
andl $0x0, 0x1c(%rsp)
pushq $0x1
popq %rcx
andl $0x0, 0x18(%rsp)
movl %ecx, 0x24(%rsp)
andl $0x0, 0x14(%rsp)
movl %ecx, 0x20(%rsp)
andl $0x0, 0x10(%rsp)
pushq $0x4
popq %rsi
movq %rax, %rdi
callq 0x18b1d
movsd 0x7bdb(%rip), %xmm0     # 0x20418
testl %eax, %eax
je 0x18b10
movq (%rsp), %r14
movb (%r14), %al
cmpb $0x2d, %al
jne 0x188a6
incq %r14
movq %rsp, %rdi
movq %r14, (%rdi)
pushq $0x2
popq %rsi
leaq 0x24(%rsp), %rdx
callq 0x18b1d
testl %eax, %eax
je 0x1896e
movq (%rsp), %r14
movb (%r14), %al
cmpb $0x2d, %al
jne 0x1889e
incq %r14
movq %rsp, %rdi
movq %r14, (%rdi)
pushq $0x2
popq %rsi
leaq 0x20(%rsp), %rdx
callq 0x18b1d
testl %eax, %eax
je 0x1896e
movq (%rsp), %r14
movb (%r14), %al
movsd 0x7b72(%rip), %xmm0     # 0x20418
xorl %ebx, %ebx
cmpb $0x54, %al
jne 0x18a41
incq %r14
movq %rsp, %rdi
movq %r14, (%rdi)
pushq $0x2
popq %rsi
leaq 0x1c(%rsp), %rdx
callq 0x18b1d
testl %eax, %eax
je 0x1896e
movq (%rsp), %rax
cmpb $0x3a, (%rax)
jne 0x1896e
incq %rax
movq %rsp, %rdi
movq %rax, (%rdi)
pushq $0x2
popq %rsi
leaq 0x18(%rsp), %rdx
callq 0x18b1d
testl %eax, %eax
je 0x1896e
movq (%rsp), %r14
movb (%r14), %bpl
cmpb $0x3a, %bpl
jne 0x1894a
incq %r14
movq %rsp, %rdi
movq %r14, (%rdi)
pushq $0x2
popq %rsi
leaq 0x14(%rsp), %rdx
callq 0x18b1d
testl %eax, %eax
je 0x1896e
movq (%rsp), %r14
movb (%r14), %bpl
cmpb $0x2e, %bpl
jne 0x1894a
incq %r14
movq %rsp, %rdi
movq %r14, (%rdi)
pushq $0x3
popq %rsi
leaq 0x10(%rsp), %rdx
callq 0x18b1d
testl %eax, %eax
je 0x1896e
movq (%rsp), %r14
movb (%r14), %bpl
cmpb $0x2b, %bpl
je 0x1897b
movzbl %bpl, %eax
cmpl $0x2d, %eax
je 0x1897b
cmpl $0x5a, %eax
jne 0x18a30
incq %r14
movq %r14, (%rsp)
jmp 0x18a39
movsd 0x7aa2(%rip), %xmm0     # 0x20418
jmp 0x18b10
leaq 0x28(%rsp), %rdx
andl $0x0, (%rdx)
andl $0x0, 0xc(%rsp)
incq %r14
movq %rsp, %rdi
movq %r14, (%rdi)
pushq $0x2
popq %rsi
callq 0x18b1d
testl %eax, %eax
movsd 0x7a75(%rip), %xmm0     # 0x20418
je 0x18b10
movq (%rsp), %rcx
xorl %eax, %eax
cmpb $0x3a, (%rcx)
jne 0x189de
incq %rcx
movq %rsp, %rdi
movq %rcx, (%rdi)
pushq $0x2
popq %rsi
leaq 0xc(%rsp), %rdx
callq 0x18b1d
movsd 0x7a46(%rip), %xmm0     # 0x20418
testl %eax, %eax
je 0x18b10
movl 0xc(%rsp), %eax
movl 0x28(%rsp), %ecx
cmpl $0x18, %ecx
setge %dl
cmpl $0x3c, %eax
setge %sil
orb %dl, %sil
cmpb $0x1, %sil
je 0x18b10
cvtsi2sd %ecx, %xmm2
cvtsi2sd %eax, %xmm1
mulsd 0x7a74(%rip), %xmm1     # 0x20480
mulsd 0x7b54(%rip), %xmm2     # 0x20568
addsd %xmm1, %xmm2
cmpb $0x2b, %bpl
je 0x18a26
xorpd 0x7b7a(%rip), %xmm2     # 0x205a0
cvttsd2si %xmm2, %ebx
movq (%rsp), %r14
jmp 0x18a41
callq 0x18063
cvttsd2si %xmm0, %ebx
movsd 0x79d7(%rip), %xmm0     # 0x20418
cmpb $0x0, (%r14)
jne 0x18b10
movl 0x24(%rsp), %eax
leal -0xd(%rax), %ecx
cmpl $-0xc, %ecx
jb 0x18b10
movl 0x20(%rsp), %ecx
leal -0x20(%rcx), %edx
cmpl $-0x1f, %edx
jb 0x18b10
movl 0x1c(%rsp), %ebp
cmpl $0x18, %ebp
ja 0x18b10
movl 0x18(%rsp), %r14d
cmpl $0x3b, %r14d
ja 0x18b10
movl 0x14(%rsp), %r15d
cmpl $0x3b, %r15d
ja 0x18b10
movl 0x10(%rsp), %r12d
cmpl $0x3e7, %r12d           # imm = 0x3E7
ja 0x18b10
cmpl $0x18, %ebp
jne 0x18ab0
movl %r15d, %edx
orl %r14d, %edx
orl %r12d, %edx
jne 0x18b10
cvtsi2sdl 0x2c(%rsp), %xmm0
decl %eax
cvtsi2sd %eax, %xmm1
cvtsi2sd %ecx, %xmm2
callq 0x186f2
cvtsi2sd %ebp, %xmm1
cvtsi2sd %r14d, %xmm2
cvtsi2sd %r15d, %xmm3
cvtsi2sd %r12d, %xmm4
movsd 0x79b0(%rip), %xmm5     # 0x20490
mulsd %xmm5, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm5, %xmm1
addsd %xmm3, %xmm1
mulsd 0x79a0(%rip), %xmm1     # 0x20498
addsd %xmm4, %xmm1
mulsd 0x7984(%rip), %xmm0     # 0x20488
addsd %xmm1, %xmm0
cvtsi2sd %ebx, %xmm1
subsd %xmm1, %xmm0
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq