#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 /*<<< orphan*/ scanf(char *, int *, int *, int *);
void main() {
  int year, month, day, sum, leap;
  printf("\nPlease input the year,month,day:\n");
  scanf("%d,%d,%d", &year, &month, &day);
  switch (month) {
  case 1:
    sum = 0;
    break;
  case 2:
    sum = 31;
    break;
  case 3:
    sum = 59;
    break;
  case 4:
    sum = 90;
    break;
  case 5:
    sum = 120;
    break;
  case 6:
    sum = 151;
    break;
  case 7:
    sum = 181;
    break;
  case 8:
    sum = 212;
    break;
  case 9:
    sum = 243;
    break;
  case 10:
    sum = 273;
    break;
  case 11:
    sum = 303;
    break;
  case 12:
    sum = 333;
    break;
  default:
    printf("month error!");
  }
  if ((0 == year % 400) || (0 == year % 4 || 0 != year % 100))
    leap = 1;
  else
    leap = 0;
  if (1 == month || 2 == month) {
    sum = sum + day;
    printf("the number of the day in this year is: %d\n", sum);
  } else {
    if (1 == leap) {
      sum = sum + day + 1;
      printf("the number of the day in this year is: %d\n", sum);
    } else {
      sum = sum + day;
      printf("the number of the day in this year is: %d\n", sum);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xf01(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xb,%eax
ja     1207 <main+0xe7>
mov    -0x20(%rbp),%rax
lea    0xe92(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0x1f,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0x3b,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0x5a,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0x78,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0x97,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0xb5,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0xd4,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0xf3,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0x111,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0x12f,-0x10(%rbp)
jmp    1215 <main+0xf5>
movl   $0x14d,-0x10(%rbp)
jmp    1215 <main+0xf5>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
je     1254 <main+0x134>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
je     1254 <main+0x134>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
je     1260 <main+0x140>
movl   $0x1,-0x14(%rbp)
jmp    1267 <main+0x147>
movl   $0x0,-0x14(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
je     1283 <main+0x163>
mov    $0x2,%eax
cmp    -0x8(%rbp),%eax
jne    12a2 <main+0x182>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f1 <main+0x1d1>
mov    $0x1,%eax
cmp    -0x14(%rbp),%eax
jne    12d2 <main+0x1b2>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ec <main+0x1cc>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f1 <main+0x1d1>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
lea    0xee9(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <scanf@plt>
mov    0x10(%rsp),%ecx
add    $0xffffffff,%ecx
cmp    $0xb,%ecx
ja     11cb <main+0x9b>
mov    $0x3b,%eax
xor    %esi,%esi
lea    0xe8b(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x1f,%esi
add    0xc(%rsp),%esi
jmp    1236 <main+0x106>
mov    $0x5a,%eax
jmp    11eb <main+0xbb>
mov    $0x78,%eax
jmp    11eb <main+0xbb>
mov    $0x97,%eax
jmp    11eb <main+0xbb>
mov    $0xb5,%eax
jmp    11eb <main+0xbb>
mov    $0xd4,%eax
jmp    11eb <main+0xbb>
mov    $0xf3,%eax
jmp    11eb <main+0xbb>
mov    $0x111,%eax
jmp    11eb <main+0xbb>
mov    $0x12f,%eax
jmp    11eb <main+0xbb>
mov    $0x14d,%eax
jmp    11eb <main+0xbb>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%ecx
add    $0xffffffff,%ecx
cmp    $0x1,%ecx
ja     11eb <main+0xbb>
add    0xc(%rsp),%esi
jmp    1236 <main+0x106>
movslq 0x14(%rsp),%rcx
imul   $0xc28f5c29,%ecx,%edx
add    $0x51eb850,%edx
ror    $0x4,%edx
mov    0xc(%rsp),%esi
cmp    $0xa3d70b,%edx
jb     1231 <main+0x101>
mov    %ecx,%edx
and    $0x3,%edx
je     1231 <main+0x101>
imul   $0x51eb851f,%rcx,%rdx
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x25,%rdx
add    %edi,%edx
imul   $0x64,%edx,%edx
sub    %edx,%ecx
jne    1231 <main+0x101>
add    %eax,%esi
jmp    1236 <main+0x106>
add    %eax,%esi
add    $0x1,%esi
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0APlease input the year,month,day:\0A\00"
@.str.1 = [9 x i8] c"%d,%d,%d\00"
@.str.2 = [13 x i8] c"month error!\00"
@.str.3 = [43 x i8] c"the number of the day in this year is: %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%8 = load i32, i32* %2
switch i32 %8, label %21 [
i32 1, label %9
i32 2, label %10
i32 3, label %11
i32 4, label %12
i32 5, label %13
i32 6, label %14
i32 7, label %15
i32 8, label %16
i32 9, label %17
i32 10, label %18
i32 11, label %19
i32 12, label %20
]
9: ; preds = %0
store i32 0, i32* %4
br label %23
10: ; preds = %0
store i32 31, i32* %4
br label %23
11: ; preds = %0
store i32 59, i32* %4
br label %23
12: ; preds = %0
store i32 90, i32* %4
br label %23
13: ; preds = %0
store i32 120, i32* %4
br label %23
14: ; preds = %0
store i32 151, i32* %4
br label %23
15: ; preds = %0
store i32 181, i32* %4
br label %23
16: ; preds = %0
store i32 212, i32* %4
br label %23
17: ; preds = %0
store i32 243, i32* %4
br label %23
18: ; preds = %0
store i32 273, i32* %4
br label %23
19: ; preds = %0
store i32 303, i32* %4
br label %23
20: ; preds = %0
store i32 333, i32* %4
br label %23
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9
%24 = load i32, i32* %1
%25 = srem i32 %24, 400
%26 = icmp eq i32 0, %25
br i1 %26, label %35, label %27
27: ; preds = %23
%28 = load i32, i32* %1
%29 = srem i32 %28, 4
%30 = icmp eq i32 0, %29
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i32, i32* %1
%33 = srem i32 %32, 100
%34 = icmp ne i32 0, %33
br i1 %34, label %35, label %36
35: ; preds = %31, %27, %23
store i32 1, i32* %5
br label %37
36: ; preds = %31
store i32 0, i32* %5
br label %37
37: ; preds = %36, %35
%38 = load i32, i32* %2
%39 = icmp eq i32 1, %38
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32, i32* %2
%42 = icmp eq i32 2, %41
br i1 %42, label %43, label %49
43: ; preds = %40, %37
%44 = load i32, i32* %4
%45 = load i32, i32* %3
%46 = add nsw i32 %44, %45
store i32 %46, i32* %4
%47 = load i32, i32* %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %47)
br label %66
49: ; preds = %40
%50 = load i32, i32* %5
%51 = icmp eq i32 1, %50
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load i32, i32* %4
%54 = load i32, i32* %3
%55 = add nsw i32 %53, %54
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
%57 = load i32, i32* %4
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %57)
br label %65
59: ; preds = %49
%60 = load i32, i32* %4
%61 = load i32, i32* %3
%62 = add nsw i32 %60, %61
store i32 %62, i32* %4
%63 = load i32, i32* %4
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %59, %52
br label %66
66: ; preds = %65, %43
ret void
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%d,%d,%d\00"
@.str.2 = [13 x i8] c"month error!\00"
@.str.3 = [43 x i8] c"the number of the day in this year is: %d\0A\00"
@str = [34 x i8] c"\0APlease input the year,month,day:\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %2
switch i32 %9, label %20 [
i32 1, label %25
i32 2, label %10
i32 3, label %29
i32 4, label %11
i32 5, label %12
i32 6, label %13
i32 7, label %14
i32 8, label %15
i32 9, label %16
i32 10, label %17
i32 11, label %18
i32 12, label %19
]
10: ; preds = %0
br label %25
11: ; preds = %0
br label %29
12: ; preds = %0
br label %29
13: ; preds = %0
br label %29
14: ; preds = %0
br label %29
15: ; preds = %0
br label %29
16: ; preds = %0
br label %29
17: ; preds = %0
br label %29
18: ; preds = %0
br label %29
19: ; preds = %0
br label %29
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* %2
%23 = add i32 %22, -1
%24 = icmp ult i32 %23, 2
br i1 %24, label %25, label %29
25: ; preds = %0, %10, %20
%26 = phi i32 [ undef, %20 ], [ 0, %0 ], [ 31, %10 ]
%27 = load i32, i32* %3
%28 = add nsw i32 %27, %26
br label %46
29: ; preds = %0, %11, %12, %13, %14, %15, %16, %17, %18, %19, %20
%30 = phi i32 [ undef, %20 ], [ 90, %11 ], [ 120, %12 ], [ 151, %13 ], [ 181, %14 ], [ 212, %15 ], [ 243, %16 ], [ 273, %17 ], [ 303, %18 ], [ 333, %19 ], [ 59, %0 ]
%31 = load i32, i32* %1
%32 = srem i32 %31, 100
%33 = icmp ne i32 %32, 0
%34 = and i32 %31, 3
%35 = icmp eq i32 %34, 0
%36 = srem i32 %31, 400
%37 = icmp eq i32 %36, 0
%38 = or i1 %37, %35
%39 = select i1 %38, i1 true, i1 %33
%40 = load i32, i32* %3
br i1 %39, label %41, label %44
41: ; preds = %29
%42 = add nuw nsw i32 %30, 1
%43 = add i32 %42, %40
br label %46
44: ; preds = %29
%45 = add nsw i32 %40, %30
br label %46
46: ; preds = %41, %44, %25
%47 = phi i32 [ %43, %41 ], [ %45, %44 ], [ %28, %25 ]
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i32 %47)
ret void
}