// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x20f0
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x34(%rax)
jne 0x864b
movq -0x18(%rbp), %rax
cmpl $0x1d, 0x38(%rax)
jne 0x85f1
movq -0x18(%rbp), %rax
cmpl $0x1, 0x30(%rax)
jne 0x85f1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x87c6
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x862a
movslq -0x34(%rbp), %rcx
leaq 0x5b1a(%rip), %rax      # 0xe130
movl (%rax,%rcx,4), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x85ff
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %edx
movq -0x18(%rbp), %rax
addl 0x38(%rax), %edx
leaq 0x65ce(%rip), %rsi      # 0xec0d
movb $0x0, %al
callq 0x2250
jmp 0x8724
movq -0x18(%rbp), %rax
cmpl $0x1, 0x34(%rax)
jne 0x868c
movq -0x18(%rbp), %rax
movl 0x38(%rax), %eax
movl $0x7, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
je 0x8675
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x87c6
movq -0x18(%rbp), %rax
movl 0x38(%rax), %eax
movl $0x7, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x86fd
movq -0x18(%rbp), %rax
cmpl $0x2, 0x34(%rax)
jne 0x86ef
movq -0x18(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x18(%rbp), %rcx
movslq 0x30(%rcx), %rdx
leaq 0x5a84(%rip), %rcx      # 0xe130
cmpl 0x30(%rcx,%rdx,4), %eax
jne 0x86bb
movl $0x5, -0x3c(%rbp)
jmp 0x86ed
movq -0x18(%rbp), %rax
movl 0x38(%rax), %eax
movl $0x7, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x86db
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x87c6
movq -0x18(%rbp), %rax
movl 0x38(%rax), %eax
movl $0x7, %ecx
cltd
idivl %ecx
movl %eax, -0x3c(%rbp)
jmp 0x86fb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x87c6
jmp 0x86fd
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x30(%rax), %edx
addl $0x1, %edx
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %r8d
leaq 0x64f4(%rip), %rsi      # 0xec11
movb $0x0, %al
callq 0x2250
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x4c(%rax)
je 0x8746
movq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x48(%rax)
je 0x8767
movq -0x18(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x8767
movq -0x20(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jge 0x877e
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x87c6
cmpq $0x1c20, -0x30(%rbp)    # imm = 0x1C20
je 0x87bf
movq -0x10(%rbp), %rdi
leaq 0x5c8d(%rip), %rsi      # 0xe420
callq 0x2240
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x20f0
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x8480
cmpl $0x0, %eax
je 0x87bd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x87c6
jmp 0x87bf
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop