// File: /workspace/github_c_makefile_star2_O0/JimKent[P]linearSat/lib/common.c
// Function: dateAdd
static void dateAdd(struct tm *tp,int addYears,int addMonths,int addDays)
/* Add years,months,days to a date */
{
tp->tm_mday  += addDays;
tp->tm_mon   += addMonths;
tp->tm_year  += addYears;
int dom=28;
while ( (tp->tm_mon >11  || tp->tm_mon <0)
    || (tp->tm_mday>dom || tp->tm_mday<1) )
    {
    if (tp->tm_mon>11)   // First month: tm.tm_mon is 0-11 range
        {
        tp->tm_year += (tp->tm_mon / 12);
        tp->tm_mon  = (tp->tm_mon % 12);
        }
    else if (tp->tm_mon<0)
        {
        tp->tm_year += (tp->tm_mon / 12) - 1;
        tp->tm_mon  =  (tp->tm_mon % 12) + 12;
        }
    else
        {
        dom = daysOfMonth(tp);
        if (tp->tm_mday>dom)
            {
            tp->tm_mday -= dom;
            tp->tm_mon  += 1;
            dom = daysOfMonth(tp);
            }
        else if (tp->tm_mday < 1)
            {
            tp->tm_mon  -= 1;
            dom = daysOfMonth(tp);
            tp->tm_mday += dom;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x14(%rax), %ecx
movl %ecx, 0x14(%rax)
movl $0x1c, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movb $0x1, %al
cmpl $0xb, 0x10(%rcx)
movb %al, -0x19(%rbp)
jg 0xe5a6
movq -0x8(%rbp), %rcx
movb $0x1, %al
cmpl $0x0, 0x10(%rcx)
movb %al, -0x19(%rbp)
jl 0xe5a6
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
movb $0x1, %al
cmpl -0x18(%rbp), %ecx
movb %al, -0x1a(%rbp)
jg 0xe5a0
movq -0x8(%rbp), %rax
cmpl $0x1, 0xc(%rax)
setl %al
movb %al, -0x1a(%rbp)
movb -0x1a(%rbp), %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
testb $0x1, %al
jne 0xe5b2
jmp 0xe6b2
movq -0x8(%rbp), %rax
cmpl $0xb, 0x10(%rax)
jle 0xe5f2
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl $0xc, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x8(%rbp), %rax
addl 0x14(%rax), %ecx
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl $0xc, %ecx
cltd
idivl %ecx
movq -0x8(%rbp), %rax
movl %edx, 0x10(%rax)
jmp 0xe6ad
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jge 0xe635
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl $0xc, %ecx
cltd
idivl %ecx
movl %eax, %ecx
subl $0x1, %ecx
movq -0x8(%rbp), %rax
addl 0x14(%rax), %ecx
movl %ecx, 0x14(%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl $0xc, %ecx
cltd
idivl %ecx
addl $0xc, %edx
movq -0x8(%rbp), %rax
movl %edx, 0x10(%rax)
jmp 0xe6ab
movq -0x8(%rbp), %rdi
callq 0xe6c0
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x18(%rbp), %eax
jle 0xe677
movl -0x18(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rdi
callq 0xe6c0
movl %eax, -0x18(%rbp)
jmp 0xe6a9
movq -0x8(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jge 0xe6a7
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
subl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rdi
callq 0xe6c0
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
jmp 0xe6a9
jmp 0xe6ab
jmp 0xe6ad
jmp 0xe563
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)