// File: /workspace/github_c_makefile_star2_O1/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 $0x68, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testl %edx, %edx
je 0x3d7a
movq %rbx, %rdi
callq 0x20c0
leaq (%rbx,%rax), %r12
movl $0x1ff, %r15d           # imm = 0x1FF
cmpq %r15, %rax
cmovbq %rax, %r15
movq $0x0, (%rsp)
leaq 0x251f(%rip), %rdi      # 0x624d
movq %r14, %rsi
xorl %edx, %edx
callq 0x3339
movl %eax, %ebp
testl %eax, %eax
je 0x3d45
movl $0x0, (%r14)
movzbl (%r12), %ecx
testl %ecx, %ecx
je 0x3db3
cmpl $0x3c, %ecx
jne 0x3e59
leaq 0x1(%r12), %rcx
xorl %r13d, %r13d
movzbl (%rcx,%r13), %eax
testl %eax, %eax
je 0x411e
cmpl $0x3e, %eax
je 0x3eac
incq %r13
jmp 0x3d5f
movzbl (%rbx), %eax
movq %rbx, %rdi
testl %eax, %eax
je 0x3ea1
cmpl $0x3c, %eax
jne 0x3e81
leaq 0x1(%rbx), %rax
xorl %r15d, %r15d
movzbl (%rax,%r15), %ecx
testl %ecx, %ecx
je 0x411e
cmpl $0x3e, %ecx
je 0x4128
incq %r15
jmp 0x3d98
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x4(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a48(%r14)
xorl %r13d, %r13d
movq %r13, 0x2a58(%r14)
xorl %eax, %eax
subq (%rsp), %rax
movq %rax, 0x2a48(%r14)
movq %r13, 0x2a50(%r14)
xorl %r12d, %r12d
leal 0x1(%r13), %eax
xorl %ecx, %ecx
testq %r13, %r13
cmovel %ecx, %eax
addl %r15d, %eax
incl %eax
movl %eax, 0xc(%r14)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x200, %eax            # imm = 0x200
ja 0x4224
leaq 0x4248(%r14), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2070
movb $0x0, 0x4248(%r14,%r15)
testq %r13, %r13
je 0x3e52
leaq (%r14,%r15), %rbx
addq $0x4248, %rbx           # imm = 0x4248
leaq 0x1(%rbx), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2070
movb $0x0, 0x1(%rbx,%r13)
xorl %ebp, %ebp
jmp 0x4224
movq %r12, %rax
leal -0x2e(%rcx), %edx
cmpb $-0x4, %dl
ja 0x3e79
movsbl %cl, %ecx
addl $-0x3a, %ecx
cmpl $-0xb, %ecx
ja 0x3e79
movb 0x1(%rax), %cl
incq %rax
testb %cl, %cl
jne 0x3e5c
movq %rax, %r13
subq %r12, %r13
jmp 0x3eb7
movq %rbx, %rdi
leal -0x2e(%rax), %ecx
cmpb $-0x4, %cl
ja 0x3ea1
movsbl %al, %eax
addl $-0x3a, %eax
cmpl $-0xb, %eax
ja 0x3ea1
movb 0x1(%rdi), %al
incq %rdi
testb %al, %al
jne 0x3e84
movq %rdi, %r15
subq %rbx, %r15
jmp 0x4133
leaq (%r12,%r13), %rax
addq $0x2, %rax
movq %rcx, %r12
movzbl (%rax), %ecx
cmpq $0x3b, %rcx
ja 0x4108
movabsq $0x800100000000001, %rdx # imm = 0x800100000000001
btq %rcx, %rdx
jae 0x4108
movq $-0xe10, %rcx           # imm = 0xF1F0
addq (%rsp), %rcx
movq %rcx, 0x8(%rsp)
cmpb $0x0, (%rax)
leaq 0x2366(%rip), %rdi      # 0x6258
cmovneq %rax, %rdi
testl %ebp, %ebp
cmoveq %rax, %rdi
movzbl (%rdi), %eax
cmpl $0x3b, %eax
je 0x3f0d
cmpl $0x2c, %eax
jne 0x40c8
incq %rdi
leaq 0x50(%rsp), %rsi
callq 0x48a7
testq %rax, %rax
je 0x411e
cmpb $0x2c, (%rax)
jne 0x411e
incq %rax
leaq 0x38(%rsp), %rsi
movq %rax, %rdi
callq 0x48a7
testq %rax, %rax
je 0x411e
cmpb $0x0, (%rax)
jne 0x411e
movq %r12, 0x10(%rsp)
movq %rbx, 0x20(%rsp)
movl $0x2, 0x8(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x2a48(%r14)
movups %xmm0, 0x2a58(%r14)
movups %xmm0, 0x2a68(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
negq %rax
movq %rax, 0x2a48(%r14)
movl $0x1, 0x2a50(%r14)
movq %r15, 0x18(%rsp)
leal 0x1(%r15), %eax
movl %eax, 0x2a54(%r14)
movq (%rsp), %rax
movq %rax, 0x28(%rsp)
negq %rax
movq %rax, 0x2a60(%r14)
movq $0x0, 0x2a68(%r14)
movl $0x0, 0x4(%r14)
movl $0x7b2, %ebp            # imm = 0x7B2
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %r12, %rdi
movl %ebp, %esi
leaq 0x50(%rsp), %rdx
movq 0x28(%rsp), %rcx
callq 0x4a6a
movq %r14, %r15
movq %rax, %r14
movq %r12, %rdi
movl %ebp, %esi
leaq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0x4a6a
cmpq %rax, %r14
movq %rax, %rcx
cmovlq %r14, %rcx
cmovgq %r14, %rax
movq %r15, %r14
movq %rcx, 0x18(%r15,%rbx,8)
setg 0x2598(%r15,%rbx)
movq %rax, 0x20(%r15,%rbx,8)
setle 0x2599(%r15,%rbx)
addl $0x2, 0x4(%r15)
testb $0x3, %bpl
je 0x4044
xorl %ecx, %ecx
jmp 0x408b
movl %ebp, %eax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rcx
shrq $0x25, %rcx
imull $0x64, %ecx, %ecx
movl $0x7b2, %edx            # imm = 0x7B2
subl %ecx, %edx
addl %ebp, %edx
movl $0x1, %ecx
cmpl $0x7b2, %edx            # imm = 0x7B2
jne 0x408b
shrq $0x27, %rax
imull $0x190, %eax, %eax      # imm = 0x190
movl $0x7b2, %edx            # imm = 0x7B2
subl %eax, %edx
addl %ebp, %edx
xorl %ecx, %ecx
cmpl $0x7b2, %edx            # imm = 0x7B2
sete %cl
leaq 0x218e(%rip), %rax      # 0x6220
movslq (%rax,%rcx,4), %rax
imulq $0x15180, %rax, %rax    # imm = 0x15180
addq %rax, %r12
incl %ebp
addq $0x2, %rbx
cmpl $0x4af, 0x4(%r14)       # imm = 0x4AF
jl 0x3fda
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r12
jmp 0x3ded
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
jne 0x4224
movslq 0x4(%r14), %rcx
testq %rcx, %rcx
jle 0x415a
leaq 0x2a48(%r14), %rsi
xorl %edx, %edx
xorl %edi, %edi
movzbl 0x2598(%r14,%rdi), %r8d
leaq (%r8,%r8,2), %r8
cmpl $0x0, 0x8(%rsi,%r8,8)
je 0x415e
incq %rdi
cmpq %rdi, %rcx
jne 0x40e9
jmp 0x4167
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x4876
testq %rax, %rax
jne 0x3ee8
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4224
leaq (%rbx,%r15), %rdi
addq $0x2, %rdi
movq %rax, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpb $0x0, (%rdi)
je 0x4224
movq %rsp, %rsi
callq 0x4876
movq %rax, %r12
testq %rax, %rax
jne 0x3d27
jmp 0x4224
xorl %edx, %edx
jmp 0x4167
leaq (%rsi,%r8,8), %rsi
xorl %edx, %edx
subq (%rsi), %rdx
testl %ecx, %ecx
jle 0x41c1
leaq 0x2a48(%r14), %rsi
movq (%rsp), %rdi
xorl %r8d, %r8d
movzbl 0x2598(%r14,%r8), %r9d
leaq (%r9,%r9,2), %r9
movb 0x8(%rsi,%r9,8), %r10b
movb %r10b, 0x2598(%r14,%r8)
cmpl $0x0, 0x14(%rsi,%r9,8)
jne 0x41a6
movq %rdi, %r10
subq %rdx, %r10
addq %r10, 0x18(%r14,%r8,8)
leaq (%rsi,%r9,8), %r9
cmpl $0x0, 0x8(%r9)
jne 0x41b9
movq (%r9), %r9
xorl %edx, %edx
subq %r9, %rdx
incq %r8
cmpq %r8, %rcx
jne 0x4179
xorps %xmm0, %xmm0
movups %xmm0, 0x2a68(%r14)
movups %xmm0, 0x2a58(%r14)
movups %xmm0, 0x2a48(%r14)
xorl %ecx, %ecx
xorl %edx, %edx
subq (%rsp), %rdx
movq %rdx, 0x2a48(%r14)
movq %rcx, 0x2a50(%r14)
subq 0x8(%rsp), %rcx
leal 0x1(%r15), %edx
movq %rcx, 0x2a60(%r14)
movl $0x1, 0x2a68(%r14)
movl %edx, 0x2a6c(%r14)
movl $0x2, 0x8(%r14)
testb %al, %al
je 0x3ded
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq