// File: /workspace/github_c_makefile_star2_O1/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 0x6fa7
cmpl $0x1, %eax
je 0x6f72
testl %eax, %eax
jne 0x7088
movl 0x38(%r13), %eax
cmpl $0x1d, %eax
jne 0x6f45
cmpl $0x1, 0x30(%r13)
je 0x7088
movslq 0x30(%r13), %rcx
testq %rcx, %rcx
jle 0x7010
shlq $0x2, %rcx
xorl %esi, %esi
leaq 0x3111(%rip), %rdi      # 0xa070
xorl %edx, %edx
addl (%rsi,%rdi), %edx
addq $0x4, %rsi
cmpq %rsi, %rcx
jne 0x6f61
jmp 0x7012
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 0x7088
incl %ecx
jmp 0x6ff3
movl 0x38(%r13), %eax
movslq 0x30(%r13), %rdx
leaq 0x30ba(%rip), %rsi      # 0xa070
movl $0x5, %ecx
cmpl 0x30(%rsi,%rdx,4), %eax
je 0x6ff3
imull $0xb6db6db7, %eax, %ecx # imm = 0xB6DB6DB7
addl $0x12492492, %ecx       # imm = 0x12492492
cmpl $0x24924924, %ecx       # imm = 0x24924924
ja 0x7088
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
movl 0x30(%r13), %edx
movl 0x3c(%r13), %r8d
incl %edx
leaq 0x3ae0(%rip), %rsi      # 0xaae4
movq %r15, %rdi
xorl %eax, %eax
callq 0x2290
jmp 0x7025
xorl %edx, %edx
addl %eax, %edx
leaq 0x3ac5(%rip), %rsi      # 0xaae0
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 0x7049
xorl %eax, %eax
cmpq $0x0, 0x50(%r13)
cmoveq %r12, %rax
addq %rax, %r14
testq %r14, %r14
js 0x7084
cmpq $0x1c20, %r14           # imm = 0x1C20
je 0x7080
movq %r15, %rdi
callq 0x20e0
movw $0x2f, (%r15,%rax)
movq %r15, %rdi
callq 0x20e0
addq %rax, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x6df6
testl %eax, %eax
jne 0x7088
xorl %ebx, %ebx
jmp 0x7088
movb $0x0, (%r15)
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq