#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 */
scalar_t__ EOF;
scalar_t__ RunYear(int);
int /*<<< orphan*/ printf(char *, int, int, int);
scalar_t__ scanf(char *, int *, int *);
int main() {
  int i;
  int year, day;
  int mday[] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  while (scanf("%d%d", &year, &day) != EOF) {
    if (RunYear(year))
      mday[1] = 29;
    else
      mday[1] = 28;
    for (i = 0; i < 12; i++) {
      if (mday[i] >= day) {
        printf("%.4d-%.2d-%.2d\n", year, i + 1, day);
        break;
      } else
        day -= mday[i];
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
lea    0xec5(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <scanf@plt>
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%rax
je     1214 <main+0xd4>
mov    -0xc(%rbp),%edi
call   1050 <RunYear@plt>
cmp    $0x0,%rax
je     11a6 <main+0x66>
movl   $0x1d,-0x3c(%rbp)
jmp    11ad <main+0x6d>
movl   $0x1c,-0x3c(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
jge    120f <main+0xcf>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
cmp    -0x10(%rbp),%eax
jl     11ec <main+0xac>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%ecx
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xcf>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    1201 <main+0xc1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <main+0x74>
jmp    1164 <main+0x24>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0x2e8e(%rip),%rbx
cmp    (%rbx),%rax
je     12c3 <main+0x193>
lea    0xe96(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xe8a(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
call   1040 <RunYear@plt>
cmp    $0x1,%rax
mov    $0x1d,%esi
sbb    $0x0,%esi
mov    0x8(%rsp),%ecx
mov    $0x1,%edx
cmp    $0x1f,%ecx
jle    12a0 <main+0x170>
add    $0xffffffe1,%ecx
mov    %ecx,0x8(%rsp)
mov    $0x2,%edx
mov    %ecx,%eax
sub    %esi,%eax
jbe    12a0 <main+0x170>
mov    %eax,0x8(%rsp)
mov    $0x3,%edx
cmp    $0x20,%eax
jl     129e <main+0x16e>
lea    -0x1f(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0x4,%edx
cmp    $0x3e,%eax
jb     12a0 <main+0x170>
lea    -0x3d(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0x5,%edx
cmp    $0x5d,%eax
jb     12a0 <main+0x170>
lea    -0x5c(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0x6,%edx
cmp    $0x7b,%eax
jb     12a0 <main+0x170>
lea    -0x7a(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0x7,%edx
cmp    $0x9a,%eax
jb     12a0 <main+0x170>
lea    -0x99(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0x8,%edx
cmp    $0xb9,%eax
jb     12a0 <main+0x170>
lea    -0xb8(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0x9,%edx
cmp    $0xd7,%eax
jb     12a0 <main+0x170>
lea    -0xd6(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0xa,%edx
cmp    $0xf6,%eax
jb     12a0 <main+0x170>
lea    -0xf5(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0xb,%edx
cmp    $0x114,%eax
jb     12a0 <main+0x170>
lea    -0x113(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0xc,%edx
cmp    $0x133,%eax
jb     12a0 <main+0x170>
add    $0xfffffece,%eax
mov    %eax,0x8(%rsp)
jmp    12ac <main+0x17c>
mov    %eax,%ecx
mov    0xc(%rsp),%esi
mov    %r13,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <scanf@plt>
cmp    (%rbx),%rax
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.mday = [12 x i32] [i32 31, i32 0, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31, i32 30, i32 31]
@.str = [5 x i8] c"%d%d\00"
@EOF = global i64 0
@.str.1 = [16 x i8] c"%.4d-%.2d-%.2d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [12 x i32]
store i32 0, i32* %1
%6 = bitcast [12 x i32]* %5 to i8*
br label %7
7: ; preds = %47, %0
%8 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%9 = load i64, i64* @EOF
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %48
11: ; preds = %7
%12 = load i32, i32* %3
%13 = call i64 @RunYear(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 1
store i32 29, i32* %16
br label %19
17: ; preds = %11
%18 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 1
store i32 28, i32* %18
br label %19
19: ; preds = %17, %15
store i32 0, i32* %2
br label %20
20: ; preds = %44, %19
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 12
br i1 %22, label %23, label %47
23: ; preds = %20
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32, i32* %4
%29 = icmp sge i32 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %23
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
%34 = load i32, i32* %4
%35 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %33, i32 %34)
br label %47
36: ; preds = %23
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = load i32, i32* %4
%42 = sub nsw i32 %41, %40
store i32 %42, i32* %4
br label %43
43: ; preds = %36
br label %44
44: ; preds = %43
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %20
47: ; preds = %30, %20
br label %7
48: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@EOF = global i64 0
@.str.1 = [16 x i8] c"%.4d-%.2d-%.2d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %59, label %8
8: ; preds = %0, %55
%9 = load i32, i32* %1
%10 = call i64 @RunYear(i32 %9)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 28, i32 29
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 31
br i1 %14, label %20, label %15
15: ; preds = %50, %47, %44, %41, %38, %35, %32, %29, %26, %23, %20, %8
%16 = phi i32 [ 1, %8 ], [ 2, %20 ], [ 3, %23 ], [ 4, %26 ], [ 5, %29 ], [ 6, %32 ], [ 7, %35 ], [ 8, %38 ], [ 9, %41 ], [ 10, %44 ], [ 11, %47 ], [ 12, %50 ]
%17 = phi i32 [ %13, %8 ], [ %21, %20 ], [ %24, %23 ], [ %27, %26 ], [ %30, %29 ], [ %33, %32 ], [ %36, %35 ], [ %39, %38 ], [ %42, %41 ], [ %45, %44 ], [ %48, %47 ], [ %51, %50 ]
%18 = load i32, i32* %1
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %16, i32 %17)
br label %55
20: ; preds = %8
%21 = add nsw i32 %13, -31
store i32 %21, i32* %2
%22 = icmp ugt i32 %21, %12
br i1 %22, label %23, label %15
23: ; preds = %20
%24 = sub nsw i32 %21, %12
store i32 %24, i32* %2
%25 = icmp sgt i32 %24, 31
br i1 %25, label %26, label %15
26: ; preds = %23
%27 = add nsw i32 %24, -31
store i32 %27, i32* %2
%28 = icmp ugt i32 %24, 61
br i1 %28, label %29, label %15
29: ; preds = %26
%30 = add nsw i32 %24, -61
store i32 %30, i32* %2
%31 = icmp ugt i32 %24, 92
br i1 %31, label %32, label %15
32: ; preds = %29
%33 = add nsw i32 %24, -92
store i32 %33, i32* %2
%34 = icmp ugt i32 %24, 122
br i1 %34, label %35, label %15
35: ; preds = %32
%36 = add nsw i32 %24, -122
store i32 %36, i32* %2
%37 = icmp ugt i32 %24, 153
br i1 %37, label %38, label %15
38: ; preds = %35
%39 = add nsw i32 %24, -153
store i32 %39, i32* %2
%40 = icmp ugt i32 %24, 184
br i1 %40, label %41, label %15
41: ; preds = %38
%42 = add nsw i32 %24, -184
store i32 %42, i32* %2
%43 = icmp ugt i32 %24, 214
br i1 %43, label %44, label %15
44: ; preds = %41
%45 = add nsw i32 %24, -214
store i32 %45, i32* %2
%46 = icmp ugt i32 %24, 245
br i1 %46, label %47, label %15
47: ; preds = %44
%48 = add nsw i32 %24, -245
store i32 %48, i32* %2
%49 = icmp ugt i32 %24, 275
br i1 %49, label %50, label %15
50: ; preds = %47
%51 = add nsw i32 %24, -275
store i32 %51, i32* %2
%52 = icmp ugt i32 %24, 306
br i1 %52, label %53, label %15
53: ; preds = %50
%54 = add nsw i32 %24, -306
store i32 %54, i32* %2
br label %55
55: ; preds = %53, %15
%56 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%57 = load i64, i64* @EOF
%58 = icmp eq i64 %56, %57
br i1 %58, label %59, label %8
59: ; preds = %55, %0
ret i32 0
}