#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int day_of_week(int day, int month, int year) {
  int count, sum_of_days;
  int first_day = 6;
  if (year < 2000) {
    printf("Sorry buddy, your date should be >= 1/1/2000!\n");
    return -1;
  }
  if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 ||
      month == 10 || month == 12) {
    if (day > 31 || day < 1) {
      printf("Sorry buddy, your date is not correct!\n");
      return -1;
    }
  } else if (month == 2) {
    if (((year % 4 == 0) ? ((year % 100 == 0) ? ((year % 400 == 0) ? 1 : 0) : 1)
                         : 0)) {
      if (day > 29 || day < 1) {
        printf("Sorry buddy, your date is not correct!\n");
        return -1;
      }
    } else {
      if (day > 28 || day < 1) {
        printf("Sorry buddy, your date is not correct!\n");
        return -1;
      }
    }
  } else {
    if (day > 30 || day < 1) {
      printf("Sorry buddy, your date is not correct!\n");
      return -1;
    }
  }
  sum_of_days = 0;
  for (count = 2000; count < year; count++) {
    sum_of_days +=
        (((((count % 4 == 0)
                ? ((count % 100 == 0) ? ((count % 400 == 0) ? 1 : 0) : 1)
                : 0) == 1)
              ? 366
              : 365)) %
        7;
  }
  for (count = 1; count < month; count++) {
    if (count == 1 || count == 3 || count == 5 || count == 7 || count == 8 ||
        count == 10 || count == 12) {
      sum_of_days += 31 % 7;
    } else if (count == 2) {
      if (((year % 4 == 0)
               ? ((year % 100 == 0) ? ((year % 400 == 0) ? 1 : 0) : 1)
               : 0)) {
        sum_of_days += 29 % 7;
      } else {
        sum_of_days += 28 % 7;
      }
    } else {
      sum_of_days += 30 % 7;
    }
  }
  sum_of_days += (day - 1) % 7;
  return (sum_of_days + first_day) % 7;
}


