// File: /workspace/github_c_makefile_star2_O2/lyda[P]tz/localtime.c
// Function: tzload
static int
tzload(name, sp, doextend)
register const char *		name;
register struct state * const	sp;
register const int		doextend;
{
	register const char *		p;
	register int			i;
	register int			fid;
	register int			stored;
	register int			nread;
	typedef union {
		struct tzhead	tzhead;
		char		buf[2 * sizeof(struct tzhead) +
					2 * sizeof *sp +
					4 * TZ_MAX_TIMES];
	} u_t;
#ifdef ALL_STATE
	register u_t *			up;

	up = (u_t *) calloc(1, sizeof *up);
	if (up == NULL)
		return -1;
#else /* !defined ALL_STATE */
	u_t				u;
	register u_t * const		up = &u;
#endif /* !defined ALL_STATE */

	sp->goback = sp->goahead = FALSE;
	if (name == NULL && (name = TZDEFAULT) == NULL)
		goto oops;
	{
		register int	doaccess;
		/*
		** Section 4.9.1 of the C standard says that
		** "FILENAME_MAX expands to an integral constant expression
		** that is the size needed for an array of char large enough
		** to hold the longest file name string that the implementation
		** guarantees can be opened."
		*/
		char		fullname[FILENAME_MAX + 1];

		if (name[0] == ':')
			++name;
		doaccess = name[0] == '/';
		if (!doaccess) {
			if ((p = TZDIR) == NULL)
				goto oops;
			if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
				goto oops;
			(void) strcpy(fullname, p);
			(void) strcat(fullname, "/");
			(void) strcat(fullname, name);
			/*
			** Set doaccess if '.' (as in "../") shows up in name.
			*/
			if (strchr(name, '.') != NULL)
				doaccess = TRUE;
			name = fullname;
		}
		if (doaccess && access(name, R_OK) != 0)
			goto oops;
		if ((fid = open(name, OPEN_MODE)) == -1)
			goto oops;
	}
	nread = read(fid, up->buf, sizeof up->buf);
	if (close(fid) < 0 || nread <= 0)
		goto oops;
	for (stored = 4; stored <= 8; stored *= 2) {
		int		ttisstdcnt;
		int		ttisgmtcnt;

		ttisstdcnt = (int) detzcode(up->tzhead.tzh_ttisstdcnt);
		ttisgmtcnt = (int) detzcode(up->tzhead.tzh_ttisgmtcnt);
		sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt);
		sp->timecnt = (int) detzcode(up->tzhead.tzh_timecnt);
		sp->typecnt = (int) detzcode(up->tzhead.tzh_typecnt);
		sp->charcnt = (int) detzcode(up->tzhead.tzh_charcnt);
		p = up->tzhead.tzh_charcnt + sizeof up->tzhead.tzh_charcnt;
		if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS ||
			sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES ||
			sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES ||
			sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS ||
			(ttisstdcnt != sp->typecnt && ttisstdcnt != 0) ||
			(ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0))
				goto oops;
		if (nread - (p - up->buf) <
			sp->timecnt * stored +		/* ats */
			sp->timecnt +			/* types */
			sp->typecnt * 6 +		/* ttinfos */
			sp->charcnt +			/* chars */
			sp->leapcnt * (stored + 4) +	/* lsinfos */
			ttisstdcnt +			/* ttisstds */
			ttisgmtcnt)			/* ttisgmts */
				goto oops;
		for (i = 0; i < sp->timecnt; ++i) {
			sp->ats[i] = (stored == 4) ?
				detzcode(p) : detzcode64(p);
			p += stored;
		}
		for (i = 0; i < sp->timecnt; ++i) {
			sp->types[i] = (unsigned char) *p++;
			if (sp->types[i] >= sp->typecnt)
				goto oops;
		}
		for (i = 0; i < sp->typecnt; ++i) {
			register struct ttinfo *	ttisp;

			ttisp = &sp->ttis[i];
			ttisp->tt_gmtoff = detzcode(p);
			p += 4;
			ttisp->tt_isdst = (unsigned char) *p++;
			if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1)
				goto oops;
			ttisp->tt_abbrind = (unsigned char) *p++;
			if (ttisp->tt_abbrind < 0 ||
				ttisp->tt_abbrind > sp->charcnt)
					goto oops;
		}
		for (i = 0; i < sp->charcnt; ++i)
			sp->chars[i] = *p++;
		sp->chars[i] = '\0';	/* ensure '\0' at end */
		for (i = 0; i < sp->leapcnt; ++i) {
			register struct lsinfo *	lsisp;

			lsisp = &sp->lsis[i];
			lsisp->ls_trans = (stored == 4) ?
				detzcode(p) : detzcode64(p);
			p += stored;
			lsisp->ls_corr = detzcode(p);
			p += 4;
		}
		for (i = 0; i < sp->typecnt; ++i) {
			register struct ttinfo *	ttisp;

			ttisp = &sp->ttis[i];
			if (ttisstdcnt == 0)
				ttisp->tt_ttisstd = FALSE;
			else {
				ttisp->tt_ttisstd = *p++;
				if (ttisp->tt_ttisstd != TRUE &&
					ttisp->tt_ttisstd != FALSE)
						goto oops;
			}
		}
		for (i = 0; i < sp->typecnt; ++i) {
			register struct ttinfo *	ttisp;

			ttisp = &sp->ttis[i];
			if (ttisgmtcnt == 0)
				ttisp->tt_ttisgmt = FALSE;
			else {
				ttisp->tt_ttisgmt = *p++;
				if (ttisp->tt_ttisgmt != TRUE &&
					ttisp->tt_ttisgmt != FALSE)
						goto oops;
			}
		}
		/*
		** Out-of-sort ats should mean we're running on a
		** signed time_t system but using a data file with
		** unsigned values (or vice versa).
		*/
		for (i = 0; i < sp->timecnt - 2; ++i)
			if (sp->ats[i] > sp->ats[i + 1]) {
				++i;
				if (TYPE_SIGNED(time_t)) {
					/*
					** Ignore the end (easy).
					*/
					sp->timecnt = i;
				} else {
					/*
					** Ignore the beginning (harder).
					*/
					register int	j;

					for (j = 0; j + i < sp->timecnt; ++j) {
						sp->ats[j] = sp->ats[j + i];
						sp->types[j] = sp->types[j + i];
					}
					sp->timecnt = j;
				}
				break;
			}
		/*
		** If this is an old file, we're done.
		*/
		if (up->tzhead.tzh_version[0] == '\0')
			break;
		nread -= p - up->buf;
		for (i = 0; i < nread; ++i)
			up->buf[i] = p[i];
		/*
		** If this is a narrow integer time_t system, we're done.
		*/
		if (stored >= (int) sizeof(time_t) && TYPE_INTEGRAL(time_t))
			break;
	}
	if (doextend && nread > 2 &&
		up->buf[0] == '\n' && up->buf[nread - 1] == '\n' &&
		sp->typecnt + 2 <= TZ_MAX_TYPES) {
			struct state	ts;
			register int	result;

			up->buf[nread - 1] = '\0';
			result = tzparse(&up->buf[1], &ts, FALSE);
			if (result == 0 && ts.typecnt == 2 &&
				sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) {
					for (i = 0; i < 2; ++i)
						ts.ttis[i].tt_abbrind +=
							sp->charcnt;
					for (i = 0; i < ts.charcnt; ++i)
						sp->chars[sp->charcnt++] =
							ts.chars[i];
					i = 0;
					while (i < ts.timecnt &&
						ts.ats[i] <=
						sp->ats[sp->timecnt - 1])
							++i;
					while (i < ts.timecnt &&
					    sp->timecnt < TZ_MAX_TIMES) {
						sp->ats[sp->timecnt] =
							ts.ats[i];
						sp->types[sp->timecnt] =
							sp->typecnt +
							ts.types[i];
						++sp->timecnt;
						++i;
					}
					sp->ttis[sp->typecnt++] = ts.ttis[0];
					sp->ttis[sp->typecnt++] = ts.ttis[1];
			}
	}
	if (sp->timecnt > 1) {
		for (i = 1; i < sp->timecnt; ++i)
			if (typesequiv(sp, sp->types[i], sp->types[0]) &&
				differ_by_repeat(sp->ats[i], sp->ats[0])) {
					sp->goback = TRUE;
					break;
				}
		for (i = sp->timecnt - 2; i >= 0; --i)
			if (typesequiv(sp, sp->types[sp->timecnt - 1],
				sp->types[i]) &&
				differ_by_repeat(sp->ats[sp->timecnt - 1],
				sp->ats[i])) {
					sp->goahead = TRUE;
					break;
		}
	}
#ifdef ALL_STATE
	(void) free((void *) up);
#endif /* defined ALL_STATE */
	return 0;
oops:
#ifdef ALL_STATE
	(void) free((void *) up);
#endif /* defined ALL_STATE */
	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe9a8, %rsp           # imm = 0xE9A8
movl %edx, %r13d
movq %rsi, %rbx
andq $0x0, 0x10(%rsi)
testq %rdi, %rdi
leaq 0x3091(%rip), %rax      # 0x522b
cmovneq %rdi, %rax
xorl %ecx, %ecx
cmpb $0x3a, (%rax)
sete %cl
leaq (%rax,%rcx), %r14
cmpb $0x2f, (%rax,%rcx)
pushq $-0x1
popq %r12
je 0x221f
movq %r14, %rdi
callq 0x10b0
addq $-0xfe9, %rax           # imm = 0xF017
cmpq $-0x1001, %rax          # imm = 0xEFFF
jb 0x264d
movups 0x3060(%rip), %xmm0     # 0x5235
leaq 0x47c0(%rsp), %r15
movaps %xmm0, (%r15)
movabsq $0x6f666e69656e6f, %rax # imm = 0x6F666E69656E6F
movq %rax, 0x10(%r15)
movq %r15, %rdi
callq 0x10b0
movw $0x2f, 0x47c0(%rsp,%rax)
movq %r15, %rdi
movq %r14, %rsi
callq 0x11f0
pushq $0x2e
popq %rsi
movq %r14, %rdi
callq 0x10d0
movq %r15, %r14
testq %rax, %rax
je 0x2232
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x11c0
testl %eax, %eax
jne 0x264d
movq %r14, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x11b0
cmpl $-0x1, %eax
je 0x264d
movl %eax, %ebp
leaq 0x47c0(%rsp), %rsi
movl $0xa1e8, %edx           # imm = 0xA1E8
movl %eax, %edi
callq 0x1110
movq %rax, %r14
movl %ebp, %edi
callq 0x10f0
testl %eax, %eax
sets %al
testl %r14d, %r14d
setle %cl
orb %al, %cl
jne 0x264d
leaq 0x47d8(%rsp), %rdi
leaq 0x47d4(%rsp), %r8
leaq 0x2a48(%rbx), %rbp
pushq $0x4
popq %rax
movq %rbx, (%rsp)
movq %rbp, 0x28(%rsp)
cmpl $0x8, %eax
ja 0x266a
movl %r13d, %r15d
movq %r14, %r13
movq %rax, 0x10(%rsp)
movq %r8, %r14
callq 0x32cf
movq %rax, 0x18(%rsp)
movq %r14, %rdi
callq 0x32cf
movq %rax, 0x40(%rsp)
leaq 0x47dc(%rsp), %rdi
callq 0x32cf
movq %rax, %r14
movl %r14d, (%rbx)
leaq 0x47e0(%rsp), %rdi
callq 0x32cf
movq %rax, 0x30(%rsp)
movl %eax, 0x4(%rbx)
leaq 0x47e4(%rsp), %rdi
callq 0x32cf
movq %rax, %rbp
movl %ebp, 0x8(%rbx)
leaq 0x47e8(%rsp), %rdi
callq 0x32cf
movq %rax, 0x8(%rsp)
movl %eax, 0xc(%rbx)
movq %r14, 0x38(%rsp)
cmpl $0x32, %r14d
ja 0x264d
leal -0x101(%rbp), %eax
cmpl $0xffffff00, %eax       # imm = 0xFFFFFF00
jb 0x264d
movq 0x30(%rsp), %r8
cmpl $0x4b0, %r8d            # imm = 0x4B0
ja 0x264d
cmpl $0x32, 0x8(%rsp)
ja 0x264d
movq 0x18(%rsp), %rcx
cmpl %ecx, %ebp
setne %al
testl %ecx, %ecx
setne %cl
testb %al, %cl
jne 0x264d
movq 0x40(%rsp), %rsi
cmpl %esi, %ebp
setne %al
testl %esi, %esi
setne %cl
testb %al, %cl
jne 0x264d
movslq %r13d, %rax
addq $-0x2c, %rax
movq 0x10(%rsp), %rdi
movl %edi, %ecx
orl $0x1, %ecx
imull %r8d, %ecx
imull $0x6, %ebp, %edx
addl %ecx, %edx
leal 0x4(%rdi), %ecx
imull 0x38(%rsp), %ecx
movq 0x18(%rsp), %r9
addl %r9d, %esi
addl %esi, %ecx
addl %edx, %ecx
addl 0x8(%rsp), %ecx
cmpq %rcx, %rax
jl 0x264d
movq %r13, 0x50(%rsp)
movl %r15d, 0x24(%rsp)
movl %edi, %r12d
movl %r8d, %r13d
andl $0x7ff, %r13d           # imm = 0x7FF
leaq 0x47ec(%rsp), %r14
leaq (%r14,%r12), %r15
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x241b
cmpl $0x4, %edi
jne 0x23fa
movq %r14, %rdi
callq 0x32cf
jmp 0x2402
movq %r14, %rdi
callq 0x32f1
movq (%rsp), %rcx
movq %rax, 0x18(%rcx,%rbx,8)
addq %r12, %r14
incq %rbx
addq %r12, %r15
movq 0x10(%rsp), %rdi
jmp 0x23e6
xorl %eax, %eax
movq (%rsp), %rdx
cmpq %rax, %r13
je 0x2442
movzbl (%r14,%rax), %ecx
movb %cl, 0x2598(%rdx,%rax)
cmpl %ecx, %ebp
jle 0x2649
incq %rax
incq %r15
jmp 0x2421
movl %ebp, %ecx
addq %rax, %r14
movq %rcx, 0x48(%rsp)
imulq $0x6, %rcx, %rbx
xorl %r13d, %r13d
movq 0x8(%rsp), %rbp
cmpq %r13, %rbx
je 0x24aa
movq %r14, %rdi
callq 0x32cf
movq (%rsp), %rcx
movq %rax, 0x2a48(%rcx,%r13,4)
movzbl 0x4(%r14), %eax
movl %eax, 0x2a50(%rcx,%r13,4)
cmpl $0x1, %eax
ja 0x2649
movzbl 0x5(%r14), %eax
movl %eax, 0x2a54(%rcx,%r13,4)
cmpl %eax, %ebp
jl 0x2649
addq $0x6, %r14
addq $0x6, %r13
addq $0x6, %r15
jmp 0x2458
andl $0x3f, %ebp
xorl %eax, %eax
movq (%rsp), %rbx
cmpq %rax, %rbp
je 0x24cb
movb (%r14,%rax), %cl
movb %cl, 0x4248(%rbx,%rax)
incq %rax
incq %r15
jmp 0x24b3
movb $0x0, 0x4248(%rbx,%rbp)
movq 0x38(%rsp), %r13
andl $0x3f, %r13d
addq %rax, %r14
shll $0x4, %r13d
leaq 0x4(%r12), %rax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
cmpq %rbp, %r13
movq 0x10(%rsp), %rax
je 0x2537
movq %r14, %rdi
cmpl $0x4, %eax
jne 0x2508
callq 0x32cf
jmp 0x250d
callq 0x32f1
movq %rax, 0x4448(%rbx,%rbp)
movq %r15, %rdi
callq 0x32cf
movq %rax, 0x4450(%rbx,%rbp)
addq %r12, %r14
addq $0x4, %r14
addq $0x10, %rbp
addq 0x8(%rsp), %r15
jmp 0x24ef
imulq $0x18, 0x48(%rsp), %rax
xorl %ecx, %ecx
pushq $-0x1
popq %r12
movl 0x24(%rsp), %r13d
movq 0x50(%rsp), %rdi
leaq 0x47d4(%rsp), %r8
cmpq %rcx, %rax
je 0x2588
cmpl $0x0, 0x18(%rsp)
je 0x257a
movsbl (%r14), %edx
movl %edx, 0x2a58(%rbx,%rcx)
cmpl $0x1, %edx
ja 0x264d
incq %r14
jmp 0x2582
andl $0x0, 0x2a58(%rbx,%rcx)
addq $0x18, %rcx
jmp 0x2555
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x25bd
cmpl $0x0, 0x40(%rsp)
je 0x25af
movsbl (%r14), %edx
movl %edx, 0x2a5c(%rbx,%rcx)
cmpl $0x1, %edx
ja 0x264d
incq %r14
jmp 0x25b7
andl $0x0, 0x2a5c(%rbx,%rcx)
addq $0x18, %rcx
jmp 0x258a
movq 0x30(%rsp), %rcx
cmpl $0x3, %ecx
pushq $0x2
popq %rax
cmovgel %ecx, %eax
addl $-0x2, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x25eb
movq 0x18(%rbx,%rcx,8), %rsi
leaq 0x1(%rcx), %rdx
cmpq 0x20(%rbx,%rcx,8), %rsi
movq %rdx, %rcx
jle 0x25d0
movl %edx, 0x4(%rbx)
cmpb $0x0, 0x47c4(%rsp)
je 0x2662
leaq 0x47c0(%rsp), %rax
subl %r14d, %eax
addl %eax, %edi
testl %edi, %edi
movl $0x0, %eax
movq %rdi, %rsi
cmovgl %edi, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x2626
movb (%r14,%rcx), %dl
movb %dl, 0x47c0(%rsp,%rcx)
incq %rcx
jmp 0x2611
movq 0x10(%rsp), %rcx
leal (%rcx,%rcx), %eax
cmpl $0x8, %ecx
movq 0x28(%rsp), %rbp
leaq 0x47d8(%rsp), %rdi
movq %rsi, %r14
jne 0x229d
jmp 0x266a
pushq $-0x1
popq %r12
movl %r12d, %eax
addq $0xe9a8, %rsp           # imm = 0xE9A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %rbp
movq %rdi, %r14
testl %r13d, %r13d
je 0x27e8
cmpl $0x3, %r14d
jl 0x27e8
cmpb $0xa, 0x47c0(%rsp)
jne 0x27e8
decl %r14d
cmpb $0xa, 0x47c0(%rsp,%r14)
jne 0x27e8
cmpl $0xfe, 0x8(%rbx)
jg 0x27e8
movb $0x0, 0x47c0(%rsp,%r14)
leaq 0x47c1(%rsp), %rdi
leaq 0x58(%rsp), %rsi
xorl %edx, %edx
callq 0x28a2
testl %eax, %eax
jne 0x27e8
cmpl $0x2, 0x60(%rsp)
jne 0x27e8
movl 0xc(%rbx), %edx
movl 0x64(%rsp), %ecx
leal (%rcx,%rdx), %eax
cmpl $0x32, %eax
jg 0x27e8
leaq 0x2aa0(%rsp), %rax
xorl %esi, %esi
cmpq $0x30, %rsi
je 0x270a
addl %edx, 0x2aac(%rsp,%rsi)
addq $0x18, %rsi
jmp 0x26f7
xorl %edx, %edx
testl %ecx, %ecx
cmovlel %edx, %ecx
movq (%rsp), %rbx
cmpq %rdx, %rcx
je 0x273b
movb 0x42a0(%rsp,%rdx), %sil
movslq 0xc(%rbx), %rdi
leal 0x1(%rdi), %r8d
movl %r8d, 0xc(%rbx)
movb %sil, 0x4248(%rbx,%rdi)
incq %rdx
jmp 0x2715
movslq 0x5c(%rsp), %rcx
xorl %esi, %esi
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
cmpq %rsi, %rdx
je 0x279c
movq 0x70(%rsp,%rsi,8), %rdi
movslq 0x4(%rbx), %r8
cmpq 0x10(%rbx,%r8,8), %rdi
jg 0x2766
incq %rsi
jmp 0x274c
movq %rsi, %rdx
jmp 0x279c
movslq 0x4(%rbx), %rsi
cmpq $0x4af, %rsi            # imm = 0x4AF
jg 0x27a1
movq 0x70(%rsp,%rdx,8), %rdi
movq %rdi, 0x18(%rbx,%rsi,8)
movb 0x25f0(%rsp,%rdx), %dil
addb 0x8(%rbx), %dil
movb %dil, 0x2598(%rbx,%rsi)
incl 0x4(%rbx)
incq %rdx
cmpq %rcx, %rdx
jl 0x276b
movslq 0x8(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x8(%rbx)
imulq $0x18, %rcx, %rcx
movq 0x10(%rax), %rdx
movq %rdx, 0x10(%rbp,%rcx)
movups (%rax), %xmm0
movups %xmm0, (%rbp,%rcx)
movslq 0x8(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x8(%rbx)
imulq $0x18, %rax, %rax
movq 0x2ac8(%rsp), %rcx
movq %rcx, 0x10(%rbp,%rax)
movups 0x2ab8(%rsp), %xmm0
movups %xmm0, (%rbp,%rax)
movslq 0x4(%rbx), %r14
xorl %r12d, %r12d
cmpq $0x2, %r14
jl 0x264d
movabsq $0x2f0605980, %r15      # imm = 0x2F0605980
leaq -0x1(%r14), %rbx
xorl %r12d, %r12d
movq (%rsp), %r13
cmpq %r12, %rbx
je 0x284b
movzbl 0x2599(%r13,%r12), %esi
movzbl 0x2598(%r13), %edx
movq %r13, %rdi
callq 0x3313
testl %eax, %eax
je 0x283e
movq 0x20(%r13,%r12,8), %rax
subq 0x18(%r13), %rax
cmpq %r15, %rax
je 0x2843
incq %r12
jmp 0x280e
movl $0x1, 0x10(%r13)
leal -0x2(%r14), %ebx
movq (%rsp), %r13
xorl %r12d, %r12d
testl %ebx, %ebx
js 0x264d
movzbl 0x2597(%r13,%r14), %esi
movl %ebx, %r12d
movzbl 0x2598(%r13,%r12), %edx
movq %r13, %rdi
callq 0x3313
testl %eax, %eax
je 0x288e
movq 0x10(%r13,%r14,8), %rax
subq 0x18(%r13,%r12,8), %rax
cmpq %r15, %rax
je 0x2892
decl %ebx
jmp 0x2853
movl $0x1, 0x14(%r13)
xorl %r12d, %r12d
jmp 0x264d