#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 */
typedef int /*<<< orphan*/ days_in_month;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int count = 0;
  int num_days = 365;
  int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int len = sizeof(days_in_month) / sizeof(days_in_month[0]);
  for (int i = 1901; i <= 2000; i++) {
    for (int j = 0; j < len; j++) {
      if (i % 4 == 0)
        days_in_month[1] = 29;
      else
        days_in_month[1] = 28;
      if ((num_days + 1) % 7 == 0)
        ++count;
      num_days += days_in_month[j];
    }
  }
  printf("# of Sundays that fall on 1st of the month: %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x16d,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeb1(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
movl   $0xc,-0x54(%rbp)
movl   $0x76d,-0x58(%rbp)
cmpl   $0x7d0,-0x58(%rbp)
jg     11fd <main+0xdd>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    11ea <main+0xca>
mov    -0x58(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a7 <main+0x87>
movl   $0x1d,-0x4c(%rbp)
jmp    11ae <main+0x8e>
movl   $0x1c,-0x4c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ce <main+0xae>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    117b <main+0x5b>
jmp    11ef <main+0xcf>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1167 <main+0x47>
mov    -0x14(%rbp),%esi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movaps 0xf05(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,(%rsp)
xor    %esi,%esi
mov    $0x16d,%eax
mov    $0x76d,%r8d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edx,%edx
test   $0x3,%r8b
sete   %dl
or     $0x1c,%edx
mov    $0x1,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edx,0x4(%rsp)
imul   $0xb6db6db7,%eax,%ecx
add    $0xc9249249,%ecx
cmp    $0x24924925,%ecx
adc    $0x0,%esi
add    -0x4(%rsp,%rdi,4),%eax
mov    %edx,0x4(%rsp)
imul   $0xb6db6db7,%eax,%ecx
add    $0xc9249249,%ecx
cmp    $0x24924925,%ecx
adc    $0x0,%esi
add    (%rsp,%rdi,4),%eax
add    $0x2,%rdi
cmp    $0xd,%rdi
jne    1170 <main+0x60>
add    $0x1,%r8d
cmp    $0x7d1,%r8d
jne    1150 <main+0x40>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.main.days_in_month = [12 x i32] [i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@.str = [48 x i8] c"# of Sundays that fall on 1st of the month: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [12 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 365, i32* %7
%12 = bitcast [12 x i32]* %8 to i8*
store i32 12, i32* %9
store i32 1901, i32* %10
br label %13
13: ; preds = %48, %2
%14 = load i32, i32* %10
%15 = icmp sle i32 %14, 2000
br i1 %15, label %16, label %51
16: ; preds = %13
store i32 0, i32* %11
br label %17
17: ; preds = %44, %16
%18 = load i32, i32* %11
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %47
21: ; preds = %17
%22 = load i32, i32* %10
%23 = srem i32 %22, 4
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i64 0, i64 1
store i32 29, i32* %26
br label %29
27: ; preds = %21
%28 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i64 0, i64 1
store i32 28, i32* %28
br label %29
29: ; preds = %27, %25
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
%32 = srem i32 %31, 7
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %37
37: ; preds = %34, %29
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = load i32, i32* %7
%43 = add nsw i32 %42, %41
store i32 %43, i32* %7
br label %44
44: ; preds = %37
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
store i32 %46, i32* %11
br label %17
47: ; preds = %17
br label %48
48: ; preds = %47
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %13
51: ; preds = %13
%52 = load i32, i32* %6
%53 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %52)
ret i32 0
}

LLVM IR (-O2):
@__const.main.days_in_month = [12 x i32] [i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@.str = [48 x i8] c"# of Sundays that fall on 1st of the month: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [12 x i32]
%4 = bitcast [12 x i32]* %3 to i8*
%5 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 1
br label %6
6: ; preds = %2, %16
%7 = phi i32 [ 1901, %2 ], [ %17, %16 ]
%8 = phi i32 [ 365, %2 ], [ %39, %16 ]
%9 = phi i32 [ 0, %2 ], [ %36, %16 ]
%10 = and i32 %7, 3
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i32 29, i32 28
%13 = select i1 %11, i32 29, i32 28
br label %19
14: ; preds = %16
%15 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %36)
ret i32 0
16: ; preds = %19
%17 = add nuw nsw i32 %7, 1
%18 = icmp eq i32 %17, 2001
br i1 %18, label %14, label %6
19: ; preds = %19, %6
%20 = phi i64 [ 0, %6 ], [ %40, %19 ]
%21 = phi i32 [ %8, %6 ], [ %39, %19 ]
%22 = phi i32 [ %9, %6 ], [ %36, %19 ]
store i32 %12, i32* %5
%23 = add nsw i32 %21, 1
%24 = srem i32 %23, 7
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = add nsw i32 %22, %26
%28 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %20
%29 = load i32, i32* %28
%30 = add nsw i32 %29, %21
%31 = or i64 %20, 1
store i32 %13, i32* %5
%32 = add nsw i32 %30, 1
%33 = srem i32 %32, 7
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = add nsw i32 %27, %35
%37 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %31
%38 = load i32, i32* %37
%39 = add nsw i32 %38, %30
%40 = add nuw nsw i64 %20, 2
%41 = icmp eq i64 %40, 12
br i1 %41, label %16, label %19
}