// File: /workspace/github_c_makefile_star2_O1/lyda[P]tz/localtime.c
// Function: time2sub
static time_t
time2sub(tmp, funcp, offset, okayp, do_norm_secs)
struct tm * const	tmp;
struct tm * (* const	funcp)(const time_t*, long, struct tm*);
const long		offset;
int * const		okayp;
const int		do_norm_secs;
{
	register const struct state *	sp;
	register int			dir;
	register int			i, j;
	register int			saved_seconds;
	register long			li;
	register time_t			lo;
	register time_t			hi;
	long				y;
	time_t				newt;
	time_t				t;
	struct tm			yourtm, mytm;

	*okayp = FALSE;
	yourtm = *tmp;
	if (do_norm_secs) {
		if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec,
			SECSPERMIN))
				return WRONG;
	}
	if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR))
		return WRONG;
	if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY))
		return WRONG;
	y = yourtm.tm_year;
	if (long_normalize_overflow(&y, &yourtm.tm_mon, MONSPERYEAR))
		return WRONG;
	/*
	** Turn y into an actual year number for now.
	** It is converted back to an offset from TM_YEAR_BASE later.
	*/
	if (long_increment_overflow(&y, TM_YEAR_BASE))
		return WRONG;
	while (yourtm.tm_mday <= 0) {
		if (long_increment_overflow(&y, -1))
			return WRONG;
		li = y + (1 < yourtm.tm_mon);
		yourtm.tm_mday += year_lengths[isleap(li)];
	}
	while (yourtm.tm_mday > DAYSPERLYEAR) {
		li = y + (1 < yourtm.tm_mon);
		yourtm.tm_mday -= year_lengths[isleap(li)];
		if (long_increment_overflow(&y, 1))
			return WRONG;
	}
	for ( ; ; ) {
		i = mon_lengths[isleap(y)][yourtm.tm_mon];
		if (yourtm.tm_mday <= i)
			break;
		yourtm.tm_mday -= i;
		if (++yourtm.tm_mon >= MONSPERYEAR) {
			yourtm.tm_mon = 0;
			if (long_increment_overflow(&y, 1))
				return WRONG;
		}
	}
	if (long_increment_overflow(&y, -TM_YEAR_BASE))
		return WRONG;
	yourtm.tm_year = y;
	if (yourtm.tm_year != y)
		return WRONG;
	if (yourtm.tm_sec >= 0 && yourtm.tm_sec < SECSPERMIN)
		saved_seconds = 0;
	else if (y + TM_YEAR_BASE < EPOCH_YEAR) {
		/*
		** We can't set tm_sec to 0, because that might push the
		** time below the minimum representable time.
		** Set tm_sec to 59 instead.
		** This assumes that the minimum representable time is
		** not in the same minute that a leap second was deleted from,
		** which is a safer assumption than using 58 would be.
		*/
		if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN))
			return WRONG;
		saved_seconds = yourtm.tm_sec;
		yourtm.tm_sec = SECSPERMIN - 1;
	} else {
		saved_seconds = yourtm.tm_sec;
		yourtm.tm_sec = 0;
	}
	/*
	** Do a binary search (this works whatever time_t's type is).
	*/
	if (!TYPE_SIGNED(time_t)) {
		lo = 0;
		hi = lo - 1;
	} else if (!TYPE_INTEGRAL(time_t)) {
		if (sizeof(time_t) > sizeof(float))
			hi = (time_t) DBL_MAX;
		else	hi = (time_t) FLT_MAX;
		lo = -hi;
	} else {
		lo = 1;
		for (i = 0; i < (int) TYPE_BIT(time_t) - 1; ++i)
			lo *= 2;
		hi = -(lo + 1);
	}
	for ( ; ; ) {
		t = lo / 2 + hi / 2;
		if (t < lo)
			t = lo;
		else if (t > hi)
			t = hi;
		if ((*funcp)(&t, offset, &mytm) == NULL) {
			/*
			** Assume that t is too extreme to be represented in
			** a struct tm; arrange things so that it is less
			** extreme on the next pass.
			*/
			dir = (t > 0) ? 1 : -1;
		} else	dir = tmcomp(&mytm, &yourtm);
		if (dir != 0) {
			if (t == lo) {
				++t;
				if (t <= lo)
					return WRONG;
				++lo;
			} else if (t == hi) {
				--t;
				if (t >= hi)
					return WRONG;
				--hi;
			}
			if (lo > hi)
				return WRONG;
			if (dir > 0)
				hi = t;
			else	lo = t;
			continue;
		}
		if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst)
			break;
		/*
		** Right time, wrong type.
		** Hunt for right time, right type.
		** It's okay to guess wrong since the guess
		** gets checked.
		*/
		sp = (const struct state *)
			((funcp == localsub) ? lclptr : gmtptr);
#ifdef ALL_STATE
		if (sp == NULL)
			return WRONG;
#endif /* defined ALL_STATE */
		for (i = sp->typecnt - 1; i >= 0; --i) {
			if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
				continue;
			for (j = sp->typecnt - 1; j >= 0; --j) {
				if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
					continue;
				newt = t + sp->ttis[j].tt_gmtoff -
					sp->ttis[i].tt_gmtoff;
				if ((*funcp)(&newt, offset, &mytm) == NULL)
					continue;
				if (tmcomp(&mytm, &yourtm) != 0)
					continue;
				if (mytm.tm_isdst != yourtm.tm_isdst)
					continue;
				/*
				** We have a match.
				*/
				t = newt;
				goto label;
			}
		}
		return WRONG;
	}
label:
	newt = t + saved_seconds;
	if ((newt < t) != (saved_seconds < 0))
		return WRONG;
	t = newt;
	if ((*funcp)(&t, offset, tmp))
		*okayp = TRUE;
	return t;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r14
movl $0x0, (%rsi)
movl (%rdi), %r9d
movl 0x4(%rdi), %eax
movl 0x8(%rdi), %r8d
movl 0xc(%rdi), %r15d
movl 0x10(%rdi), %r13d
movslq 0x14(%rdi), %rcx
movl 0x20(%rdi), %r11d
testl %edx, %edx
je 0x54a6
testl %r9d, %r9d
js 0x5455
movl %r9d, %edi
movl $0x88888889, %edx       # imm = 0x88888889
imulq %rdi, %rdx
shrq $0x25, %rdx
jmp 0x5469
movl %r9d, %edi
notl %edi
movl $0x88888889, %edx       # imm = 0x88888889
imulq %rdi, %rdx
shrq $0x25, %rdx
notl %edx
testl %eax, %eax
js 0x547d
movl %eax, %edi
xorl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
cmpl %edx, %edi
jge 0x5488
xorl %edi, %edi
jmp 0x548d
movl $0x80000000, %edi       # imm = 0x80000000
subl %eax, %edi
cmpl %edx, %edi
jg 0x5479
addl %edx, %eax
movb $0x1, %dil
movq $-0x1, %rbx
testb %dil, %dil
je 0x5a65
imull $-0x3c, %edx, %edx
addl %r9d, %edx
movl %edx, %r9d
testl %eax, %eax
js 0x54bb
movl %eax, %edi
movl $0x88888889, %edx       # imm = 0x88888889
imulq %rdi, %rdx
shrq $0x25, %rdx
jmp 0x54ce
movl %eax, %edi
notl %edi
movl $0x88888889, %edx       # imm = 0x88888889
imulq %rdi, %rdx
shrq $0x25, %rdx
notl %edx
testl %r8d, %r8d
js 0x54e4
movl %r8d, %edi
xorl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
cmpl %edx, %edi
jge 0x54f0
xorl %edi, %edi
jmp 0x54f6
movl $0x80000000, %edi       # imm = 0x80000000
subl %r8d, %edi
cmpl %edx, %edi
jg 0x54e0
addl %edx, %r8d
movb $0x1, %dil
movq $-0x1, %rbx
testb %dil, %dil
je 0x5a65
testl %r8d, %r8d
js 0x551e
movl %r8d, %edi
movl $0xaaaaaaab, %r10d      # imm = 0xAAAAAAAB
imulq %rdi, %r10
shrq $0x24, %r10
jmp 0x5534
movl %r8d, %edi
notl %edi
movl $0xaaaaaaab, %r10d      # imm = 0xAAAAAAAB
imulq %rdi, %r10
shrq $0x24, %r10
notl %r10d
testl %r15d, %r15d
js 0x554b
movl %r15d, %edi
xorl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
cmpl %r10d, %edi
jge 0x5558
xorl %edi, %edi
jmp 0x555e
movl $0x80000000, %edi       # imm = 0x80000000
subl %r15d, %edi
cmpl %r10d, %edi
jg 0x5547
addl %r10d, %r15d
movb $0x1, %dil
testb %dil, %dil
je 0x5a65
movq %rsi, 0x80(%rsp)
testl %r13d, %r13d
movl %r8d, 0x4(%rsp)
js 0x558b
movl %r13d, %r8d
movl $0xaaaaaaab, %edi       # imm = 0xAAAAAAAB
imulq %r8, %rdi
shrq $0x23, %rdi
jmp 0x55a0
movl %r13d, %r8d
notl %r8d
movl $0xaaaaaaab, %edi       # imm = 0xAAAAAAAB
imulq %r8, %rdi
shrq $0x23, %rdi
notl %edi
movl %r11d, 0x10(%rsp)
movq %r9, 0x18(%rsp)
movabsq $0x7fffffffffffffff, %r12 # imm = 0x7FFFFFFFFFFFFFFF
leal (,%rdi,4), %r8d
leal (%r8,%r8,2), %r8d
subl %r8d, %r13d
movslq %edi, %rdi
addq %rdi, %rcx
addq $0x76c, %rcx            # imm = 0x76C
movabsq $0x28f5c28f5c28f5c, %rsi # imm = 0x28F5C28F5C28F5C
testl %r15d, %r15d
jg 0x566e
xorl %ebx, %ebx
cmpl $0x2, %r13d
setge %bl
leaq 0x1(%r12), %rbp
leaq 0xc28(%rip), %r8        # 0x6220
leaq -0x1(%rcx), %rdi
cmpq %rbp, %rcx
movq %rdi, %rcx
cmoveq %rbp, %rcx
je 0x5a5e
leaq (%rcx,%rbx), %r9
testb $0x3, %r9b
je 0x561a
xorl %edi, %edi
jmp 0x5668
movabsq $-0x70a3d70a3d70a3d7, %rdi # imm = 0x8F5C28F5C28F5C29
imulq %rdi, %r9
movabsq $0x51eb851eb851eb8, %rdi # imm = 0x51EB851EB851EB8
leaq (%r9,%rdi), %r11
rorq $0x2, %r11
movl $0x1, %edi
cmpq %rsi, %r11
ja 0x5668
movabsq $0x51eb851eb851eb0, %rdi # imm = 0x51EB851EB851EB0
addq %rdi, %r9
rorq $0x4, %r9
xorl %edi, %edi
movabsq $0xa3d70a3d70a3d7, %r11 # imm = 0xA3D70A3D70A3D7
cmpq %r11, %r9
setb %dil
addl (%r8,%rdi,4), %r15d
jle 0x55f8
shll $0x3, %r10d
imull $-0x3c, %edx, %r11d
leal (%r10,%r10,2), %edx
addl %eax, %r11d
movl 0x4(%rsp), %ebp
subl %edx, %ebp
xorl %eax, %eax
cmpl $0x2, %r13d
setge %al
leaq 0xb8d(%rip), %rdx       # 0x6220
movabsq $-0x70a3d70a3d70a3d7, %r10 # imm = 0x8F5C28F5C28F5C29
movabsq $0x51eb851eb851eb8, %rbx # imm = 0x51EB851EB851EB8
cmpl $0x16e, %r15d           # imm = 0x16E
jle 0x5711
leaq (%rcx,%rax), %r8
testb $0x3, %r8b
je 0x56be
xorl %edi, %edi
jmp 0x56f8
imulq %r10, %r8
leaq (%r8,%rbx), %r9
rorq $0x2, %r9
movl $0x1, %edi
cmpq %rsi, %r9
ja 0x56f8
movabsq $0x51eb851eb851eb0, %rdi # imm = 0x51EB851EB851EB0
addq %rdi, %r8
rorq $0x4, %r8
xorl %edi, %edi
movabsq $0xa3d70a3d70a3d7, %r9  # imm = 0xA3D70A3D70A3D7
cmpq %r9, %r8
setb %dil
subl (%rdx,%rdi,4), %r15d
leaq 0x1(%rcx), %rdi
cmpq %r12, %rcx
cmoveq %r12, %rdi
movq %rdi, %rcx
jne 0x56a7
jmp 0x5a5e
movl %r11d, 0x14(%rsp)
movq %r14, 0x78(%rsp)
movabsq $-0x5c28f5c28f5c28f5, %r10 # imm = 0xA3D70A3D70A3D70B
leaq 0xbc4(%rip), %r11       # 0x62f0
xorl %ebx, %ebx
movabsq $0xa3d70a3d70a3d7, %rsi # imm = 0xA3D70A3D70A3D7
movq %rcx, %rax
imulq %r10
addq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x6, %rdx
addq %rax, %rdx
imulq $0x64, %rdx, %rdx
movq %rcx, %rax
subq %rdx, %rax
movq %rcx, %rdi
movabsq $-0x70a3d70a3d70a3d7, %rdx # imm = 0x8F5C28F5C28F5C29
imulq %rdx, %rdi
movabsq $0x51eb851eb851eb0, %rdx # imm = 0x51EB851EB851EB0
addq %rdx, %rdi
rorq $0x4, %rdi
xorl %edx, %edx
cmpq %rsi, %rdi
setb %dl
movslq %r13d, %rdi
leaq (%r11,%rdi,4), %r8
movl %r15d, %r14d
testq %rax, %rax
movl $0x1, %edi
cmoveq %rdx, %rdi
testb $0x3, %cl
cmovneq %rbx, %rdi
leaq (%rdi,%rdi,2), %rdi
shll $0x4, %edi
subl (%r8,%rdi), %r15d
jle 0x57dd
leal 0x1(%r13), %edi
addq $0x4, %r8
movl %r15d, %r14d
cmpl $0xb, %r13d
movl %edi, %r13d
jl 0x578d
leaq 0x1(%rcx), %rax
xorl %r13d, %r13d
cmpq %r12, %rcx
cmoveq %r12, %rax
movq %rax, %rcx
jne 0x5738
jmp 0x5a5e
leaq 0x76c(%r12), %rax
leaq -0x76c(%rcx), %rdx
cmpq %rax, %rcx
cmovleq %rcx, %rdx
jle 0x5a5e
movslq %edx, %rax
cmpq %rdx, %rax
jne 0x5a5e
movq 0x18(%rsp), %rcx
cmpl $0x3c, %ecx
jae 0x5816
movl %ecx, (%rsp)
xorl %ecx, %ecx
jmp 0x583f
cmpq $0x45, %rdx
jg 0x5838
leal -0x3b(%rcx), %eax
movl $0x3b, (%rsp)
cmpl $0x8000003b, %ecx       # imm = 0x8000003B
cmovll %ecx, %eax
movl %eax, %ecx
jge 0x583f
jmp 0x5a5e
movl $0x0, (%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
movl %ebp, 0x4(%rsp)
movl %r13d, %r15d
negl %r15d
leaq 0x1(%r12), %rbp
movq %rbp, %rax
shrq $0x3f, %rax
addq %rbp, %rax
sarq %rax
movq %r12, %rbx
shrq $0x3f, %rbx
addq %r12, %rbx
sarq %rbx
addq %rax, %rbx
movq %rbx, 0x8(%rsp)
cmpq %rbp, %rbx
jge 0x5889
movq %rbp, 0x8(%rsp)
movq %rbp, %rbx
jmp 0x5896
cmpq %r12, %rbx
jle 0x5896
movq %r12, 0x8(%rsp)
movq %r12, %rbx
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
leaq 0x30(%rsp), %rdx
callq 0x4397
testq %rax, %rax
je 0x58e5
movl 0x44(%rsp), %eax
subl 0x20(%rsp), %eax
jne 0x58f9
movl 0x40(%rsp), %eax
cmpl %r13d, %eax
jne 0x58f6
movl 0x3c(%rsp), %eax
subl %r14d, %eax
jne 0x58f9
movl 0x38(%rsp), %eax
subl 0x4(%rsp), %eax
jne 0x58f9
movl 0x34(%rsp), %eax
subl 0x14(%rsp), %eax
jne 0x58f9
movl 0x30(%rsp), %eax
subl (%rsp), %eax
jmp 0x58f9
xorl %eax, %eax
testq %rbx, %rbx
setg %al
leal -0x1(,%rax,2), %eax
jmp 0x58f9
addl %r15d, %eax
testl %eax, %eax
je 0x5937
cmpq %rbp, %rbx
jne 0x590f
incq %rbx
movq %rbx, 0x8(%rsp)
incq %rbp
jmp 0x591f
cmpq %r12, %rbx
jne 0x591f
decq %rbx
movq %rbx, 0x8(%rsp)
decq %r12
cmpq %r12, %rbp
jg 0x5a5e
testl %eax, %eax
cmovleq %rbx, %rbp
cmovgq %rbx, %r12
jmp 0x5858
movl 0x10(%rsp), %ecx
testl %ecx, %ecx
js 0x5a7f
cmpl %ecx, 0x50(%rsp)
je 0x5a7f
movslq 0x2d74(%rip), %r15      # 0x86c8
testq %r15, %r15
jle 0x5a5e
movq 0x8(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq (%r15,%r15,2), %rax
leaq 0x2d4e(%rip), %rdx      # 0x86c0
cmpl %ecx, 0x2a38(%rdx,%rax,8)
jne 0x5a4d
movslq 0x2d42(%rip), %rbp      # 0x86c8
testq %rbp, %rbp
jle 0x5a4d
leaq 0x2d2a(%rip), %rdx      # 0x86c0
leaq (%rdx,%rax,8), %rax
addq $0x2a30, %rax           # imm = 0x2A30
movq %rax, 0x70(%rsp)
leaq (,%rbp,2), %rax
addq %rbp, %rax
incq %rbp
leaq (%rdx,%rax,8), %r12
addq $0x2a38, %r12           # imm = 0x2A38
cmpl %ecx, (%r12)
je 0x5a38
movq -0x8(%r12), %rbx
addq 0x68(%rsp), %rbx
movq 0x70(%rsp), %rax
subq (%rax), %rbx
movq %rbx, 0x28(%rsp)
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
leaq 0x30(%rsp), %rdx
callq 0x4397
testq %rax, %rax
je 0x5a38
xorl %eax, %eax
movq 0x20(%rsp), %rcx
cmpl %ecx, 0x44(%rsp)
jne 0x5a2a
cmpl %r13d, 0x40(%rsp)
jne 0x5a2a
cmpl %r14d, 0x3c(%rsp)
jne 0x5a2a
movl 0x4(%rsp), %ecx
cmpl %ecx, 0x38(%rsp)
jne 0x5a2a
movl 0x14(%rsp), %ecx
cmpl %ecx, 0x34(%rsp)
jne 0x5a2a
movl (%rsp), %eax
cmpl %eax, 0x30(%rsp)
sete %al
testb %al, %al
je 0x5a38
movl 0x10(%rsp), %eax
cmpl %eax, 0x50(%rsp)
je 0x5a7a
decq %rbp
addq $-0x18, %r12
cmpq $0x1, %rbp
movl 0x10(%rsp), %ecx
jg 0x59be
leaq -0x1(%r15), %rax
cmpq $0x1, %r15
movq %rax, %r15
jg 0x5967
movq $-0x1, %rbx
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0x8(%rsp)
movslq 0x18(%rsp), %rbx
leaq 0x8(%rsp), %rdi
addq (%rdi), %rbx
movq %rbx, 0x28(%rsp)
movq %rbx, (%rdi)
xorl %esi, %esi
movq 0x78(%rsp), %rdx
callq 0x4397
testq %rax, %rax
je 0x5a65
movq 0x80(%rsp), %rax
movl $0x1, (%rax)
jmp 0x5a65
nopl (%rax)