// File: /workspace/github_c_makefile_star2_O3/lyda[P]tz/localtime.c
// Function: tzparse
static int
tzparse(name, sp, lastditch)
const char *			name;
register struct state * const	sp;
const int			lastditch;
{
	const char *			stdname;
	const char *			dstname;
	size_t				stdlen;
	size_t				dstlen;
	long				stdoffset;
	long				dstoffset;
	register time_t *		atp;
	register unsigned char *	typep;
	register char *			cp;
	register int			load_result;
	static struct ttinfo		zttinfo;

	INITIALIZE(dstname);
	stdname = name;
	if (lastditch) {
		stdlen = strlen(name);	/* length of standard zone name */
		name += stdlen;
		if (stdlen >= sizeof sp->chars)
			stdlen = (sizeof sp->chars) - 1;
		stdoffset = 0;
	} else {
		if (*name == '<') {
			name++;
			stdname = name;
			name = getqzname(name, '>');
			if (*name != '>')
				return (-1);
			stdlen = name - stdname;
			name++;
		} else {
			name = getzname(name);
			stdlen = name - stdname;
		}
		if (*name == '\0')
			return -1;
		name = getoffset(name, &stdoffset);
		if (name == NULL)
			return -1;
	}
	load_result = tzload(TZDEFRULES, sp, FALSE);
	if (load_result != 0)
		sp->leapcnt = 0;		/* so, we're off a little */
	if (*name != '\0') {
		if (*name == '<') {
			dstname = ++name;
			name = getqzname(name, '>');
			if (*name != '>')
				return -1;
			dstlen = name - dstname;
			name++;
		} else {
			dstname = name;
			name = getzname(name);
			dstlen = name - dstname; /* length of DST zone name */
		}
		if (*name != '\0' && *name != ',' && *name != ';') {
			name = getoffset(name, &dstoffset);
			if (name == NULL)
				return -1;
		} else	dstoffset = stdoffset - SECSPERHOUR;
		if (*name == '\0' && load_result != 0)
			name = TZDEFRULESTRING;
		if (*name == ',' || *name == ';') {
			struct rule	start;
			struct rule	end;
			register int	year;
			register time_t	janfirst;
			time_t		starttime;
			time_t		endtime;

			++name;
			if ((name = getrule(name, &start)) == NULL)
				return -1;
			if (*name++ != ',')
				return -1;
			if ((name = getrule(name, &end)) == NULL)
				return -1;
			if (*name != '\0')
				return -1;
			sp->typecnt = 2;	/* standard time and DST */
			/*
			** Two transitions per year, from EPOCH_YEAR forward.
			*/
			sp->ttis[0] = sp->ttis[1] = zttinfo;
			sp->ttis[0].tt_gmtoff = -dstoffset;
			sp->ttis[0].tt_isdst = 1;
			sp->ttis[0].tt_abbrind = stdlen + 1;
			sp->ttis[1].tt_gmtoff = -stdoffset;
			sp->ttis[1].tt_isdst = 0;
			sp->ttis[1].tt_abbrind = 0;
			atp = sp->ats;
			typep = sp->types;
			janfirst = 0;
			sp->timecnt = 0;
			for (year = EPOCH_YEAR;
			    sp->timecnt + 2 <= TZ_MAX_TIMES;
			    ++year) {
			    	time_t	newfirst;

				starttime = transtime(janfirst, year, &start,
					stdoffset);
				endtime = transtime(janfirst, year, &end,
					dstoffset);
				if (starttime > endtime) {
					*atp++ = endtime;
					*typep++ = 1;	/* DST ends */
					*atp++ = starttime;
					*typep++ = 0;	/* DST begins */
				} else {
					*atp++ = starttime;
					*typep++ = 0;	/* DST begins */
					*atp++ = endtime;
					*typep++ = 1;	/* DST ends */
				}
				sp->timecnt += 2;
				newfirst = janfirst;
				newfirst += year_lengths[isleap(year)] *
					SECSPERDAY;
				if (newfirst <= janfirst)
					break;
				janfirst = newfirst;
			}
		} else {
			register long	theirstdoffset;
			register long	theirdstoffset;
			register long	theiroffset;
			register int	isdst;
			register int	i;
			register int	j;

			if (*name != '\0')
				return -1;
			/*
			** Initial values of theirstdoffset and theirdstoffset.
			*/
			theirstdoffset = 0;
			for (i = 0; i < sp->timecnt; ++i) {
				j = sp->types[i];
				if (!sp->ttis[j].tt_isdst) {
					theirstdoffset =
						-sp->ttis[j].tt_gmtoff;
					break;
				}
			}
			theirdstoffset = 0;
			for (i = 0; i < sp->timecnt; ++i) {
				j = sp->types[i];
				if (sp->ttis[j].tt_isdst) {
					theirdstoffset =
						-sp->ttis[j].tt_gmtoff;
					break;
				}
			}
			/*
			** Initially we're assumed to be in standard time.
			*/
			isdst = FALSE;
			theiroffset = theirstdoffset;
			/*
			** Now juggle transition times and types
			** tracking offsets as you do.
			*/
			for (i = 0; i < sp->timecnt; ++i) {
				j = sp->types[i];
				sp->types[i] = sp->ttis[j].tt_isdst;
				if (sp->ttis[j].tt_ttisgmt) {
					/* No adjustment to transition time */
				} else {
					/*
					** If summer time is in effect, and the
					** transition time was not specified as
					** standard time, add the summer time
					** offset to the transition time;
					** otherwise, add the standard time
					** offset to the transition time.
					*/
					/*
					** Transitions from DST to DDST
					** will effectively disappear since
					** POSIX provides for only one DST
					** offset.
					*/
					if (isdst && !sp->ttis[j].tt_ttisstd) {
						sp->ats[i] += dstoffset -
							theirdstoffset;
					} else {
						sp->ats[i] += stdoffset -
							theirstdoffset;
					}
				}
				theiroffset = -sp->ttis[j].tt_gmtoff;
				if (sp->ttis[j].tt_isdst)
					theirdstoffset = theiroffset;
				else	theirstdoffset = theiroffset;
			}
			/*
			** Finally, fill in ttis.
			*/
			sp->ttis[0] = sp->ttis[1] = zttinfo;
			sp->ttis[0].tt_gmtoff = -stdoffset;
			sp->ttis[0].tt_isdst = FALSE;
			sp->ttis[0].tt_abbrind = 0;
			sp->ttis[1].tt_gmtoff = -dstoffset;
			sp->ttis[1].tt_isdst = TRUE;
			sp->ttis[1].tt_abbrind = stdlen + 1;
			sp->typecnt = 2;
		}
	} else {
		dstlen = 0;
		sp->typecnt = 1;		/* only standard time */
		sp->timecnt = 0;
		sp->ttis[0] = zttinfo;
		sp->ttis[0].tt_gmtoff = -stdoffset;
		sp->ttis[0].tt_isdst = 0;
		sp->ttis[0].tt_abbrind = 0;
	}
	sp->charcnt = stdlen + 1;
	if (dstlen != 0)
		sp->charcnt += dstlen + 1;
	if ((size_t) sp->charcnt > sizeof sp->chars)
		return -1;
	cp = sp->chars;
	(void) strncpy(cp, stdname, stdlen);
	cp += stdlen;
	*cp++ = '\0';
	if (dstlen != 0) {
		(void) strncpy(cp, dstname, dstlen);
		*(cp + dstlen) = '\0';
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testl %edx, %edx
je 0x2c12
movq %rbx, %rdi
callq 0x10b0
leaq (%rbx,%rax), %r12
movl $0x1ff, %r15d           # imm = 0x1FF
cmpq %r15, %rax
cmovbq %rax, %r15
movq $0x0, 0x8(%rsp)
leaq 0x2688(%rip), %rdi      # 0x524d
movq %r14, %rsi
xorl %edx, %edx
callq 0x22dd
movl %eax, %ebp
testl %eax, %eax
je 0x2bdc
movl $0x0, (%r14)
movzbl (%r12), %ecx
testl %ecx, %ecx
je 0x2c49
cmpl $0x3c, %ecx
jne 0x2c82
leaq 0x1(%r12), %rdx
xorl %r13d, %r13d
movzbl 0x1(%r12,%r13), %eax
testl %eax, %eax
je 0x2f23
cmpl $0x3e, %eax
je 0x2cde
incq %r13
jmp 0x2bf6
movzbl (%rbx), %eax
testl %eax, %eax
je 0x2cac
cmpl $0x3c, %eax
jne 0x2cb1
leaq 0x1(%rbx), %rcx
xorl %r15d, %r15d
movzbl 0x1(%rbx,%r15), %eax
testl %eax, %eax
je 0x2f23
cmpl $0x3e, %eax
je 0x2f5f
incq %r15
jmp 0x2c2d
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x4(%r14)
xorl %r13d, %r13d
movq %r13, 0x2a58(%r14)
xorl %eax, %eax
subq 0x8(%rsp), %rax
movq %rax, 0x2a48(%r14)
movq %r13, 0x2a50(%r14)
leal 0x1(%r15), %edx
xorl %r12d, %r12d
jmp 0x3047
movq %r12, %rax
leal -0x2e(%rcx), %edx
cmpb $-0x4, %dl
ja 0x2ca4
movsbl %cl, %edx
addl $-0x3a, %edx
cmpl $-0xb, %edx
ja 0x2ca4
movb 0x1(%rax), %cl
incq %rax
testb %cl, %cl
jne 0x2c85
xorl %ecx, %ecx
movq %rax, %r13
subq %r12, %r13
jmp 0x2ceb
movq %rbx, %rdi
jmp 0x2cd3
movq %rbx, %rdi
leal -0x2e(%rax), %ecx
cmpb $-0x4, %cl
ja 0x2cd3
movsbl %al, %ecx
addl $-0x3a, %ecx
cmpl $-0xb, %ecx
ja 0x2cd3
movb 0x1(%rdi), %al
incq %rdi
testb %al, %al
jne 0x2cb4
xorl %eax, %eax
movq %rdi, %r15
subq %rbx, %r15
jmp 0x2f6c
leaq (%r12,%r13), %rax
addq $0x2, %rax
movb (%rax), %cl
movq %rdx, %r12
cmpb $0x3b, %cl
ja 0x2f0d
movzbl %cl, %ecx
movabsq $0x800100000000001, %rdx # imm = 0x800100000000001
btq %rcx, %rdx
jae 0x2f0d
movq $-0xe10, %rcx           # imm = 0xF1F0
addq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rsp)
cmpb $0x0, (%rax)
leaq 0x2532(%rip), %rdi      # 0x5258
cmovneq %rax, %rdi
testl %ebp, %ebp
cmoveq %rax, %rdi
movzbl (%rdi), %eax
testl %eax, %eax
je 0x2f2d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x3b, %eax
je 0x2d4e
cmpl $0x2c, %eax
jne 0x30a7
incq %rdi
leaq 0x60(%rsp), %rsi
callq 0x373c
testq %rax, %rax
je 0x30a7
cmpb $0x2c, (%rax)
jne 0x30a7
incq %rax
leaq 0x48(%rsp), %rsi
movq %rax, %rdi
callq 0x373c
testq %rax, %rax
je 0x30a7
cmpb $0x0, (%rax)
jne 0x30a7
movq %rbx, 0x30(%rsp)
movl $0x2, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a58(%r14)
movups %xmm0, 0x2a68(%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
negq %rax
movq %rax, 0x2a48(%r14)
movl $0x1, 0x2a50(%r14)
leal 0x1(%r15), %eax
movl %eax, 0x1c(%rsp)
movl %eax, 0x2a54(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
negq %rax
movq %rax, 0x2a60(%r14)
xorl %ebx, %ebx
movl %ebx, 0x2a6c(%r14)
movq %r14, 0x28(%rsp)
movl %ebx, 0x4(%r14)
movl $0x7b2, %ebp            # imm = 0x7B2
xorl %r14d, %r14d
movq %r12, 0x20(%rsp)
movq %r14, %rdi
movl %ebp, %esi
leaq 0x60(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x38e1
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
leaq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rcx
callq 0x38e1
cmpq %rax, %r12
jle 0x2e49
movb $0x1, %dl
xorl %ecx, %ecx
movq %rax, %rsi
jmp 0x2e53
movb $0x1, %cl
xorl %edx, %edx
movq %r12, %rsi
movq %rax, %r12
movq 0x28(%rsp), %rdi
movq %rsi, 0x18(%rdi,%rbx,8)
movb %dl, 0x2598(%rdi,%rbx)
movq %r12, 0x20(%rdi,%rbx,8)
movb %cl, 0x2599(%rdi,%rbx)
movl 0x4(%rdi), %eax
leal 0x2(%rax), %ecx
movl %ecx, 0x4(%rdi)
testb $0x3, %bpl
je 0x2e88
xorl %edx, %edx
movq 0x20(%rsp), %r12
jmp 0x2ed4
movl %ebp, %ecx
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x25, %rdx
imull $0x64, %edx, %edx
movl $0x7b2, %esi            # imm = 0x7B2
subl %edx, %esi
addl %ebp, %esi
movl $0x1, %edx
cmpl $0x7b2, %esi            # imm = 0x7B2
movq 0x20(%rsp), %r12
jne 0x2ed4
shrq $0x27, %rcx
imull $0x190, %ecx, %ecx      # imm = 0x190
movl $0x7b2, %esi            # imm = 0x7B2
subl %ecx, %esi
addl %ebp, %esi
xorl %edx, %edx
cmpl $0x7b2, %esi            # imm = 0x7B2
sete %dl
leaq 0x2345(%rip), %rcx      # 0x5220
movslq (%rcx,%rdx,4), %rcx
imulq $0x15180, %rcx, %rcx    # imm = 0x15180
addq %rcx, %r14
incl %ebp
addq $0x2, %rbx
cmpl $0x4ad, %eax            # imm = 0x4AD
jl 0x2e10
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %rbx
movl 0x1c(%rsp), %edx
jmp 0x3047
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x370b
testq %rax, %rax
jne 0x2d1c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x30a7
movslq 0x4(%r14), %rax
testq %rax, %rax
jle 0x2f94
leaq 0x2a48(%r14), %rcx
xorl %edx, %edx
xorl %esi, %esi
movzbl 0x2598(%r14,%rsi), %edi
leaq (%rdi,%rdi,2), %rdi
cmpl $0x0, 0x8(%rcx,%rdi,8)
je 0x2f9b
incq %rsi
cmpq %rsi, %rax
jne 0x2f41
jmp 0x2fa4
leaq (%rbx,%r15), %rdi
addq $0x2, %rdi
movb (%rdi), %al
movq %rcx, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
je 0x30a7
leaq 0x8(%rsp), %rsi
callq 0x370b
movq %rax, %r12
testq %rax, %rax
jne 0x2bbe
jmp 0x30a7
movq 0x8(%rsp), %rsi
jmp 0x2ff7
leaq (%rcx,%rdi,8), %rsi
xorl %edx, %edx
subq (%rsi), %rdx
movq 0x8(%rsp), %rsi
testl %eax, %eax
jle 0x2ff7
xorl %edi, %edi
movzbl 0x2598(%r14,%rdi), %r8d
leaq (%r8,%r8,2), %r8
movb 0x8(%rcx,%r8,8), %r9b
movb %r9b, 0x2598(%r14,%rdi)
cmpl $0x0, 0x14(%rcx,%r8,8)
jne 0x2fdc
movq %rsi, %r9
subq %rdx, %r9
addq %r9, 0x18(%r14,%rdi,8)
leaq (%rcx,%r8,8), %r8
cmpl $0x0, 0x8(%r8)
jne 0x2fef
movq (%r8), %r8
xorl %edx, %edx
subq %r8, %rdx
incq %rdi
cmpq %rdi, %rax
jne 0x2faf
negq %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x2a68(%r14)
movups %xmm0, 0x2a58(%r14)
movq %rsi, 0x2a48(%r14)
xorl %eax, %eax
movq %rax, 0x2a50(%r14)
subq 0x10(%rsp), %rax
movq %rax, 0x2a60(%r14)
movl $0x1, 0x2a68(%r14)
leal 0x1(%r15), %edx
movl %edx, 0x2a6c(%r14)
movl $0x2, 0x8(%r14)
leal 0x1(%r13), %eax
xorl %ecx, %ecx
testq %r13, %r13
cmovel %ecx, %eax
addl %edx, %eax
movl %eax, 0xc(%r14)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x200, %eax            # imm = 0x200
ja 0x30a7
leaq 0x4248(%r14), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1070
movb $0x0, 0x4248(%r14,%r15)
testq %r13, %r13
je 0x30a5
leaq (%r14,%r15), %rbx
addq $0x4248, %rbx           # imm = 0x4248
leaq 0x1(%rbx), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1070
movb $0x0, 0x1(%rbx,%r13)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq