// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
movl $0x38, %edx
callq 0x1130
cmpl $0x0, -0x2c(%rbp)
je 0x5b94
leaq -0xb0(%rbp), %rdi
addq $0x4, %rdi
leaq -0xb0(%rbp), %rsi
movl $0x3c, %edx
callq 0x6330
cmpl $0x0, %eax
je 0x5b92
movq $-0x1, -0x8(%rbp)
jmp 0x6320
jmp 0x5b94
leaq -0xb0(%rbp), %rdi
addq $0x8, %rdi
leaq -0xb0(%rbp), %rsi
addq $0x4, %rsi
movl $0x3c, %edx
callq 0x6330
cmpl $0x0, %eax
je 0x5bc6
movq $-0x1, -0x8(%rbp)
jmp 0x6320
leaq -0xb0(%rbp), %rdi
addq $0xc, %rdi
leaq -0xb0(%rbp), %rsi
addq $0x8, %rsi
movl $0x18, %edx
callq 0x6330
cmpl $0x0, %eax
je 0x5bf8
movq $-0x1, -0x8(%rbp)
jmp 0x6320
movslq -0x9c(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0xb0(%rbp), %rsi
addq $0x10, %rsi
leaq -0x68(%rbp), %rdi
movl $0xc, %edx
callq 0x63a0
cmpl $0x0, %eax
je 0x5c2e
movq $-0x1, -0x8(%rbp)
jmp 0x6320
leaq -0x68(%rbp), %rdi
movl $0x76c, %esi            # imm = 0x76C
callq 0x6410
cmpl $0x0, %eax
je 0x5c4e
movq $-0x1, -0x8(%rbp)
jmp 0x6320
jmp 0x5c50
cmpl $0x0, -0xa4(%rbp)
jg 0x5d27
leaq -0x68(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x6410
cmpl $0x0, %eax
je 0x5c7d
movq $-0x1, -0x8(%rbp)
jmp 0x6320
movq -0x68(%rbp), %rax
movl $0x1, %ecx
cmpl -0xa0(%rbp), %ecx
setl %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl $0x4, %ecx
cqto
idivq %rcx
xorl %eax, %eax
cmpq $0x0, %rdx
movb %al, -0xe9(%rbp)
jne 0x5cfe
movq -0x50(%rbp), %rax
movl $0x64, %ecx
cqto
idivq %rcx
movb $0x1, %al
cmpq $0x0, %rdx
movb %al, -0xea(%rbp)
jne 0x5cf2
movq -0x50(%rbp), %rax
movl $0x190, %ecx            # imm = 0x190
cqto
idivq %rcx
cmpq $0x0, %rdx
sete %al
movb %al, -0xea(%rbp)
movb -0xea(%rbp), %al
movb %al, -0xe9(%rbp)
movb -0xe9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movslq %eax, %rcx
leaq 0x15d1(%rip), %rax      # 0x72e4
movl (%rax,%rcx,4), %eax
addl -0xa4(%rbp), %eax
movl %eax, -0xa4(%rbp)
jmp 0x5c50
jmp 0x5d29
cmpl $0x16e, -0xa4(%rbp)     # imm = 0x16E
jle 0x5e05
movq -0x68(%rbp), %rax
movl $0x1, %ecx
cmpl -0xa0(%rbp), %ecx
setl %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl $0x4, %ecx
cqto
idivq %rcx
xorl %eax, %eax
cmpq $0x0, %rdx
movb %al, -0xeb(%rbp)
jne 0x5dba
movq -0x50(%rbp), %rax
movl $0x64, %ecx
cqto
idivq %rcx
movb $0x1, %al
cmpq $0x0, %rdx
movb %al, -0xec(%rbp)
jne 0x5dae
movq -0x50(%rbp), %rax
movl $0x190, %ecx            # imm = 0x190
cqto
idivq %rcx
cmpq $0x0, %rdx
sete %al
movb %al, -0xec(%rbp)
movb -0xec(%rbp), %al
movb %al, -0xeb(%rbp)
movb -0xeb(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movslq %eax, %rcx
leaq 0x1515(%rip), %rax      # 0x72e4
movl (%rax,%rcx,4), %ecx
movl -0xa4(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xa4(%rbp)
leaq -0x68(%rbp), %rdi
movl $0x1, %esi
callq 0x6410
cmpl $0x0, %eax
je 0x5e00
movq $-0x1, -0x8(%rbp)
jmp 0x6320
jmp 0x5d29
jmp 0x5e07
movq -0x68(%rbp), %rax
movl $0x4, %ecx
cqto
idivq %rcx
xorl %eax, %eax
cmpq $0x0, %rdx
movb %al, -0xed(%rbp)
jne 0x5e66
movq -0x68(%rbp), %rax
movl $0x64, %ecx
cqto
idivq %rcx
movb $0x1, %al
cmpq $0x0, %rdx
movb %al, -0xee(%rbp)
jne 0x5e5a
movq -0x68(%rbp), %rax
movl $0x190, %ecx            # imm = 0x190
cqto
idivq %rcx
cmpq $0x0, %rdx
sete %al
movb %al, -0xee(%rbp)
movb -0xee(%rbp), %al
movb %al, -0xed(%rbp)
movb -0xed(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movslq %eax, %rcx
leaq 0x1475(%rip), %rax      # 0x72f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0xa0(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x5e9c
jmp 0x5ef2
movl -0x40(%rbp), %ecx
movl -0xa4(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xa4(%rbp)
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
cmpl $0xc, %eax
jl 0x5eed
movl $0x0, -0xa0(%rbp)
leaq -0x68(%rbp), %rdi
movl $0x1, %esi
callq 0x6410
cmpl $0x0, %eax
je 0x5eeb
movq $-0x1, -0x8(%rbp)
jmp 0x6320
jmp 0x5eed
jmp 0x5e07
leaq -0x68(%rbp), %rdi
movl $0xfffff894, %esi       # imm = 0xFFFFF894
callq 0x6410
cmpl $0x0, %eax
je 0x5f12
movq $-0x1, -0x8(%rbp)
jmp 0x6320
movq -0x68(%rbp), %rax
movl %eax, -0x9c(%rbp)
movslq -0x9c(%rbp), %rax
cmpq -0x68(%rbp), %rax
je 0x5f36
movq $-0x1, -0x8(%rbp)
jmp 0x6320
cmpl $0x0, -0xb0(%rbp)
jl 0x5f51
cmpl $0x3c, -0xb0(%rbp)
jge 0x5f51
movl $0x0, -0x48(%rbp)
jmp 0x5fb0
movq -0x68(%rbp), %rax
addq $0x76c, %rax            # imm = 0x76C
cmpq $0x7b2, %rax            # imm = 0x7B2
jge 0x5f9b
leaq -0xb0(%rbp), %rdi
movl $0xffffffc5, %esi       # imm = 0xFFFFFFC5
callq 0x59e0
cmpl $0x0, %eax
je 0x5f86
movq $-0x1, -0x8(%rbp)
jmp 0x6320
movl -0xb0(%rbp), %eax
movl %eax, -0x48(%rbp)
movl $0x3b, -0xb0(%rbp)
jmp 0x5fae
movl -0xb0(%rbp), %eax
movl %eax, -0x48(%rbp)
movl $0x0, -0xb0(%rbp)
jmp 0x5fb0
movq $0x1, -0x58(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x3f, -0x40(%rbp)
jge 0x5fdb
movq -0x58(%rbp), %rax
shlq %rax
movq %rax, -0x58(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x5fbf
movq -0x58(%rbp), %rcx
addq $0x1, %rcx
xorl %eax, %eax
subq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, -0xf8(%rbp)
movq -0x60(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0xf8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x6034
movq -0x58(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x6048
movq -0x78(%rbp), %rax
cmpq -0x60(%rbp), %rax
jle 0x6046
movq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x6048
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rsi
leaq -0x78(%rbp), %rdi
leaq -0xe8(%rbp), %rdx
callq *%rax
cmpq $0x0, %rax
jne 0x607d
movq -0x78(%rbp), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovgl %ecx, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6093
leaq -0xe8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x6480
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x6147
movq -0x78(%rbp), %rax
cmpq -0x58(%rbp), %rax
jne 0x60d8
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x58(%rbp), %rax
jg 0x60ca
movq $-0x1, -0x8(%rbp)
jmp 0x6320
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x6113
movq -0x78(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x6111
movq -0x78(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x60(%rbp), %rax
jl 0x6105
movq $-0x1, -0x8(%rbp)
jmp 0x6320
movq -0x60(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x6113
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jle 0x612a
movq $-0x1, -0x8(%rbp)
jmp 0x6320
cmpl $0x0, -0x3c(%rbp)
jle 0x613a
movq -0x78(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x6142
movq -0x78(%rbp), %rax
movq %rax, -0x58(%rbp)
jmp 0x5fec
cmpl $0x0, -0x90(%rbp)
jl 0x615e
movl -0xc8(%rbp), %eax
cmpl -0x90(%rbp), %eax
jne 0x6163
jmp 0x62b2
movq -0x18(%rbp), %rdx
leaq -0x216e(%rip), %rsi     # 0x4000
leaq 0x7cfb(%rip), %rax      # 0xde70
leaq 0x3534(%rip), %rcx      # 0x96b0
cmpq %rsi, %rdx
cmoveq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jl 0x62a8
movq -0x38(%rbp), %rax
addq $0x2a48, %rax           # imm = 0x2A48
movslq -0x40(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x90(%rbp), %eax
je 0x61c3
jmp 0x629a
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jl 0x6298
movq -0x38(%rbp), %rax
addq $0x2a48, %rax           # imm = 0x2A48
movslq -0x44(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x90(%rbp), %eax
jne 0x61ff
jmp 0x628a
movq -0x78(%rbp), %rax
movq -0x38(%rbp), %rcx
addq $0x2a48, %rcx           # imm = 0x2A48
movslq -0x44(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
addq (%rcx), %rax
movq -0x38(%rbp), %rcx
addq $0x2a48, %rcx           # imm = 0x2A48
movslq -0x40(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
subq (%rcx), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rsi
leaq -0x70(%rbp), %rdi
leaq -0xe8(%rbp), %rdx
callq *%rax
cmpq $0x0, %rax
jne 0x6256
jmp 0x628a
leaq -0xe8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x6480
cmpl $0x0, %eax
je 0x6270
jmp 0x628a
movl -0xc8(%rbp), %eax
cmpl -0x90(%rbp), %eax
je 0x6280
jmp 0x628a
movq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x62b4
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x61d0
jmp 0x629a
movl -0x40(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x6194
movq $-0x1, -0x8(%rbp)
jmp 0x6320
jmp 0x62b4
movq -0x78(%rbp), %rax
movslq -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
setl %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, -0x48(%rbp)
setl %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x62ee
movq $-0x1, -0x8(%rbp)
jmp 0x6320
movq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq *%rax
cmpq $0x0, %rax
je 0x6318
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
movq -0x78(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopl (%rax)