x86 assembly (clang, -O0):
<day_of_week>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x6,-0x1c(%rbp)
cmpl   $0x7d0,-0x10(%rbp)
jge    114d <day_of_week+0x3d>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <day_of_week+0x3d1>
cmpl   $0x1,-0xc(%rbp)
je     1193 <day_of_week+0x83>
cmpl   $0x3,-0xc(%rbp)
je     1193 <day_of_week+0x83>
cmpl   $0x5,-0xc(%rbp)
je     1193 <day_of_week+0x83>
cmpl   $0x7,-0xc(%rbp)
je     1193 <day_of_week+0x83>
cmpl   $0x8,-0xc(%rbp)
je     1193 <day_of_week+0x83>
cmpl   $0xa,-0xc(%rbp)
je     1193 <day_of_week+0x83>
cmpl   $0xc,-0xc(%rbp)
jne    11c4 <day_of_week+0xb4>
cmpl   $0x1f,-0x8(%rbp)
jg     11a7 <day_of_week+0x97>
cmpl   $0x1,-0x8(%rbp)
jge    11bf <day_of_week+0xaf>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <day_of_week+0x3d1>
jmp    12e3 <day_of_week+0x1d3>
cmpl   $0x2,-0xc(%rbp)
jne    12ad <day_of_week+0x19d>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1237 <day_of_week+0x127>
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1228 <day_of_week+0x118>
mov    -0x10(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1219 <day_of_week+0x109>
mov    $0x1,%al
test   $0x1,%al
jne    1246 <day_of_week+0x136>
jmp    1277 <day_of_week+0x167>
xor    %eax,%eax
test   $0x1,%al
jne    1246 <day_of_week+0x136>
jmp    1277 <day_of_week+0x167>
mov    $0x1,%al
test   $0x1,%al
jne    1246 <day_of_week+0x136>
jmp    1277 <day_of_week+0x167>
xor    %eax,%eax
test   $0x1,%al
jne    1246 <day_of_week+0x136>
jmp    1277 <day_of_week+0x167>
cmpl   $0x1d,-0x8(%rbp)
jg     125a <day_of_week+0x14a>
cmpl   $0x1,-0x8(%rbp)
jge    1272 <day_of_week+0x162>
lea    0xdce(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <day_of_week+0x3d1>
jmp    12a8 <day_of_week+0x198>
cmpl   $0x1c,-0x8(%rbp)
jg     128b <day_of_week+0x17b>
cmpl   $0x1,-0x8(%rbp)
jge    12a3 <day_of_week+0x193>
lea    0xd9d(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <day_of_week+0x3d1>
jmp    12a8 <day_of_week+0x198>
jmp    12de <day_of_week+0x1ce>
cmpl   $0x1e,-0x8(%rbp)
jg     12c1 <day_of_week+0x1b1>
cmpl   $0x1,-0x8(%rbp)
jge    12d9 <day_of_week+0x1c9>
lea    0xd67(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <day_of_week+0x3d1>
jmp    12de <day_of_week+0x1ce>
jmp    12e3 <day_of_week+0x1d3>
movl   $0x0,-0x18(%rbp)
movl   $0x7d0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1396 <day_of_week+0x286>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    135d <day_of_week+0x24d>
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1345 <day_of_week+0x235>
mov    -0x14(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x20(%rbp)
jmp    1352 <day_of_week+0x242>
mov    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1352 <day_of_week+0x242>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1367 <day_of_week+0x257>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    1367 <day_of_week+0x257>
mov    -0x24(%rbp),%edx
mov    $0x16d,%eax
mov    $0x16e,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
add    -0x18(%rbp),%edx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12f1 <day_of_week+0x1e1>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    14bc <day_of_week+0x3ac>
cmpl   $0x1,-0x14(%rbp)
je     13ef <day_of_week+0x2df>
cmpl   $0x3,-0x14(%rbp)
je     13ef <day_of_week+0x2df>
cmpl   $0x5,-0x14(%rbp)
je     13ef <day_of_week+0x2df>
cmpl   $0x7,-0x14(%rbp)
je     13ef <day_of_week+0x2df>
cmpl   $0x8,-0x14(%rbp)
je     13ef <day_of_week+0x2df>
cmpl   $0xa,-0x14(%rbp)
je     13ef <day_of_week+0x2df>
cmpl   $0xc,-0x14(%rbp)
jne    13fd <day_of_week+0x2ed>
mov    -0x18(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x18(%rbp)
jmp    14a9 <day_of_week+0x399>
cmpl   $0x2,-0x14(%rbp)
jne    149b <day_of_week+0x38b>
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1470 <day_of_week+0x360>
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1461 <day_of_week+0x351>
mov    -0x10(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1452 <day_of_week+0x342>
mov    $0x1,%al
test   $0x1,%al
jne    147f <day_of_week+0x36f>
jmp    148d <day_of_week+0x37d>
xor    %eax,%eax
test   $0x1,%al
jne    147f <day_of_week+0x36f>
jmp    148d <day_of_week+0x37d>
mov    $0x1,%al
test   $0x1,%al
jne    147f <day_of_week+0x36f>
jmp    148d <day_of_week+0x37d>
xor    %eax,%eax
test   $0x1,%al
jne    147f <day_of_week+0x36f>
jmp    148d <day_of_week+0x37d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1496 <day_of_week+0x386>
mov    -0x18(%rbp),%eax
add    $0x0,%eax
mov    %eax,-0x18(%rbp)
jmp    14a4 <day_of_week+0x394>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    14a9 <day_of_week+0x399>
jmp    14ae <day_of_week+0x39e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    139d <day_of_week+0x28d>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
add    -0x18(%rbp),%edx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<day_of_week>:
push   %rax
cmp    $0x7cf,%edx
jg     1122 <day_of_week+0x12>
lea    0x1007(%rip),%rdi
jmp    1140 <day_of_week+0x30>
cmp    $0xc,%esi
ja     1191 <day_of_week+0x81>
mov    $0x15aa,%eax
bt     %esi,%eax
jae    114c <day_of_week+0x3c>
lea    -0x20(%rdi),%eax
cmp    $0xffffffe0,%eax
ja     1199 <day_of_week+0x89>
lea    0xfc0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
cmp    $0x2,%esi
jne    1191 <day_of_week+0x81>
test   $0x3,%dl
jne    1187 <day_of_week+0x77>
imul   $0xc28f5c29,%edx,%eax
ror    $0x2,%eax
cmp    $0x28f5c28,%eax
ja     158f <day_of_week+0x47f>
mov    %edx,%eax
imul   $0x51eb851f,%rax,%rax
shr    $0x27,%rax
imul   $0x190,%eax,%eax
mov    %edx,%ecx
sub    %eax,%ecx
je     158f <day_of_week+0x47f>
lea    -0x1d(%rdi),%eax
cmp    $0xffffffe3,%eax
jbe    1139 <day_of_week+0x29>
jmp    1199 <day_of_week+0x89>
lea    -0x1f(%rdi),%eax
cmp    $0xffffffe1,%eax
jbe    1139 <day_of_week+0x29>
xor    %r10d,%r10d
cmp    $0x7d1,%edx
jb     1337 <day_of_week+0x227>
lea    -0x7d0(%rdx),%r8d
cmp    $0x8,%r8d
jae    11c3 <day_of_week+0xb3>
mov    $0x7d0,%r11d
xor    %r10d,%r10d
jmp    1550 <day_of_week+0x440>
mov    %r8d,%r9d
and    $0xfffffff8,%r9d
lea    0x7d0(%r9),%r11d
movdqa 0xe27(%rip),%xmm0
movdqa 0xe3e(%rip),%xmm12
movdqa 0xe45(%rip),%xmm15
movdqa 0xe4c(%rip),%xmm13
movdqa 0xe53(%rip),%xmm10
movdqa 0xe5a(%rip),%xmm14
pcmpeqd %xmm9,%xmm9
movdqa 0xe5c(%rip),%xmm11
mov    %r9d,%eax
pxor   %xmm6,%xmm6
pxor   %xmm7,%xmm7
nop
movdqa %xmm0,%xmm1
pmuludq %xmm12,%xmm1
pshufd $0xe8,%xmm1,%xmm5
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm12,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm5
movdqa %xmm5,%xmm1
psrld  $0x2,%xmm1
movdqa %xmm5,%xmm4
pslld  $0x1e,%xmm4
por    %xmm1,%xmm4
movdqa %xmm5,%xmm3
paddd  %xmm10,%xmm3
movdqa %xmm3,%xmm8
psrld  $0x2,%xmm8
movdqa %xmm3,%xmm1
pslld  $0x1e,%xmm1
por    %xmm8,%xmm1
movdqa %xmm5,%xmm2
psrld  $0x4,%xmm2
pslld  $0x1c,%xmm5
por    %xmm2,%xmm5
pxor   %xmm15,%xmm4
pcmpgtd %xmm13,%xmm4
pxor   %xmm15,%xmm5
pcmpgtd %xmm14,%xmm5
pxor   %xmm9,%xmm5
por    %xmm4,%xmm5
movdqa %xmm3,%xmm2
psrld  $0x4,%xmm2
pslld  $0x1c,%xmm3
por    %xmm2,%xmm3
pxor   %xmm15,%xmm1
pcmpgtd %xmm13,%xmm1
pxor   %xmm15,%xmm3
pcmpgtd %xmm14,%xmm3
pxor   %xmm9,%xmm3
por    %xmm1,%xmm3
movdqa %xmm0,%xmm1
pand   0xd2d(%rip),%xmm1
pcmpeqd 0xe05(%rip),%xmm1
pand   %xmm1,%xmm5
psubd  %xmm5,%xmm6
pand   %xmm1,%xmm3
psubd  %xmm3,%xmm7
psubd  %xmm9,%xmm6
psubd  %xmm9,%xmm7
paddd  %xmm11,%xmm0
add    $0xfffffff8,%eax
jne    1220 <day_of_week+0x110>
paddd  %xmm6,%xmm7
pshufd $0xee,%xmm7,%xmm0
paddd  %xmm7,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%r10d
cmp    %r9d,%r8d
jne    1550 <day_of_week+0x440>
cmp    $0x2,%esi
jl     14d6 <day_of_week+0x3c6>
add    $0x3,%r10d
cmp    $0x2,%esi
je     14d6 <day_of_week+0x3c6>
imul   $0xc28f5c29,%edx,%eax
add    $0x51eb850,%eax
mov    %eax,%ecx
ror    $0x2,%ecx
cmp    $0x28f5c29,%ecx
setae  %cl
ror    $0x4,%eax
cmp    $0xa3d70b,%eax
setb   %al
or     %cl,%al
test   $0x3,%dl
sete   %cl
and    %al,%cl
movzbl %cl,%eax
add    %eax,%r10d
cmp    $0x3,%esi
je     14d6 <day_of_week+0x3c6>
lea    -0x3(%rsi),%r8d
mov    $0x3,%ecx
cmp    $0x8,%r8d
jb     14a0 <day_of_week+0x390>
mov    %r8d,%edx
and    $0xfffffff8,%edx
lea    0x3(%rdx),%ecx
movd   %r10d,%xmm1
movdqa 0xccd(%rip),%xmm4
pxor   %xmm0,%xmm0
movdqa 0xcd0(%rip),%xmm8
movdqa 0xcd7(%rip),%xmm9
movdqa 0xcde(%rip),%xmm10
movdqa 0xce5(%rip),%xmm11
movdqa 0xc8c(%rip),%xmm14
movdqa 0xce3(%rip),%xmm12
movdqa 0xcea(%rip),%xmm13
mov    %edx,%eax
nopl   0x0(%rax,%rax,1)
movdqa %xmm4,%xmm3
paddd  %xmm8,%xmm3
movdqa %xmm4,%xmm5
pand   %xmm9,%xmm5
movdqa %xmm3,%xmm7
pand   %xmm9,%xmm7
pcmpeqd %xmm10,%xmm5
pcmpeqd %xmm10,%xmm7
movdqa %xmm4,%xmm6
pand   %xmm11,%xmm6
movdqa %xmm3,%xmm2
pand   %xmm11,%xmm2
pcmpeqd %xmm14,%xmm6
por    %xmm5,%xmm6
pcmpeqd %xmm14,%xmm2
por    %xmm7,%xmm2
movdqa %xmm4,%xmm5
pcmpeqd %xmm12,%xmm5
por    %xmm6,%xmm5
psubd  %xmm5,%xmm1
pcmpeqd %xmm12,%xmm3
por    %xmm2,%xmm3
psubd  %xmm3,%xmm0
paddd  %xmm13,%xmm1
paddd  %xmm13,%xmm0
paddd  %xmm14,%xmm4
add    $0xfffffff8,%eax
jne    1400 <day_of_week+0x2f0>
paddd  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%r10d
cmp    %edx,%r8d
je     14d6 <day_of_week+0x3c6>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
and    $0x7ffffff9,%eax
cmp    $0x1,%eax
sete   %al
mov    %ecx,%edx
and    $0x7ffffffd,%edx
cmp    $0x8,%edx
sete   %dl
or     %al,%dl
cmp    $0xc,%ecx
sete   %al
or     %dl,%al
movzbl %al,%eax
add    %eax,%r10d
add    $0x2,%r10d
add    $0x1,%ecx
cmp    %ecx,%esi
jne    14a0 <day_of_week+0x390>
mov    %edi,%eax
add    $0xffffffff,%eax
cltq
imul   $0xffffffff92492493,%rax,%rax
shr    $0x20,%rax
add    %edi,%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x2,%eax
add    %ecx,%eax
lea    0x0(,%rax,8),%ecx
sub    %ecx,%eax
add    %edi,%eax
add    $0xffffffff,%eax
lea    (%r10,%rax,1),%ecx
add    $0x6,%ecx
add    %r10d,%eax
movslq %ecx,%rcx
imul   $0xffffffff92492493,%rcx,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
add    $0x6,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %ecx,%eax
add    $0x6,%eax
pop    %rcx
ret
nopl   0x0(%rax)
add    %eax,%r10d
add    $0x1,%r11d
cmp    %r11d,%edx
je     1337 <day_of_week+0x227>
mov    $0x1,%eax
test   $0x3,%r11b
jne    1540 <day_of_week+0x430>
mov    %r11d,%eax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rax
shr    $0x25,%rax
imul   $0x64,%eax,%eax
shr    $0x27,%rcx
imul   $0x190,%ecx,%ecx
cmp    %r11d,%eax
setne  %al
cmp    %r11d,%ecx
sete   %cl
or     %al,%cl
movzbl %cl,%eax
add    $0x1,%eax
jmp    1540 <day_of_week+0x430>
lea    -0x1e(%rdi),%eax
cmp    $0xffffffe2,%eax
jbe    1139 <day_of_week+0x29>
jmp    1199 <day_of_week+0x89>

LLVM IR (-O0):
@.str = [47 x i8] c"Sorry buddy, your date should be >= 1/1/2000!\0A\00"
@.str.1 = [40 x i8] c"Sorry buddy, your date is not correct!\0A\00"
define i32 @day_of_week(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 6, i32* %10
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 2000
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %200
15: ; preds = %3
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 1
br i1 %17, label %36, label %18
18: ; preds = %15
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 3
br i1 %20, label %36, label %21
21: ; preds = %18
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 5
br i1 %23, label %36, label %24
24: ; preds = %21
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 7
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 8
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 10
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 12
br i1 %35, label %36, label %45
36: ; preds = %33, %30, %27, %24, %21, %18, %15
%37 = load i32, i32* %5
%38 = icmp sgt i32 %37, 31
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i32, i32* %5
%41 = icmp slt i32 %40, 1
br i1 %41, label %42, label %44
42: ; preds = %39, %36
%43 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %200
44: ; preds = %39
br label %93
45: ; preds = %33
%46 = load i32, i32* %6
%47 = icmp eq i32 %46, 2
br i1 %47, label %48, label %83
48: ; preds = %45
%49 = load i32, i32* %7
%50 = srem i32 %49, 4
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %63
52: ; preds = %48
%53 = load i32, i32* %7
%54 = srem i32 %53, 100
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %52
%57 = load i32, i32* %7
%58 = srem i32 %57, 400
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %56
br i1 true, label %64, label %73
61: ; preds = %56
br i1 false, label %64, label %73
62: ; preds = %52
br i1 true, label %64, label %73
63: ; preds = %48
br i1 false, label %64, label %73
64: ; preds = %63, %62, %61, %60
%65 = load i32, i32* %5
%66 = icmp sgt i32 %65, 29
br i1 %66, label %70, label %67
67: ; preds = %64
%68 = load i32, i32* %5
%69 = icmp slt i32 %68, 1
br i1 %69, label %70, label %72
70: ; preds = %67, %64
%71 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %200
72: ; preds = %67
br label %82
73: ; preds = %63, %62, %61, %60
%74 = load i32, i32* %5
%75 = icmp sgt i32 %74, 28
br i1 %75, label %79, label %76
76: ; preds = %73
%77 = load i32, i32* %5
%78 = icmp slt i32 %77, 1
br i1 %78, label %79, label %81
79: ; preds = %76, %73
%80 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %200
81: ; preds = %76
br label %82
82: ; preds = %81, %72
br label %92
83: ; preds = %45
%84 = load i32, i32* %5
%85 = icmp sgt i32 %84, 30
br i1 %85, label %89, label %86
86: ; preds = %83
%87 = load i32, i32* %5
%88 = icmp slt i32 %87, 1
br i1 %88, label %89, label %91
89: ; preds = %86, %83
%90 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %200
91: ; preds = %86
br label %92
92: ; preds = %91, %82
br label %93
93: ; preds = %92, %44
store i32 0, i32* %9
store i32 2000, i32* %8
br label %94
94: ; preds = %124, %93
%95 = load i32, i32* %8
%96 = load i32, i32* %7
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %127
98: ; preds = %94
%99 = load i32, i32* %8
%100 = srem i32 %99, 4
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %115
102: ; preds = %98
%103 = load i32, i32* %8
%104 = srem i32 %103, 100
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %112
106: ; preds = %102
%107 = load i32, i32* %8
%108 = srem i32 %107, 400
%109 = icmp eq i32 %108, 0
%110 = zext i1 %109 to i64
%111 = select i1 %109, i32 1, i32 0
br label %113
112: ; preds = %102
br label %113
113: ; preds = %112, %106
%114 = phi i32 [ %111, %106 ], [ 1, %112 ]
br label %116
115: ; preds = %98
br label %116
116: ; preds = %115, %113
%117 = phi i32 [ %114, %113 ], [ 0, %115 ]
%118 = icmp eq i32 %117, 1
%119 = zext i1 %118 to i64
%120 = select i1 %118, i32 366, i32 365
%121 = srem i32 %120, 7
%122 = load i32, i32* %9
%123 = add nsw i32 %122, %121
store i32 %123, i32* %9
br label %124
124: ; preds = %116
%125 = load i32, i32* %8
%126 = add nsw i32 %125, 1
store i32 %126, i32* %8
br label %94
127: ; preds = %94
store i32 1, i32* %8
br label %128
128: ; preds = %187, %127
%129 = load i32, i32* %8
%130 = load i32, i32* %6
%131 = icmp slt i32 %129, %130
br i1 %131, label %132, label %190
132: ; preds = %128
%133 = load i32, i32* %8
%134 = icmp eq i32 %133, 1
br i1 %134, label %153, label %135
135: ; preds = %132
%136 = load i32, i32* %8
%137 = icmp eq i32 %136, 3
br i1 %137, label %153, label %138
138: ; preds = %135
%139 = load i32, i32* %8
%140 = icmp eq i32 %139, 5
br i1 %140, label %153, label %141
141: ; preds = %138
%142 = load i32, i32* %8
%143 = icmp eq i32 %142, 7
br i1 %143, label %153, label %144
144: ; preds = %141
%145 = load i32, i32* %8
%146 = icmp eq i32 %145, 8
br i1 %146, label %153, label %147
147: ; preds = %144
%148 = load i32, i32* %8
%149 = icmp eq i32 %148, 10
br i1 %149, label %153, label %150
150: ; preds = %147
%151 = load i32, i32* %8
%152 = icmp eq i32 %151, 12
br i1 %152, label %153, label %156
153: ; preds = %150, %147, %144, %141, %138, %135, %132
%154 = load i32, i32* %9
%155 = add nsw i32 %154, 3
store i32 %155, i32* %9
br label %186
156: ; preds = %150
%157 = load i32, i32* %8
%158 = icmp eq i32 %157, 2
br i1 %158, label %159, label %182
159: ; preds = %156
%160 = load i32, i32* %7
%161 = srem i32 %160, 4
%162 = icmp eq i32 %161, 0
br i1 %162, label %163, label %174
163: ; preds = %159
%164 = load i32, i32* %7
%165 = srem i32 %164, 100
%166 = icmp eq i32 %165, 0
br i1 %166, label %167, label %173
167: ; preds = %163
%168 = load i32, i32* %7
%169 = srem i32 %168, 400
%170 = icmp eq i32 %169, 0
br i1 %170, label %171, label %172
171: ; preds = %167
br i1 true, label %175, label %178
172: ; preds = %167
br i1 false, label %175, label %178
173: ; preds = %163
br i1 true, label %175, label %178
174: ; preds = %159
br i1 false, label %175, label %178
175: ; preds = %174, %173, %172, %171
%176 = load i32, i32* %9
%177 = add nsw i32 %176, 1
store i32 %177, i32* %9
br label %181
178: ; preds = %174, %173, %172, %171
%179 = load i32, i32* %9
%180 = add nsw i32 %179, 0
store i32 %180, i32* %9
br label %181
181: ; preds = %178, %175
br label %185
182: ; preds = %156
%183 = load i32, i32* %9
%184 = add nsw i32 %183, 2
store i32 %184, i32* %9
br label %185
185: ; preds = %182, %181
br label %186
186: ; preds = %185, %153
br label %187
187: ; preds = %186
%188 = load i32, i32* %8
%189 = add nsw i32 %188, 1
store i32 %189, i32* %8
br label %128
190: ; preds = %128
%191 = load i32, i32* %5
%192 = sub nsw i32 %191, 1
%193 = srem i32 %192, 7
%194 = load i32, i32* %9
%195 = add nsw i32 %194, %193
store i32 %195, i32* %9
%196 = load i32, i32* %9
%197 = load i32, i32* %10
%198 = add nsw i32 %196, %197
%199 = srem i32 %198, 7
store i32 %199, i32* %4
br label %200
200: ; preds = %190, %89, %79, %70, %42, %13
%201 = load i32, i32* %4
ret i32 %201
}

LLVM IR (-O2):
@str.4 = [39 x i8] c"Sorry buddy, your date is not correct!\00"
@str.5 = [46 x i8] c"Sorry buddy, your date should be >= 1/1/2000!\00"
define i32 @day_of_week(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %2, 2000
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.5, i64 0, i64 0))
br label %178
7: ; preds = %3
switch i32 %1, label %32 [
i32 12, label %8
i32 10, label %8
i32 8, label %8
i32 7, label %8
i32 5, label %8
i32 3, label %8
i32 1, label %8
i32 2, label %13
]
8: ; preds = %7, %7, %7, %7, %7, %7, %7
%9 = add i32 %0, -32
%10 = icmp ult i32 %9, -31
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.4, i64 0, i64 0))
br label %178
13: ; preds = %7
%14 = and i32 %2, 3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = urem i32 %2, 100
%18 = icmp ne i32 %17, 0
%19 = urem i32 %2, 400
%20 = icmp eq i32 %19, 0
%21 = or i1 %18, %20
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = add i32 %0, -30
%24 = icmp ult i32 %23, -29
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.4, i64 0, i64 0))
br label %178
27: ; preds = %16, %13
%28 = add i32 %0, -29
%29 = icmp ult i32 %28, -28
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.4, i64 0, i64 0))
br label %178
32: ; preds = %7
%33 = add i32 %0, -31
%34 = icmp ult i32 %33, -30
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.4, i64 0, i64 0))
br label %178
37: ; preds = %27, %22, %32, %8
%38 = icmp ugt i32 %2, 2000
br i1 %38, label %39, label %81
39: ; preds = %37
%40 = add i32 %2, -2000
%41 = icmp ult i32 %40, 8
br i1 %41, label %78, label %42
42: ; preds = %39
%43 = and i32 %40, -8
%44 = add i32 %43, 2000
br label %45
45: ; preds = %45, %42
%46 = phi i32 [ 0, %42 ], [ %71, %45 ]
%47 = phi <4 x i32> [ zeroinitializer, %42 ], [ %69, %45 ]
%48 = phi <4 x i32> [ zeroinitializer, %42 ], [ %70, %45 ]
%49 = phi <4 x i32> [ <i32 2000, i32 2001, i32 2002, i32 2003>, %42 ], [ %72, %45 ]
%50 = add <4 x i32> %49, <i32 4, i32 4, i32 4, i32 4>
%51 = and <4 x i32> %49, <i32 3, i32 3, i32 3, i32 3>
%52 = and <4 x i32> %49, <i32 3, i32 3, i32 3, i32 3>
%53 = icmp eq <4 x i32> %51, zeroinitializer
%54 = icmp eq <4 x i32> %52, zeroinitializer
%55 = urem <4 x i32> %49, <i32 100, i32 100, i32 100, i32 100>
%56 = urem <4 x i32> %50, <i32 100, i32 100, i32 100, i32 100>
%57 = icmp ne <4 x i32> %55, zeroinitializer
%58 = icmp ne <4 x i32> %56, zeroinitializer
%59 = urem <4 x i32> %49, <i32 400, i32 400, i32 400, i32 400>
%60 = urem <4 x i32> %50, <i32 400, i32 400, i32 400, i32 400>
%61 = icmp eq <4 x i32> %59, zeroinitializer
%62 = icmp eq <4 x i32> %60, zeroinitializer
%63 = or <4 x i1> %57, %61
%64 = or <4 x i1> %58, %62
%65 = select <4 x i1> %53, <4 x i1> %63, <4 x i1> zeroinitializer
%66 = select <4 x i1> %65, <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%67 = select <4 x i1> %54, <4 x i1> %64, <4 x i1> zeroinitializer
%68 = select <4 x i1> %67, <4 x i32> <i32 2, i32 2, i32 2, i32 2>, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
%69 = add <4 x i32> %66, %47
%70 = add <4 x i32> %68, %48
%71 = add nuw i32 %46, 8
%72 = add <4 x i32> %49, <i32 8, i32 8, i32 8, i32 8>
%73 = icmp eq i32 %71, %43
br i1 %73, label %74, label %45
74: ; preds = %45
%75 = add <4 x i32> %70, %69
%76 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %75)
%77 = icmp eq i32 %40, %43
br i1 %77, label %81, label %78
78: ; preds = %39, %74
%79 = phi i32 [ 0, %39 ], [ %76, %74 ]
%80 = phi i32 [ 2000, %39 ], [ %44, %74 ]
br label %140
81: ; preds = %152, %74, %37
%82 = phi i32 [ 0, %37 ], [ %76, %74 ], [ %154, %152 ]
%83 = icmp sgt i32 %1, 1
br i1 %83, label %84, label %171
84: ; preds = %81
%85 = add nsw i32 %82, 3
%86 = icmp eq i32 %1, 2
br i1 %86, label %171, label %87
87: ; preds = %84
%88 = srem i32 %2, 100
%89 = icmp ne i32 %88, 0
%90 = srem i32 %2, 400
%91 = icmp eq i32 %90, 0
%92 = or i1 %89, %91
%93 = and i32 %2, 3
%94 = icmp eq i32 %93, 0
%95 = and i1 %94, %92
%96 = zext i1 %95 to i32
%97 = add nsw i32 %85, %96
%98 = icmp eq i32 %1, 3
br i1 %98, label %171, label %99
99: ; preds = %87
%100 = add i32 %1, -3
%101 = icmp ult i32 %100, 8
br i1 %101, label %137, label %102
102: ; preds = %99
%103 = and i32 %100, -8
%104 = or i32 %103, 3
%105 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %97, i64 0
br label %106
106: ; preds = %106, %102
%107 = phi i32 [ 0, %102 ], [ %130, %106 ]
%108 = phi <4 x i32> [ %105, %102 ], [ %128, %106 ]
%109 = phi <4 x i32> [ zeroinitializer, %102 ], [ %129, %106 ]
%110 = phi <4 x i32> [ <i32 3, i32 4, i32 5, i32 6>, %102 ], [ %131, %106 ]
%111 = add <4 x i32> %110, <i32 4, i32 4, i32 4, i32 4>
%112 = and <4 x i32> %110, <i32 2147483641, i32 2147483641, i32 2147483641, i32 2147483641>
%113 = and <4 x i32> %111, <i32 2147483641, i32 2147483641, i32 2147483641, i32 2147483641>
%114 = icmp eq <4 x i32> %112, <i32 1, i32 1, i32 1, i32 1>
%115 = icmp eq <4 x i32> %113, <i32 1, i32 1, i32 1, i32 1>
%116 = and <4 x i32> %110, <i32 2147483645, i32 2147483645, i32 2147483645, i32 2147483645>
%117 = and <4 x i32> %111, <i32 2147483645, i32 2147483645, i32 2147483645, i32 2147483645>
%118 = icmp eq <4 x i32> %116, <i32 8, i32 8, i32 8, i32 8>
%119 = icmp eq <4 x i32> %117, <i32 8, i32 8, i32 8, i32 8>
%120 = or <4 x i1> %118, %114
%121 = or <4 x i1> %119, %115
%122 = icmp eq <4 x i32> %110, <i32 12, i32 12, i32 12, i32 12>
%123 = icmp eq <4 x i32> %111, <i32 12, i32 12, i32 12, i32 12>
%124 = select <4 x i1> %120, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x i1> %122
%125 = select <4 x i1> %121, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x i1> %123
%126 = select <4 x i1> %124, <4 x i32> <i32 3, i32 3, i32 3, i32 3>, <4 x i32> <i32 2, i32 2, i32 2, i32 2>
%127 = select <4 x i1> %125, <4 x i32> <i32 3, i32 3, i32 3, i32 3>, <4 x i32> <i32 2, i32 2, i32 2, i32 2>
%128 = add <4 x i32> %108, %126
%129 = add <4 x i32> %109, %127
%130 = add nuw i32 %107, 8
%131 = add <4 x i32> %110, <i32 8, i32 8, i32 8, i32 8>
%132 = icmp eq i32 %130, %103
br i1 %132, label %133, label %106
133: ; preds = %106
%134 = add <4 x i32> %129, %128
%135 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %134)
%136 = icmp eq i32 %100, %103
br i1 %136, label %171, label %137
137: ; preds = %99, %133
%138 = phi i32 [ %97, %99 ], [ %135, %133 ]
%139 = phi i32 [ 3, %99 ], [ %104, %133 ]
br label %157
140: ; preds = %78, %152
%141 = phi i32 [ %154, %152 ], [ %79, %78 ]
%142 = phi i32 [ %155, %152 ], [ %80, %78 ]
%143 = and i32 %142, 3
%144 = icmp eq i32 %143, 0
br i1 %144, label %145, label %152
145: ; preds = %140
%146 = urem i32 %142, 100
%147 = icmp ne i32 %146, 0
%148 = urem i32 %142, 400
%149 = icmp eq i32 %148, 0
%150 = or i1 %147, %149
%151 = select i1 %150, i32 2, i32 1
br label %152
152: ; preds = %145, %140
%153 = phi i32 [ 1, %140 ], [ %151, %145 ]
%154 = add nuw nsw i32 %153, %141
%155 = add nuw nsw i32 %142, 1
%156 = icmp eq i32 %155, %2
br i1 %156, label %81, label %140
157: ; preds = %137, %157
%158 = phi i32 [ %168, %157 ], [ %138, %137 ]
%159 = phi i32 [ %169, %157 ], [ %139, %137 ]
%160 = and i32 %159, 2147483641
%161 = icmp eq i32 %160, 1
%162 = and i32 %159, 2147483645
%163 = icmp eq i32 %162, 8
%164 = or i1 %163, %161
%165 = icmp eq i32 %159, 12
%166 = select i1 %164, i1 true, i1 %165
%167 = select i1 %166, i32 3, i32 2
%168 = add nsw i32 %158, %167
%169 = add nuw nsw i32 %159, 1
%170 = icmp eq i32 %169, %1
br i1 %170, label %171, label %157
171: ; preds = %157, %133, %84, %87, %81
%172 = phi i32 [ %82, %81 ], [ %85, %84 ], [ %97, %87 ], [ %135, %133 ], [ %168, %157 ]
%173 = add nsw i32 %0, -1
%174 = srem i32 %173, 7
%175 = add nsw i32 %174, 6
%176 = add i32 %175, %172
%177 = srem i32 %176, 7
br label %178
178: ; preds = %171, %35, %30, %25, %11, %5
%179 = phi i32 [ -1, %5 ], [ -1, %11 ], [ %177, %171 ], [ -1, %25 ], [ -1, %30 ], [ -1, %35 ]
ret i32 %179
}