// File: /workspace/github_c_makefile_star2_O2/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 $0x88, %rsp
movq %rsi, %r14
movq %rdi, %r15
pushq $-0x1
popq %rbp
testl %edx, %edx
je 0x292f
movq %r15, %rdi
callq 0x10b0
movl $0x1ff, %r12d           # imm = 0x1FF
cmpq %r12, %rax
cmovbq %rax, %r12
leaq (%r15,%rax), %r13
andq $0x0, (%rsp)
leaq 0x2968(%rip), %rdi      # 0x524d
movq %r14, %rsi
xorl %edx, %edx
callq 0x2174
movl %eax, %ebx
testl %eax, %eax
je 0x28f9
andl $0x0, (%r14)
movzbl (%r13), %eax
testl %eax, %eax
je 0x295b
cmpl $0x3c, %eax
jne 0x2995
incq %r13
movq %r13, %rdi
callq 0x33b0
cmpb $0x3e, (%rax)
jne 0x2d49
movq %rax, %rcx
subq %r13, %rcx
movq %rcx, 0x10(%rsp)
incq %rax
jmp 0x29a8
cmpb $0x3c, (%r15)
jne 0x2bbe
incq %r15
movq %r15, %rdi
callq 0x33b0
cmpb $0x3e, (%rax)
jne 0x2d49
movq %rax, %r12
subq %r15, %r12
incq %rax
jmp 0x2bcc
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x4(%r14)
andq $0x0, 0x2a58(%r14)
xorl %eax, %eax
subq (%rsp), %rax
movq %rax, 0x2a48(%r14)
andq $0x0, 0x2a50(%r14)
xorl %ebx, %ebx
leal 0x1(%r12), %edx
xorl %r13d, %r13d
jmp 0x2cec
movq %r13, %rdi
callq 0x33c5
movq %rax, %rcx
subq %r13, %rcx
movq %rcx, 0x10(%rsp)
movzbl (%rax), %ecx
cmpq $0x3b, %rcx
ja 0x2bf1
movabsq $0x800100000000001, %rdx # imm = 0x800100000000001
btq %rcx, %rdx
jae 0x2bf1
movq $-0xe10, %rdx           # imm = 0xF1F0
addq (%rsp), %rdx
movq %rdx, 0x18(%rsp)
testb %cl, %cl
leaq 0x2876(%rip), %rdi      # 0x5258
cmovneq %rax, %rdi
testl %ebx, %ebx
cmoveq %rax, %rdi
movzbl (%rdi), %eax
testl %eax, %eax
je 0x2c0e
cmpl $0x3b, %eax
je 0x2a05
cmpl $0x2c, %eax
jne 0x2d49
incq %rdi
leaq 0x70(%rsp), %rsi
callq 0x3416
testq %rax, %rax
je 0x2d49
cmpb $0x2c, (%rax)
jne 0x2d49
incq %rax
leaq 0x58(%rsp), %rsi
movq %rax, %rdi
callq 0x3416
testq %rax, %rax
je 0x2d49
cmpb $0x0, (%rax)
jne 0x2d49
movq %r13, 0x28(%rsp)
movq %r15, 0x38(%rsp)
movl $0x2, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a58(%r14)
movups %xmm0, 0x2a68(%r14)
movq 0x18(%rsp), %rax
movq %rax, 0x48(%rsp)
negq %rax
movq %rax, 0x2a48(%r14)
movl $0x1, 0x2a50(%r14)
movq %r12, 0x30(%rsp)
leal 0x1(%r12), %eax
movl %eax, 0x20(%rsp)
movl %eax, 0x2a54(%r14)
movq (%rsp), %rax
movq %rax, 0x40(%rsp)
negq %rax
movq %rax, 0x2a60(%r14)
andl $0x0, 0x2a6c(%r14)
andl $0x0, 0x4(%r14)
movl $0x7b2, %ebx            # imm = 0x7B2
xorl %ebp, %ebp
movl $0xfffff84e, %esi       # imm = 0xFFFFF84E
xorl %ecx, %ecx
xorl %r15d, %r15d
movl %ebx, %eax
xorl %edx, %edx
movl $0x190, %edi            # imm = 0x190
divl %edi
movl %eax, %r9d
movl %ebx, %eax
xorl %edx, %edx
pushq $0x64
popq %rdi
divl %edi
cmpl $0x4ae, %ecx            # imm = 0x4AE
jg 0x2d5d
movl %eax, %r13d
movl %r9d, 0x24(%rsp)
movl %esi, 0xc(%rsp)
movq %r15, %rdi
movl %ebx, %esi
leaq 0x70(%rsp), %rdx
movq 0x40(%rsp), %rcx
callq 0x34d4
movq %rax, %r12
movq %r15, 0x50(%rsp)
movq %r15, %rdi
movl %ebx, %esi
leaq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rcx
callq 0x34d4
cmpq %rax, %r12
jle 0x2b3d
movb $0x1, %dl
xorl %ecx, %ecx
movq %rax, %rsi
jmp 0x2b47
movb $0x1, %cl
xorl %edx, %edx
movq %r12, %rsi
movq %rax, %r12
movq %rsi, 0x18(%r14,%rbp,8)
movb %dl, 0x2598(%r14,%rbp)
movq %r12, 0x20(%r14,%rbp,8)
movb %cl, 0x2599(%r14,%rbp)
movl 0x4(%r14), %ecx
addl $0x2, %ecx
movl %ecx, 0x4(%r14)
testb $0x3, %bl
movq 0x50(%rsp), %r15
je 0x2b7e
xorl %eax, %eax
movl 0xc(%rsp), %esi
jmp 0x2b9c
imull $0x64, %r13d, %edx
pushq $0x1
popq %rax
movl 0xc(%rsp), %esi
addl %esi, %edx
jne 0x2b9c
imull $0x190, 0x24(%rsp), %edx # imm = 0x190
xorl %eax, %eax
addl %esi, %edx
sete %al
leaq 0x267d(%rip), %rdx      # 0x5220
movslq (%rdx,%rax,4), %rax
imulq $0x15180, %rax, %rax    # imm = 0x15180
addq %rax, %r15
incl %ebx
addq $0x2, %rbp
decl %esi
jmp 0x2ad0
movq %r15, %rdi
callq 0x33c5
movq %rax, %r12
subq %r15, %r12
cmpb $0x0, (%rax)
je 0x2d49
movq %rsp, %rsi
movq %rax, %rdi
callq 0x33e5
movq %rax, %r13
testq %rax, %rax
jne 0x28de
jmp 0x2d49
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x33e5
testq %rax, %rax
je 0x2d49
movb (%rax), %cl
jmp 0x29d9
movl 0x4(%r14), %eax
leaq 0x2a48(%r14), %rcx
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
xorl %esi, %esi
movq 0x10(%rsp), %rbx
cmpq %rsi, %rax
je 0x2c4b
movzbl 0x2598(%r14,%rsi), %edi
imulq $0x18, %rdi, %rdi
incq %rsi
cmpl $0x0, 0x8(%rcx,%rdi)
jne 0x2c27
addq %rcx, %rdi
xorl %edx, %edx
subq (%rdi), %rdx
movq (%rsp), %rsi
xorl %edi, %edi
cmpq %rdi, %rax
je 0x2c9a
movzbl 0x2598(%r14,%rdi), %r8d
imulq $0x18, %r8, %r8
movb 0x8(%rcx,%r8), %r9b
movb %r9b, 0x2598(%r14,%rdi)
cmpl $0x0, 0x14(%rcx,%r8)
jne 0x2c83
movq %rsi, %r9
subq %rdx, %r9
addq %r9, 0x18(%r14,%rdi,8)
addq %rcx, %r8
cmpl $0x0, 0x8(%r8)
jne 0x2c95
movq (%r8), %r8
xorl %edx, %edx
subq %r8, %rdx
incq %rdi
jmp 0x2c51
negq %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x2a68(%r14)
movups %xmm0, 0x2a58(%r14)
movq %rsi, 0x2a48(%r14)
andq $0x0, 0x2a50(%r14)
xorl %eax, %eax
subq 0x18(%rsp), %rax
movq %rax, 0x2a60(%r14)
movl $0x1, 0x2a68(%r14)
leal 0x1(%r12), %edx
movl %edx, 0x2a6c(%r14)
movl $0x2, 0x8(%r14)
leal 0x1(%rbx), %eax
xorl %ecx, %ecx
testq %rbx, %rbx
cmovel %ecx, %eax
addl %edx, %eax
movl %eax, 0xc(%r14)
cmpl $0x200, %eax            # imm = 0x200
ja 0x2d49
leaq 0x4248(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1070
movb $0x0, 0x4248(%r14,%r12)
testq %rbx, %rbx
je 0x2d47
movq %rbx, %r15
leaq (%r14,%r12), %rbx
addq $0x4248, %rbx           # imm = 0x4248
leaq 0x1(%rbx), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1070
movb $0x0, 0x1(%rbx,%r15)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rbp
movq 0x38(%rsp), %r15
movq 0x30(%rsp), %r12
movq 0x28(%rsp), %r13
movq 0x10(%rsp), %rbx
movl 0x20(%rsp), %edx
jmp 0x2cec