// File: /workspace/github_c_makefile_star2_O0/mmayer[P]pcal/src/pcalutil.c
// Function: normalize
void normalize (date_str *pd)
{
   int len;

   /* adjust if day is in previous or following month */
   
   while (pd->dd < 1) {
      pd->yy = PREV_YEAR(pd->mm, pd->yy);
      pd->mm = PREV_MONTH(pd->mm, pd->yy);
      pd->dd += LENGTH_OF(pd->mm, pd->yy);
   }
   
   while (pd->dd > (len = LENGTH_OF(pd->mm, pd->yy))) {
      pd->dd -= len;
      pd->yy = NEXT_YEAR(pd->mm, pd->yy);
      pd->mm = NEXT_MONTH(pd->mm, pd->yy);
   }

   return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jge 0xbc84
movq -0x8(%rbp), %rax
cmpl $0x1, (%rax)
jne 0xbbae
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xbbb8
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
cmpl $0x1, (%rax)
jne 0xbbd5
movl $0xc, %eax
movl %eax, -0x14(%rbp)
jmp 0xbbe1
movq -0x8(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x22593(%rip), %rax     # 0x2e190
movsbl (%rax,%rcx), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
movb %al, -0x15(%rbp)
jne 0xbc68
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
xorl %eax, %eax
cmpl $0x0, %edx
movb %al, -0x1d(%rbp)
jne 0xbc62
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movb $0x1, %al
cmpl $0x0, %edx
movb %al, -0x1e(%rbp)
jne 0xbc5c
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x190, %ecx            # imm = 0x190
cltd
idivl %ecx
cmpl $0x0, %edx
sete %al
movb %al, -0x1e(%rbp)
movb -0x1e(%rbp), %al
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %al
movb %al, -0x15(%rbp)
movl -0x1c(%rbp), %ecx
movb -0x15(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
addl %eax, %ecx
movq -0x8(%rbp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
jmp 0xbb88
jmp 0xbc86
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x224ed(%rip), %rax     # 0x2e190
movsbl (%rax,%rcx), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
movb %al, -0x1f(%rbp)
jne 0xbd0e
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
xorl %eax, %eax
cmpl $0x0, %edx
movb %al, -0x29(%rbp)
jne 0xbd08
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x64, %ecx
cltd
idivl %ecx
movb $0x1, %al
cmpl $0x0, %edx
movb %al, -0x2a(%rbp)
jne 0xbd02
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x190, %ecx            # imm = 0x190
cltd
idivl %ecx
cmpl $0x0, %edx
sete %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
movb %al, -0x1f(%rbp)
movl -0x28(%rbp), %eax
movl -0x24(%rbp), %ecx
movb -0x1f(%rbp), %dl
andb $0x1, %dl
movzbl %dl, %edx
addl %edx, %ecx
movl %ecx, -0xc(%rbp)
cmpl %ecx, %eax
jle 0xbd8e
movl -0xc(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
cmpl $0xc, (%rax)
jne 0xbd4d
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xbd57
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
cmpl $0xc, (%rax)
jne 0xbd74
movl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xbd80
movq -0x8(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
jmp 0xbc86
popq %rbp
retq