#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 */
double CLOCKS_PER_SEC;
double clock();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end;
  unsigned short int monthEnds[12] = {31, 28, 31, 30, 31, 30,
                                      31, 31, 30, 31, 30, 31};
  unsigned short int counter = 0, totalSundays = 0;
  printf("Algorithm starts, please wait...\n");
  start = clock();
  for (unsigned short int i = 0; i < 12; i++) {
    counter += monthEnds[i];
  }
  for (unsigned short int j = 1901; j <= 2000; j++) {
    if (!(j % 4) || (!(j % 100) && !(j % 400))) {
      monthEnds[1] = 29;
    } else {
      monthEnds[1] = 28;
    }
    for (unsigned short int i = 0; i < 12; i++) {
      if (!((counter - 1) % 7)) {
        totalSundays++;
      }
      counter += monthEnds[i];
    }
  }
  end = clock();
  printf("Algorithm end.\n");
  printf("Total time: %f\n", (end - start) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x30(%rbp)
movw   $0x0,-0x42(%rbp)
movw   $0x0,-0x44(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movw   $0x0,-0x46(%rbp)
movzwl -0x46(%rbp),%eax
cmp    $0xc,%eax
jge    11b4 <main+0x94>
movzwl -0x46(%rbp),%eax
movzwl -0x40(%rbp,%rax,2),%ecx
movzwl -0x42(%rbp),%eax
add    %ecx,%eax
mov    %ax,-0x42(%rbp)
mov    -0x46(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x46(%rbp)
jmp    1183 <main+0x63>
movw   $0x76d,-0x48(%rbp)
movzwl -0x48(%rbp),%eax
cmp    $0x7d0,%eax
jg     128a <main+0x16a>
movzwl -0x48(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1208 <main+0xe8>
movzwl -0x48(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1213 <main+0xf3>
movzwl -0x48(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1213 <main+0xf3>
movw   $0x1d,-0x3e(%rbp)
jmp    1219 <main+0xf9>
movw   $0x1c,-0x3e(%rbp)
movw   $0x0,-0x4a(%rbp)
movzwl -0x4a(%rbp),%eax
cmp    $0xc,%eax
jge    1274 <main+0x154>
movzwl -0x42(%rbp),%eax
sub    $0x1,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1250 <main+0x130>
mov    -0x44(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x44(%rbp)
movzwl -0x4a(%rbp),%eax
movzwl -0x40(%rbp,%rax,2),%ecx
movzwl -0x42(%rbp),%eax
add    %ecx,%eax
mov    %ax,-0x42(%rbp)
mov    -0x4a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x4a(%rbp)
jmp    121f <main+0xff>
jmp    1279 <main+0x159>
mov    -0x48(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x48(%rbp)
jmp    11ba <main+0x9a>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2d33(%rip),%rax
divsd  (%rax),%xmm0
lea    0xd8a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
mov    0x2e6f(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.monthEnds = [12 x i16] [i16 31, i16 28, i16 31, i16 30, i16 31, i16 30, i16 31, i16 31, i16 30, i16 31, i16 30, i16 31]
@.str = [34 x i8] c"Algorithm starts, please wait...\0A\00"
@.str.1 = [16 x i8] c"Algorithm end.\0A\00"
@.str.2 = [16 x i8] c"Total time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca [12 x i16]
%9 = alloca i16
%10 = alloca i16
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [12 x i16]* %8 to i8*
store i16 0, i16* %9
store i16 0, i16* %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%16 = call double (...) @clock()
store double %16, double* %6
store i16 0, i16* %11
br label %17
17: ; preds = %31, %2
%18 = load i16, i16* %11
%19 = zext i16 %18 to i32
%20 = icmp slt i32 %19, 12
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = load i16, i16* %11
%23 = zext i16 %22 to i64
%24 = getelementptr inbounds [12 x i16], [12 x i16]* %8, i64 0, i64 %23
%25 = load i16, i16* %24
%26 = zext i16 %25 to i32
%27 = load i16, i16* %9
%28 = zext i16 %27 to i32
%29 = add nsw i32 %28, %26
%30 = trunc i32 %29 to i16
store i16 %30, i16* %9
br label %31
31: ; preds = %21
%32 = load i16, i16* %11
%33 = add i16 %32, 1
store i16 %33, i16* %11
br label %17
34: ; preds = %17
store i16 1901, i16* %12
br label %35
35: ; preds = %86, %34
%36 = load i16, i16* %12
%37 = zext i16 %36 to i32
%38 = icmp sle i32 %37, 2000
br i1 %38, label %39, label %89
39: ; preds = %35
%40 = load i16, i16* %12
%41 = zext i16 %40 to i32
%42 = srem i32 %41, 4
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %54
44: ; preds = %39
%45 = load i16, i16* %12
%46 = zext i16 %45 to i32
%47 = srem i32 %46, 100
%48 = icmp ne i32 %47, 0
br i1 %48, label %56, label %49
49: ; preds = %44
%50 = load i16, i16* %12
%51 = zext i16 %50 to i32
%52 = srem i32 %51, 400
%53 = icmp ne i32 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %49, %39
%55 = getelementptr inbounds [12 x i16], [12 x i16]* %8, i64 0, i64 1
store i16 29, i16* %55
br label %58
56: ; preds = %49, %44
%57 = getelementptr inbounds [12 x i16], [12 x i16]* %8, i64 0, i64 1
store i16 28, i16* %57
br label %58
58: ; preds = %56, %54
store i16 0, i16* %13
br label %59
59: ; preds = %82, %58
%60 = load i16, i16* %13
%61 = zext i16 %60 to i32
%62 = icmp slt i32 %61, 12
br i1 %62, label %63, label %85
63: ; preds = %59
%64 = load i16, i16* %9
%65 = zext i16 %64 to i32
%66 = sub nsw i32 %65, 1
%67 = srem i32 %66, 7
%68 = icmp ne i32 %67, 0
br i1 %68, label %72, label %69
69: ; preds = %63
%70 = load i16, i16* %10
%71 = add i16 %70, 1
store i16 %71, i16* %10
br label %72
72: ; preds = %69, %63
%73 = load i16, i16* %13
%74 = zext i16 %73 to i64
%75 = getelementptr inbounds [12 x i16], [12 x i16]* %8, i64 0, i64 %74
%76 = load i16, i16* %75
%77 = zext i16 %76 to i32
%78 = load i16, i16* %9
%79 = zext i16 %78 to i32
%80 = add nsw i32 %79, %77
%81 = trunc i32 %80 to i16
store i16 %81, i16* %9
br label %82
82: ; preds = %72
%83 = load i16, i16* %13
%84 = add i16 %83, 1
store i16 %84, i16* %13
br label %59
85: ; preds = %59
br label %86
86: ; preds = %85
%87 = load i16, i16* %12
%88 = add i16 %87, 1
store i16 %88, i16* %12
br label %35
89: ; preds = %35
%90 = call double (...) @clock()
store double %90, double* %7
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%92 = load double, double* %7
%93 = load double, double* %6
%94 = fsub double %92, %93
%95 = load double, double* @CLOCKS_PER_SEC
%96 = fdiv double %94, %95
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %96)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [16 x i8] c"Total time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [33 x i8] c"Algorithm starts, please wait...\00"
@str.3 = [15 x i8] c"Algorithm end.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @clock()
%5 = tail call double (...) @clock()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%7 = fsub double %5, %4
%8 = load double, double* @CLOCKS_PER_SEC
%9 = fdiv double %7, %8
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %9)
ret i32 0
}