#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_year(int year, int month, int day, char *daytab) {
  int i = 0;
  int leap = 0;
  char count = 0;
  char *check = 0;
  leap = year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
  if (leap) {
    printf("Year is leap.\n");
  } else {
    printf("Year is _NOT_ leap.\n");
  }
  if (year < 1 || year > 2016) {
    printf("Error: year isn't in [ 1..2016 ] interval.\n");
    return -1;
  }
  if (month < 1 || month > 12) {
    printf("Error: month isn't in [ 1..12 ] interval.\n");
    return -1;
  }
  if (day < 1 || day > 31) {
    printf("Error: dey isn't in [ 1..31 ] interval.\n");
    return -1;
  } else {
    check = daytab;
    for (i = 0; i < leap * 13 + month; i++) {
      printf("* check = %d;\n", *check);
      *check++;
    }
    if (day > *check) {
      printf("Error: month is longer than may be in this month. ( day = %d and "
             "is more than %d )\n",
             day, *check);
      return -1;
    }
  }
  i = 0;
  count = 0;
  while (i < month) {
    if (count < leap * 13) {
      count++;
      *daytab++;
    } else {
      day += *daytab;
      i++;
      *daytab++;
    }
  }
  return day;
}


x86 assembly (clang, -O0):
<day_of_year>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116c <day_of_year+0x5c>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x31(%rbp)
jne    1180 <day_of_year+0x70>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11a8 <day_of_year+0x98>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b6 <day_of_year+0xa6>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     11cd <day_of_year+0xbd>
cmpl   $0x7e0,-0x8(%rbp)
jle    11e7 <day_of_year+0xd7>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <day_of_year+0x22b>
cmpl   $0x1,-0xc(%rbp)
jl     11fb <day_of_year+0xeb>
cmpl   $0xc,-0xc(%rbp)
jle    1215 <day_of_year+0x105>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <day_of_year+0x22b>
cmpl   $0x1,-0x10(%rbp)
jl     1229 <day_of_year+0x119>
cmpl   $0x1f,-0x10(%rbp)
jle    1243 <day_of_year+0x133>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <day_of_year+0x22b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
imul   $0xd,-0x20(%rbp),%ecx
add    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    1293 <day_of_year+0x183>
mov    -0x30(%rbp),%rax
movsbl (%rax),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1252 <day_of_year+0x142>
mov    -0x10(%rbp),%eax
mov    -0x30(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jle    12c9 <day_of_year+0x1b9>
mov    -0x10(%rbp),%esi
mov    -0x30(%rbp),%rax
movsbl (%rax),%edx
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <day_of_year+0x22b>
jmp    12ce <day_of_year+0x1be>
movl   $0x0,-0x1c(%rbp)
movb   $0x0,-0x21(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1335 <day_of_year+0x225>
movsbl -0x21(%rbp),%eax
imul   $0xd,-0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    130e <day_of_year+0x1fe>
mov    -0x21(%rbp),%al
add    $0x1,%al
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1330 <day_of_year+0x220>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    12d9 <day_of_year+0x1c9>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<day_of_year>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%ebp
test   $0x3,%bpl
sete   %al
imul   $0xc28f5c29,%edi,%ecx
add    $0x51eb850,%ecx
mov    %ecx,%edx
ror    $0x2,%edx
cmp    $0x28f5c29,%edx
setae  %dl
ror    $0x4,%ecx
and    %al,%dl
cmp    $0xa3d70b,%ecx
setb   %r12b
or     %dl,%r12b
lea    0xf81(%rip),%rax
lea    0xee9(%rip),%rdi
cmovne %rax,%rdi
call   1030 <puts@plt>
add    $0xfffff81f,%ebp
cmp    $0xfffff81f,%ebp
ja     119a <day_of_year+0x7a>
lea    0xf31(%rip),%rdi
jmp    11bc <day_of_year+0x9c>
lea    -0xd(%r15),%eax
cmp    $0xfffffff3,%eax
ja     11ac <day_of_year+0x8c>
lea    0xef5(%rip),%rdi
jmp    11bc <day_of_year+0x9c>
lea    -0x20(%r14),%eax
cmp    $0xffffffe1,%eax
jae    11d9 <day_of_year+0xb9>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
test   %r12b,%r12b
mov    $0xd,%ecx
cmove  %eax,%ecx
mov    %r15d,%r13d
mov    %r13,0x10(%rsp)
mov    %rcx,0x8(%rsp)
add    %rcx,%r13
lea    0xe03(%rip),%r12
xor    %ebp,%ebp
nop
movsbl (%rbx,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %ebp,%r13d
jne    1200 <day_of_year+0xe0>
movsbl (%rbx,%rbp,1),%edx
cmp    %r14d,%edx
jge    1233 <day_of_year+0x113>
lea    0xde8(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c1 <day_of_year+0xa1>
cmpl   $0x0,0x10(%rsp)
jle    11c7 <day_of_year+0xa7>
xor    %eax,%eax
xor    %ecx,%ecx
mov    0x8(%rsp),%rsi
jmp    1266 <day_of_year+0x146>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rbx),%edx
add    %edx,%r14d
add    $0x1,%ecx
add    $0x1,%rbx
cmp    %r15d,%ecx
jge    11c7 <day_of_year+0xa7>
movsbl %al,%edx
cmp    %edx,%esi
jle    1250 <day_of_year+0x130>
add    $0x1,%al
jmp    1259 <day_of_year+0x139>

LLVM IR (-O0):
@.str = [15 x i8] c"Year is leap.\0A\00"
@.str.1 = [21 x i8] c"Year is _NOT_ leap.\0A\00"
@.str.2 = [44 x i8] c"Error: year isn't in [ 1..2016 ] interval.\0A\00"
@.str.3 = [43 x i8] c"Error: month isn't in [ 1..12 ] interval.\0A\00"
@.str.4 = [41 x i8] c"Error: dey isn't in [ 1..31 ] interval.\0A\00"
@.str.5 = [15 x i8] c"* check = %d;\0A\00"
@.str.6 = [84 x i8] c"Error: month is longer than may be in this month. ( day = %d and is more than %d )\0A\00"
define i32 @day_of_year(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i8*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 0, i32* %10
store i32 0, i32* %11
store i8 0, i8* %12
store i8* null, i8** %13
%14 = load i32, i32* %6
%15 = srem i32 %14, 4
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %4
%18 = load i32, i32* %6
%19 = srem i32 %18, 100
%20 = icmp ne i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %17, %4
%22 = load i32, i32* %6
%23 = srem i32 %22, 400
%24 = icmp eq i32 %23, 0
br label %25
25: ; preds = %21, %17
%26 = phi i1 [ true, %17 ], [ %24, %21 ]
%27 = zext i1 %26 to i32
store i32 %27, i32* %11
%28 = load i32, i32* %11
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %34
32: ; preds = %25
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
%35 = load i32, i32* %6
%36 = icmp slt i32 %35, 1
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = load i32, i32* %6
%39 = icmp sgt i32 %38, 2016
br i1 %39, label %40, label %42
40: ; preds = %37, %34
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %5
br label %122
42: ; preds = %37
%43 = load i32, i32* %7
%44 = icmp slt i32 %43, 1
br i1 %44, label %48, label %45
45: ; preds = %42
%46 = load i32, i32* %7
%47 = icmp sgt i32 %46, 12
br i1 %47, label %48, label %50
48: ; preds = %45, %42
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %5
br label %122
50: ; preds = %45
%51 = load i32, i32* %8
%52 = icmp slt i32 %51, 1
br i1 %52, label %56, label %53
53: ; preds = %50
%54 = load i32, i32* %8
%55 = icmp sgt i32 %54, 31
br i1 %55, label %56, label %58
56: ; preds = %53, %50
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %5
br label %122
58: ; preds = %53
%59 = load i8*, i8** %9
store i8* %59, i8** %13
store i32 0, i32* %10
br label %60
60: ; preds = %75, %58
%61 = load i32, i32* %10
%62 = load i32, i32* %11
%63 = mul nsw i32 %62, 13
%64 = load i32, i32* %7
%65 = add nsw i32 %63, %64
%66 = icmp slt i32 %61, %65
br i1 %66, label %67, label %78
67: ; preds = %60
%68 = load i8*, i8** %13
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %70)
%72 = load i8*, i8** %13
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %13
%74 = load i8, i8* %72
br label %75
75: ; preds = %67
%76 = load i32, i32* %10
%77 = add nsw i32 %76, 1
store i32 %77, i32* %10
br label %60
78: ; preds = %60
%79 = load i32, i32* %8
%80 = load i8*, i8** %13
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp sgt i32 %79, %82
br i1 %83, label %84, label %90
84: ; preds = %78
%85 = load i32, i32* %8
%86 = load i8*, i8** %13
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str.6, i64 0, i64 0), i32 %85, i32 %88)
store i32 -1, i32* %5
br label %122
90: ; preds = %78
br label %91
91: ; preds = %90
store i32 0, i32* %10
store i8 0, i8* %12
br label %92
92: ; preds = %119, %91
%93 = load i32, i32* %10
%94 = load i32, i32* %7
%95 = icmp slt i32 %93, %94
br i1 %95, label %96, label %120
96: ; preds = %92
%97 = load i8, i8* %12
%98 = sext i8 %97 to i32
%99 = load i32, i32* %11
%100 = mul nsw i32 %99, 13
%101 = icmp slt i32 %98, %100
br i1 %101, label %102, label %108
102: ; preds = %96
%103 = load i8, i8* %12
%104 = add i8 %103, 1
store i8 %104, i8* %12
%105 = load i8*, i8** %9
%106 = getelementptr inbounds i8, i8* %105, i32 1
store i8* %106, i8** %9
%107 = load i8, i8* %105
br label %119
108: ; preds = %96
%109 = load i8*, i8** %9
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = load i32, i32* %8
%113 = add nsw i32 %112, %111
store i32 %113, i32* %8
%114 = load i32, i32* %10
%115 = add nsw i32 %114, 1
store i32 %115, i32* %10
%116 = load i8*, i8** %9
%117 = getelementptr inbounds i8, i8* %116, i32 1
store i8* %117, i8** %9
%118 = load i8, i8* %116
br label %119
119: ; preds = %108, %102
br label %92
120: ; preds = %92
%121 = load i32, i32* %8
store i32 %121, i32* %5
br label %122
122: ; preds = %120, %84, %56, %48, %40
%123 = load i32, i32* %5
ret i32 %123
}

LLVM IR (-O2):
@.str.5 = [15 x i8] c"* check = %d;\0A\00"
@.str.6 = [84 x i8] c"Error: month is longer than may be in this month. ( day = %d and is more than %d )\0A\00"
@str = [20 x i8] c"Year is _NOT_ leap.\00"
@str.7 = [40 x i8] c"Error: dey isn't in [ 1..31 ] interval.\00"
@str.8 = [42 x i8] c"Error: month isn't in [ 1..12 ] interval.\00"
@str.9 = [43 x i8] c"Error: year isn't in [ 1..2016 ] interval.\00"
@str.10 = [14 x i8] c"Year is leap.\00"
define i32 @day_of_year(i32 %0, i32 %1, i32 %2, i8* nocapture %3) {
%5 = and i32 %0, 3
%6 = icmp eq i32 %5, 0
%7 = srem i32 %0, 100
%8 = icmp ne i32 %7, 0
%9 = and i1 %6, %8
%10 = srem i32 %0, 400
%11 = icmp eq i32 %10, 0
%12 = or i1 %11, %9
%13 = select i1 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = add i32 %0, -2017
%16 = icmp ult i32 %15, -2016
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0))
br label %69
19: ; preds = %4
%20 = add i32 %1, -13
%21 = icmp ult i32 %20, -12
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.8, i64 0, i64 0))
br label %69
24: ; preds = %19
%25 = add i32 %2, -32
%26 = icmp ult i32 %25, -31
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = select i1 %12, i32 13, i32 0
%29 = add nuw nsw i32 %28, %1
br label %32
30: ; preds = %24
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.7, i64 0, i64 0))
br label %69
32: ; preds = %27, %32
%33 = phi i8* [ %38, %32 ], [ %3, %27 ]
%34 = phi i32 [ %39, %32 ], [ 0, %27 ]
%35 = load i8, i8* %33
%36 = sext i8 %35 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds i8, i8* %33, i64 1
%39 = add nuw nsw i32 %34, 1
%40 = icmp eq i32 %39, %29
br i1 %40, label %41, label %32
41: ; preds = %32
%42 = load i8, i8* %38
%43 = sext i8 %42 to i32
%44 = icmp slt i32 %43, %2
br i1 %44, label %47, label %45
45: ; preds = %41
%46 = icmp sgt i32 %1, 0
br i1 %46, label %49, label %69
47: ; preds = %41
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @.str.6, i64 0, i64 0), i32 %2, i32 %43)
br label %69
49: ; preds = %45, %63
%50 = phi i8 [ %66, %63 ], [ 0, %45 ]
%51 = phi i32 [ %65, %63 ], [ 0, %45 ]
%52 = phi i8* [ %67, %63 ], [ %3, %45 ]
%53 = phi i32 [ %64, %63 ], [ %2, %45 ]
%54 = sext i8 %50 to i32
%55 = icmp sgt i32 %28, %54
br i1 %55, label %56, label %58
56: ; preds = %49
%57 = add i8 %50, 1
br label %63
58: ; preds = %49
%59 = load i8, i8* %52
%60 = sext i8 %59 to i32
%61 = add nsw i32 %53, %60
%62 = add nsw i32 %51, 1
br label %63
63: ; preds = %58, %56
%64 = phi i32 [ %53, %56 ], [ %61, %58 ]
%65 = phi i32 [ %51, %56 ], [ %62, %58 ]
%66 = phi i8 [ %57, %56 ], [ %50, %58 ]
%67 = getelementptr inbounds i8, i8* %52, i64 1
%68 = icmp slt i32 %65, %1
br i1 %68, label %49, label %69
69: ; preds = %63, %45, %47, %30, %22, %17
%70 = phi i32 [ -1, %17 ], [ -1, %22 ], [ -1, %30 ], [ -1, %47 ], [ %2, %45 ], [ %64, %63 ]
ret i32 %70
}