// File: /workspace/github_c_makefile_star2_O0/lyda[P]tz/localtime.c
// Function: transtime
static time_t
transtime(janfirst, year, rulep, offset)
const time_t				janfirst;
const int				year;
register const struct rule * const	rulep;
const long				offset;
{
	register int	leapyear;
	register time_t	value;
	register int	i;
	int		d, m1, yy0, yy1, yy2, dow;

	INITIALIZE(value);
	leapyear = isleap(year);
	switch (rulep->r_type) {

	case JULIAN_DAY:
		/*
		** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap
		** years.
		** In non-leap years, or if the day number is 59 or less, just
		** add SECSPERDAY times the day number-1 to the time of
		** January 1, midnight, to get the day.
		*/
		value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
		if (leapyear && rulep->r_day >= 60)
			value += SECSPERDAY;
		break;

	case DAY_OF_YEAR:
		/*
		** n - day of year.
		** Just add SECSPERDAY times the day number to the time of
		** January 1, midnight, to get the day.
		*/
		value = janfirst + rulep->r_day * SECSPERDAY;
		break;

	case MONTH_NTH_DAY_OF_WEEK:
		/*
		** Mm.n.d - nth "dth day" of month m.
		*/
		value = janfirst;
		for (i = 0; i < rulep->r_mon - 1; ++i)
			value += mon_lengths[leapyear][i] * SECSPERDAY;

		/*
		** Use Zeller's Congruence to get day-of-week of first day of
		** month.
		*/
		m1 = (rulep->r_mon + 9) % 12 + 1;
		yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
		yy1 = yy0 / 100;
		yy2 = yy0 % 100;
		dow = ((26 * m1 - 2) / 10 +
			1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
		if (dow < 0)
			dow += DAYSPERWEEK;

		/*
		** "dow" is the day-of-week of the first day of the month. Get
		** the day-of-month (zero-origin) of the first "dow" day of the
		** month.
		*/
		d = rulep->r_day - dow;
		if (d < 0)
			d += DAYSPERWEEK;
		for (i = 1; i < rulep->r_week; ++i) {
			if (d + DAYSPERWEEK >=
				mon_lengths[leapyear][rulep->r_mon - 1])
					break;
			d += DAYSPERWEEK;
		}

		/*
		** "d" is the day-of-month (zero-origin) of the day we want.
		*/
		value += d * SECSPERDAY;
		break;
	}

	/*
	** "value" is the Epoch-relative time of 00:00:00 UTC on the day in
	** question. To get the Epoch-relative time of the specified local
	** time on that day, add the transition time and the current offset
	** from UTC.
	*/
	return value + rulep->r_time + offset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movl -0xc(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
xorl %eax, %eax
cmpl $0x0, %edx
movb %al, -0x4d(%rbp)
jne 0x4def
movl -0xc(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movb $0x1, %al
cmpl $0x0, %edx
movb %al, -0x4e(%rbp)
jne 0x4de9
movl -0xc(%rbp), %eax
movl $0x190, %ecx            # imm = 0x190
cltd
idivl %ecx
cmpl $0x0, %edx
sete %al
movb %al, -0x4e(%rbp)
movb -0x4e(%rbp), %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x54(%rbp)
testl %eax, %eax
je 0x4e21
jmp 0x4e0a
movl -0x54(%rbp), %eax
subl $0x1, %eax
je 0x4e63
jmp 0x4e14
movl -0x54(%rbp), %eax
subl $0x2, %eax
je 0x4e82
jmp 0x500d
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x15180, %rcx, %rcx    # imm = 0x15180
addq %rcx, %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x4e5e
movq -0x18(%rbp), %rax
cmpl $0x3c, 0x4(%rax)
jl 0x4e5e
movq -0x30(%rbp), %rax
addq $0x15180, %rax          # imm = 0x15180
movq %rax, -0x30(%rbp)
jmp 0x500d
movq -0x8(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x4(%rcx), %rcx
imulq $0x15180, %rcx, %rcx    # imm = 0x15180
addq %rcx, %rax
movq %rax, -0x30(%rbp)
jmp 0x500d
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
movl 0xc(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x4ed6
movslq -0x24(%rbp), %rcx
leaq 0x2443(%rip), %rax      # 0x72f0
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq -0x34(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
imulq $0x15180, %rax, %rax    # imm = 0x15180
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4e91
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x9, %eax
movl $0xc, %ecx
cltd
idivl %ecx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, 0xc(%rax)
jg 0x4f03
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x4f09
movl -0xc(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movl %edx, -0x48(%rbp)
imull $0x1a, -0x3c(%rbp), %eax
subl $0x2, %eax
movl $0xa, %ecx
cltd
idivl %ecx
addl $0x1, %eax
addl -0x48(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x48(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x60(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x5c(%rbp)
movl -0x44(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x5c(%rbp), %eax
addl %ecx, %eax
movl -0x44(%rbp), %ecx
shll %ecx
subl %ecx, %eax
movl $0x7, %ecx
cltd
idivl %ecx
movl %edx, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x4f8b
movl -0x4c(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jge 0x4fa7
movl -0x38(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x38(%rbp)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x4ffa
movl -0x38(%rbp), %eax
addl $0x7, %eax
movslq -0x24(%rbp), %rdx
leaq 0x2325(%rip), %rcx      # 0x72f0
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movq -0x18(%rbp), %rdx
movl 0xc(%rdx), %edx
subl $0x1, %edx
movslq %edx, %rdx
cmpl (%rcx,%rdx,4), %eax
jl 0x4fe6
jmp 0x4ffa
movl -0x38(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4fae
movslq -0x38(%rbp), %rax
imulq $0x15180, %rax, %rax    # imm = 0x15180
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
addq 0x10(%rcx), %rax
addq -0x20(%rbp), %rax
popq %rbp
retq
nop