// File: /workspace/github_c_makefile_star2_O3/lyda[P]tz/zic.c
// Function: stringrule
static int
stringrule(result, rp, dstoff, gmtoff)
char *				result;
const struct rule * const	rp;
const long			dstoff;
const long			gmtoff;
{
	register long	tod;

	result = end(result);
	if (rp->r_dycode == DC_DOM) {
		register int	month, total;

		if (rp->r_dayofmonth == 29 && rp->r_month == TM_FEBRUARY)
			return -1;
		total = 0;
		for (month = 0; month < rp->r_month; ++month)
			total += len_months[0][month];
		(void) sprintf(result, "J%d", total + rp->r_dayofmonth);
	} else {
		register int	week;

		if (rp->r_dycode == DC_DOWGEQ) {
			if ((rp->r_dayofmonth % DAYSPERWEEK) != 1)
				return -1;
			week = 1 + rp->r_dayofmonth / DAYSPERWEEK;
		} else if (rp->r_dycode == DC_DOWLEQ) {
			if (rp->r_dayofmonth == len_months[1][rp->r_month])
				week = 5;
			else {
				if ((rp->r_dayofmonth % DAYSPERWEEK) != 0)
					return -1;
				week = rp->r_dayofmonth / DAYSPERWEEK;
			}
		} else	return -1;	/* "cannot happen" */
		(void) sprintf(result, "M%d.%d.%d",
			rp->r_month + 1, week, rp->r_wday);
	}
	tod = rp->r_tod;
	if (rp->r_todisgmt)
		tod += gmtoff;
	if (rp->r_todisstd && rp->r_stdoff == 0)
		tod += dstoff;
	if (tod < 0) {
		result[0] = '\0';
		return -1;
	}
	if (tod != 2 * SECSPERMIN * MINSPERHOUR) {
		(void) strcat(result, "/");
		if (stringoffset(end(result), tod) != 0)
			return -1;
	}
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
callq 0x20e0
movq %rax, %r15
addq %rbx, %r15
movl 0x34(%r13), %eax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x2, %eax
je 0x71da
cmpl $0x1, %eax
je 0x71a1
testl %eax, %eax
jne 0x72b7
movl 0x30(%r13), %ecx
movl 0x38(%r13), %eax
movl %eax, %edx
xorl $0x1d, %edx
movl %ecx, %esi
xorl $0x1, %esi
orl %edx, %esi
je 0x72b7
movl %ecx, %ecx
testl %ecx, %ecx
jle 0x723f
shlq $0x2, %rcx
xorl %esi, %esi
leaq 0x2f52(%rip), %rdi      # 0xa0e0
xorl %edx, %edx
addl (%rsi,%rdi), %edx
addq $0x4, %rsi
cmpq %rsi, %rcx
jne 0x7190
jmp 0x7241
movslq 0x38(%r13), %rax
imulq $-0x6db6db6d, %rax, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
sarl $0x2, %ecx
addl %edx, %ecx
leal (,%rcx,8), %edx
movl %ecx, %esi
subl %edx, %esi
addl %eax, %esi
cmpl $0x1, %esi
jne 0x72b7
incl %ecx
movl 0x30(%r13), %edx
jmp 0x7226
movl 0x38(%r13), %eax
movslq 0x30(%r13), %rdx
leaq 0x2ef7(%rip), %rsi      # 0xa0e0
movl $0x5, %ecx
cmpl 0x30(%rsi,%rdx,4), %eax
je 0x7226
imull $0xb6db6db7, %eax, %ecx # imm = 0xB6DB6DB7
addl $0x12492492, %ecx       # imm = 0x12492492
cmpl $0x24924924, %ecx       # imm = 0x24924924
ja 0x72b7
movslq %eax, %rcx
imulq $-0x6db6db6d, %rcx, %rcx # imm = 0x92492493
shrq $0x20, %rcx
addl %eax, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
sarl $0x2, %ecx
addl %eax, %ecx
incl %edx
movl 0x3c(%r13), %r8d
leaq 0x391d(%rip), %rsi      # 0xab50
movq %r15, %rdi
xorl %eax, %eax
callq 0x2290
jmp 0x7254
xorl %edx, %edx
addl %eax, %edx
leaq 0x3902(%rip), %rsi      # 0xab4c
movq %r15, %rdi
xorl %eax, %eax
callq 0x2290
xorl %eax, %eax
cmpl $0x0, 0x4c(%r13)
cmoveq %rax, %r14
addq 0x40(%r13), %r14
cmpl $0x0, 0x48(%r13)
je 0x7278
xorl %eax, %eax
cmpq $0x0, 0x50(%r13)
cmoveq %r12, %rax
addq %rax, %r14
testq %r14, %r14
js 0x72b3
cmpq $0x1c20, %r14           # imm = 0x1C20
je 0x72af
movq %r15, %rdi
callq 0x20e0
movw $0x2f, (%r15,%rax)
movq %r15, %rdi
callq 0x20e0
addq %rax, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x7022
testl %eax, %eax
jne 0x72b7
xorl %ebx, %ebx
jmp 0x72b7
movb $0x0, (%r15)
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq