#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 */
void *atoi(char *);
int /*<<< orphan*/ clear_line(char **);
int day_of_year(int, char, int);
char getline_my(char **, int);
int /*<<< orphan*/ month_day(int, int, char *, int *);
int /*<<< orphan*/ print_variants();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char line[100];
  char answ[100];
  char v = 0;
  char exit = 0;
  int rez = 0;
  int year = 0;
  int yearday = 0;
  char month = 0;
  int day = 0;
  char error = 0;
  print_variants();
  while (exit == 0) {
    v = getline_my(&answ, 100);
    v = answ[0];
    switch (v) {
    case 'a':
      rez = 0;
      error = 0;
      while (rez == 0) {
        printf("Input please year ( from 1 to 2016 ):");
        clear_line(&line);
        getline_my(&line, 100);
        year = atoi(line);
        if (year > 0 && year <= 2016) {
          rez = 1;
        } else {
          printf("Wrong year, try again.\n");
          error = 1;
        };
      };
      rez = 0;
      while (rez == 0) {
        printf("Input please month ( from 1 to 12 ):");
        clear_line(&line);
        getline_my(&line, 100);
        month = atoi(line);
        if (month > 0 && month <= 12) {
          rez = 1;
        } else {
          printf("Wrong month, try again.\n");
          error = 1;
        }
      };
      rez = 0;
      while (rez == 0) {
        printf("Input please day ( from 1 to 31 ):");
        clear_line(&line);
        getline_my(&line, 100);
        day = atoi(line);
        if (day > 0 && day <= 31) {
          rez = 1;
        } else {
          printf("Wrong day, try again.\n");
          error = 1;
        }
      };
      if (error == 1) {
        printf("Wrong input, try again.\n");
      } else {
        rez = day_of_year(year, month, day);
        if (rez == -1) {
          printf("Because of wrong values operation isn't complete.\nYou may "
                 "try again.\n");
        } else {
          printf("Day of year is %d;\n", rez);
        }
      }
      break;
    case 'b':
      rez = 0;
      while (rez == 0) {
        printf("Input please day of year ( from 1 to 366 ):");
        clear_line(&line);
        getline_my(&line, 100);
        yearday = atoi(line);
        if (yearday > 0 && yearday < 366) {
          rez = 1;
        } else {
          printf("Wrong day of year, try again.\n");
        };
      };
      rez = 0;
      while (rez == 0) {
        printf("Input please year ( from 1 to 2016 ):");
        clear_line(&line);
        getline_my(&line, 100);
        year = atoi(line);
        if (year > 0 && year < 2016) {
          rez = 1;
        } else {
          printf("Wrong year, try again.\n");
        };
      };
      month_day(year, yearday, &month, &day);
      printf("month = %d; day of month = %d;\n", month, day);
      break;
    case 'h':
      print_variants();
      break;
    case 'q':
      exit = 1;
      break;
    default:
      printf("Wrong input. To quit press 'q'.\nFor help press 'h'\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0xe1(%rbp)
movb   $0x0,-0xe2(%rbp)
movl   $0x0,-0xe8(%rbp)
movl   $0x0,-0xec(%rbp)
movl   $0x0,-0xf0(%rbp)
movb   $0x0,-0xf1(%rbp)
movl   $0x0,-0xf8(%rbp)
movb   $0x0,-0xf9(%rbp)
mov    $0x0,%al
call   1080 <print_variants@plt>
movsbl -0xe2(%rbp),%eax
cmp    $0x0,%eax
jne    15ec <main+0x47c>
lea    -0xe0(%rbp),%rdi
mov    $0x64,%esi
call   1060 <getline_my@plt>
mov    %al,-0xe1(%rbp)
mov    -0xe0(%rbp),%al
mov    %al,-0xe1(%rbp)
movsbl -0xe1(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x108(%rbp)
sub    $0x10,%eax
ja     15d9 <main+0x469>
mov    -0x108(%rbp),%rax
lea    0xdd6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0xe8(%rbp)
movb   $0x0,-0xf9(%rbp)
cmpl   $0x0,-0xe8(%rbp)
jne    12cb <main+0x15b>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <clear_line@plt>
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <getline_my@plt>
lea    -0x70(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0xec(%rbp)
cmpl   $0x0,-0xec(%rbp)
jle    12b1 <main+0x141>
cmpl   $0x7e0,-0xec(%rbp)
jg     12b1 <main+0x141>
movl   $0x1,-0xe8(%rbp)
jmp    12c6 <main+0x156>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x1,-0xf9(%rbp)
jmp    1244 <main+0xd4>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x0,-0xe8(%rbp)
jne    135f <main+0x1ef>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <clear_line@plt>
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <getline_my@plt>
lea    -0x70(%rbp),%rdi
call   1090 <atoi@plt>
mov    %al,-0xf1(%rbp)
movsbl -0xf1(%rbp),%eax
cmp    $0x0,%eax
jle    1345 <main+0x1d5>
movsbl -0xf1(%rbp),%eax
cmp    $0xc,%eax
jg     1345 <main+0x1d5>
movl   $0x1,-0xe8(%rbp)
jmp    135a <main+0x1ea>
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x1,-0xf9(%rbp)
jmp    12d5 <main+0x165>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x0,-0xe8(%rbp)
jne    13ed <main+0x27d>
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <clear_line@plt>
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <getline_my@plt>
lea    -0x70(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0xf8(%rbp)
cmpl   $0x0,-0xf8(%rbp)
jle    13d3 <main+0x263>
cmpl   $0x1f,-0xf8(%rbp)
jg     13d3 <main+0x263>
movl   $0x1,-0xe8(%rbp)
jmp    13e8 <main+0x278>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x1,-0xf9(%rbp)
jmp    1369 <main+0x1f9>
movsbl -0xf9(%rbp),%eax
cmp    $0x1,%eax
jne    1410 <main+0x2a0>
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1469 <main+0x2f9>
mov    -0xec(%rbp),%edi
mov    -0xf1(%rbp),%al
mov    -0xf8(%rbp),%edx
movsbl %al,%esi
call   1070 <day_of_year@plt>
mov    %eax,-0xe8(%rbp)
cmpl   $0xffffffff,-0xe8(%rbp)
jne    1450 <main+0x2e0>
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1464 <main+0x2f4>
mov    -0xe8(%rbp),%esi
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1469 <main+0x2f9>
jmp    15e7 <main+0x477>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x0,-0xe8(%rbp)
jne    14f8 <main+0x388>
lea    0xce1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <clear_line@plt>
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <getline_my@plt>
lea    -0x70(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0xf0(%rbp)
cmpl   $0x0,-0xf0(%rbp)
jle    14e5 <main+0x375>
cmpl   $0x16e,-0xf0(%rbp)
jge    14e5 <main+0x375>
movl   $0x1,-0xe8(%rbp)
jmp    14f3 <main+0x383>
lea    0xcad(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1478 <main+0x308>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x0,-0xe8(%rbp)
jne    1582 <main+0x412>
lea    0xb2e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <clear_line@plt>
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
call   1060 <getline_my@plt>
lea    -0x70(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0xec(%rbp)
cmpl   $0x0,-0xec(%rbp)
jle    156f <main+0x3ff>
cmpl   $0x7e0,-0xec(%rbp)
jge    156f <main+0x3ff>
movl   $0x1,-0xe8(%rbp)
jmp    157d <main+0x40d>
lea    0xaf4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1502 <main+0x392>
mov    -0xec(%rbp),%edi
mov    -0xf0(%rbp),%esi
lea    -0xf1(%rbp),%rdx
lea    -0xf8(%rbp),%rcx
call   1040 <month_day@plt>
movsbl -0xf1(%rbp),%esi
mov    -0xf8(%rbp),%edx
lea    0xc03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15e7 <main+0x477>
mov    $0x0,%al
call   1080 <print_variants@plt>
jmp    15e7 <main+0x477>
movb   $0x1,-0xe2(%rbp)
jmp    15e7 <main+0x477>
lea    0xbf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11cd <main+0x5d>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
movb   $0x0,0x7(%rsp)
movl   $0x0,0x8(%rsp)
xor    %eax,%eax
call   1090 <print_variants@plt>
lea    0x10(%rsp),%r13
lea    0xe93(%rip),%r12
lea    0x80(%rsp),%rbx
lea    0xfe3(%rip),%rbp
lea    0xff4(%rip),%r14
jmp    11e8 <main+0x68>
nopl   0x0(%rax)
lea    0xf9e(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%r13
lea    0xfbb(%rip),%rbp
lea    0xed7(%rip),%r15
mov    %r13,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
movsbl 0x10(%rsp),%eax
add    $0xffffff9f,%eax
cmp    $0x10,%eax
ja     1350 <main+0x1d0>
lea    0xdec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %rax,%rbp
add    $0xffffffff,%eax
cmp    $0x16d,%eax
lea    0xebc(%rip),%r13
jb     129c <main+0x11c>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %rax,%rbp
add    $0xffffffff,%eax
cmp    $0x16d,%eax
jae    1260 <main+0xe0>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
cmp    $0x7df,%ecx
jb     130a <main+0x18a>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
lea    -0x1(%rax),%ecx
cmp    $0x7de,%ecx
ja     12d0 <main+0x150>
mov    %eax,%edi
mov    %ebp,%esi
lea    0x7(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <month_day@plt>
movsbl 0x7(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xdc5(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe68(%rip),%rbp
lea    0x10(%rsp),%r13
jmp    11ef <main+0x6f>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
jmp    11ef <main+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <print_variants@plt>
jmp    11ef <main+0x6f>
nopl   0x0(%rax)
movl   $0x0,0xc(%rsp)
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %rax,%r13
add    $0xffffffff,%eax
cmp    $0x7e0,%eax
jb     1402 <main+0x282>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %rax,%r13
add    $0xffffffff,%eax
cmp    $0x7e0,%eax
jae    13c0 <main+0x240>
mov    $0x1,%al
mov    %eax,0xc(%rsp)
lea    0xc61(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %al,0x7(%rsp)
add    $0xff,%al
cmp    $0xc,%al
jb     147f <main+0x2ff>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %al,0x7(%rsp)
add    $0xff,%al
cmp    $0xc,%al
jae    1440 <main+0x2c0>
mov    $0x1,%al
mov    %eax,0xc(%rsp)
lea    0xc09(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %eax,0x8(%rsp)
add    $0xffffffff,%eax
cmp    $0x1f,%eax
lea    0xccf(%rip),%rbp
mov    0xc(%rsp),%eax
jb     150d <main+0x38d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <clear_line@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <getline_my@plt>
mov    %rbx,%rdi
call   10a0 <atoi@plt>
mov    %eax,0x8(%rsp)
add    $0xffffffff,%eax
cmp    $0x1e,%eax
ja     14d0 <main+0x350>
mov    $0x1,%al
test   %al,%al
jne    11d0 <main+0x50>
movsbl 0x7(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r13d,%edi
call   1080 <day_of_year@plt>
cmp    $0xffffffff,%eax
je     1540 <main+0x3c0>
lea    0xb80(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11dc <main+0x5c>
lea    0xbe9(%rip),%rdi
jmp    11d7 <main+0x57>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Input please year ( from 1 to 2016 ):\00"
@.str.1 = [24 x i8] c"Wrong year, try again.\0A\00"
@.str.2 = [37 x i8] c"Input please month ( from 1 to 12 ):\00"
@.str.3 = [25 x i8] c"Wrong month, try again.\0A\00"
@.str.4 = [35 x i8] c"Input please day ( from 1 to 31 ):\00"
@.str.5 = [23 x i8] c"Wrong day, try again.\0A\00"
@.str.6 = [25 x i8] c"Wrong input, try again.\0A\00"
@.str.7 = [70 x i8] c"Because of wrong values operation isn't complete.\0AYou may try again.\0A\00"
@.str.8 = [20 x i8] c"Day of year is %d;\0A\00"
@.str.9 = [44 x i8] c"Input please day of year ( from 1 to 366 ):\00"
@.str.10 = [31 x i8] c"Wrong day of year, try again.\0A\00"
@.str.11 = [32 x i8] c"month = %d; day of month = %d;\0A\00"
@.str.12 = [52 x i8] c"Wrong input. To quit press 'q'.\0AFor help press 'h'\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
%11 = alloca i8
store i32 0, i32* %1
store i8 0, i8* %4
store i8 0, i8* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i8 0, i8* %9
store i32 0, i32* %10
store i8 0, i8* %11
%12 = call i32 (...) @print_variants()
br label %13
13: ; preds = %169, %0
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %170
17: ; preds = %13
%18 = bitcast [100 x i8]* %3 to i8**
%19 = call signext i8 @getline_my(i8** %18, i32 100)
store i8 %19, i8* %4
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%21 = load i8, i8* %20
store i8 %21, i8* %4
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
switch i32 %23, label %167 [
i32 97, label %24
i32 98, label %112
i32 104, label %164
i32 113, label %166
]
24: ; preds = %17
store i32 0, i32* %6
store i8 0, i8* %11
br label %25
25: ; preds = %45, %24
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %46
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%30 = bitcast [100 x i8]* %2 to i8**
%31 = call i32 @clear_line(i8** %30)
%32 = bitcast [100 x i8]* %2 to i8**
%33 = call signext i8 @getline_my(i8** %32, i32 100)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%35 = call i8* @atoi(i8* %34)
%36 = ptrtoint i8* %35 to i32
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %28
%40 = load i32, i32* %7
%41 = icmp sle i32 %40, 2016
br i1 %41, label %42, label %43
42: ; preds = %39
store i32 1, i32* %6
br label %45
43: ; preds = %39, %28
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i8 1, i8* %11
br label %45
45: ; preds = %43, %42
br label %25
46: ; preds = %25
store i32 0, i32* %6
br label %47
47: ; preds = %69, %46
%48 = load i32, i32* %6
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %70
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%52 = bitcast [100 x i8]* %2 to i8**
%53 = call i32 @clear_line(i8** %52)
%54 = bitcast [100 x i8]* %2 to i8**
%55 = call signext i8 @getline_my(i8** %54, i32 100)
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%57 = call i8* @atoi(i8* %56)
%58 = ptrtoint i8* %57 to i8
store i8 %58, i8* %9
%59 = load i8, i8* %9
%60 = sext i8 %59 to i32
%61 = icmp sgt i32 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %50
%63 = load i8, i8* %9
%64 = sext i8 %63 to i32
%65 = icmp sle i32 %64, 12
br i1 %65, label %66, label %67
66: ; preds = %62
store i32 1, i32* %6
br label %69
67: ; preds = %62, %50
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i8 1, i8* %11
br label %69
69: ; preds = %67, %66
br label %47
70: ; preds = %47
store i32 0, i32* %6
br label %71
71: ; preds = %91, %70
%72 = load i32, i32* %6
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %92
74: ; preds = %71
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%76 = bitcast [100 x i8]* %2 to i8**
%77 = call i32 @clear_line(i8** %76)
%78 = bitcast [100 x i8]* %2 to i8**
%79 = call signext i8 @getline_my(i8** %78, i32 100)
%80 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%81 = call i8* @atoi(i8* %80)
%82 = ptrtoint i8* %81 to i32
store i32 %82, i32* %10
%83 = load i32, i32* %10
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %74
%86 = load i32, i32* %10
%87 = icmp sle i32 %86, 31
br i1 %87, label %88, label %89
88: ; preds = %85
store i32 1, i32* %6
br label %91
89: ; preds = %85, %74
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i8 1, i8* %11
br label %91
91: ; preds = %89, %88
br label %71
92: ; preds = %71
%93 = load i8, i8* %11
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 1
br i1 %95, label %96, label %98
96: ; preds = %92
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %111
98: ; preds = %92
%99 = load i32, i32* %7
%100 = load i8, i8* %9
%101 = load i32, i32* %10
%102 = call i32 @day_of_year(i32 %99, i8 signext %100, i32 %101)
store i32 %102, i32* %6
%103 = load i32, i32* %6
%104 = icmp eq i32 %103, -1
br i1 %104, label %105, label %107
105: ; preds = %98
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.7, i64 0, i64 0))
br label %110
107: ; preds = %98
%108 = load i32, i32* %6
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %108)
br label %110
110: ; preds = %107, %105
br label %111
111: ; preds = %110, %96
br label %169
112: ; preds = %17
store i32 0, i32* %6
br label %113
113: ; preds = %133, %112
%114 = load i32, i32* %6
%115 = icmp eq i32 %114, 0
br i1 %115, label %116, label %134
116: ; preds = %113
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0))
%118 = bitcast [100 x i8]* %2 to i8**
%119 = call i32 @clear_line(i8** %118)
%120 = bitcast [100 x i8]* %2 to i8**
%121 = call signext i8 @getline_my(i8** %120, i32 100)
%122 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%123 = call i8* @atoi(i8* %122)
%124 = ptrtoint i8* %123 to i32
store i32 %124, i32* %8
%125 = load i32, i32* %8
%126 = icmp sgt i32 %125, 0
br i1 %126, label %127, label %131
127: ; preds = %116
%128 = load i32, i32* %8
%129 = icmp slt i32 %128, 366
br i1 %129, label %130, label %131
130: ; preds = %127
store i32 1, i32* %6
br label %133
131: ; preds = %127, %116
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
br label %133
133: ; preds = %131, %130
br label %113
134: ; preds = %113
store i32 0, i32* %6
br label %135
135: ; preds = %155, %134
%136 = load i32, i32* %6
%137 = icmp eq i32 %136, 0
br i1 %137, label %138, label %156
138: ; preds = %135
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%140 = bitcast [100 x i8]* %2 to i8**
%141 = call i32 @clear_line(i8** %140)
%142 = bitcast [100 x i8]* %2 to i8**
%143 = call signext i8 @getline_my(i8** %142, i32 100)
%144 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%145 = call i8* @atoi(i8* %144)
%146 = ptrtoint i8* %145 to i32
store i32 %146, i32* %7
%147 = load i32, i32* %7
%148 = icmp sgt i32 %147, 0
br i1 %148, label %149, label %153
149: ; preds = %138
%150 = load i32, i32* %7
%151 = icmp slt i32 %150, 2016
br i1 %151, label %152, label %153
152: ; preds = %149
store i32 1, i32* %6
br label %155
153: ; preds = %149, %138
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %155
155: ; preds = %153, %152
br label %135
156: ; preds = %135
%157 = load i32, i32* %7
%158 = load i32, i32* %8
%159 = call i32 @month_day(i32 %157, i32 %158, i8* %9, i32* %10)
%160 = load i8, i8* %9
%161 = sext i8 %160 to i32
%162 = load i32, i32* %10
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i32 %161, i32 %162)
br label %169
164: ; preds = %17
%165 = call i32 (...) @print_variants()
br label %169
166: ; preds = %17
store i8 1, i8* %5
br label %169
167: ; preds = %17
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
br label %169
169: ; preds = %167, %166, %164, %156, %111
br label %13
170: ; preds = %13
%171 = load i32, i32* %1
ret i32 %171
}

LLVM IR (-O2):
@.str = [38 x i8] c"Input please year ( from 1 to 2016 ):\00"
@.str.2 = [37 x i8] c"Input please month ( from 1 to 12 ):\00"
@.str.4 = [35 x i8] c"Input please day ( from 1 to 31 ):\00"
@.str.8 = [20 x i8] c"Day of year is %d;\0A\00"
@.str.9 = [44 x i8] c"Input please day of year ( from 1 to 366 ):\00"
@.str.11 = [32 x i8] c"month = %d; day of month = %d;\0A\00"
@str.13 = [30 x i8] c"Wrong day of year, try again.\00"
@str.14 = [69 x i8] c"Because of wrong values operation isn't complete.\0AYou may try again.\00"
@str.15 = [24 x i8] c"Wrong input, try again.\00"
@str.16 = [22 x i8] c"Wrong day, try again.\00"
@str.17 = [24 x i8] c"Wrong month, try again.\00"
@str.18 = [23 x i8] c"Wrong year, try again.\00"
@str.19 = [51 x i8] c"Wrong input. To quit press 'q'.\0AFor help press 'h'\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8 0, i8* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = tail call i32 (...) @print_variants()
%9 = bitcast [100 x i8]* %2 to i8**
%10 = bitcast [100 x i8]* %1 to i8**
br label %11
11: ; preds = %91, %0
%12 = call signext i8 @getline_my(i8** %9, i32 100)
%13 = load i8, i8* %6
%14 = sext i8 %13 to i32
switch i32 %14, label %144 [
i32 97, label %24
i32 98, label %15
i32 104, label %142
i32 113, label %146
]
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0))
%17 = call i32 @clear_line(i8** %10)
%18 = call signext i8 @getline_my(i8** %10, i32 100)
%19 = call i8* @atoi(i8* %5)
%20 = ptrtoint i8* %19 to i64
%21 = trunc i64 %20 to i32
%22 = add i32 %21, -1
%23 = icmp ult i32 %22, 365
br i1 %23, label %101, label %113
24: ; preds = %11
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @clear_line(i8** %10)
%27 = call signext i8 @getline_my(i8** %10, i32 100)
%28 = call i8* @atoi(i8* %5)
%29 = ptrtoint i8* %28 to i64
%30 = trunc i64 %29 to i32
%31 = add i32 %30, -1
%32 = icmp ult i32 %31, 2016
br i1 %32, label %33, label %46
33: ; preds = %46, %24
%34 = phi i8 [ 0, %24 ], [ 1, %46 ]
%35 = phi i8* [ %28, %24 ], [ %51, %46 ]
%36 = ptrtoint i8* %35 to i64
%37 = trunc i64 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @clear_line(i8** %10)
%40 = call signext i8 @getline_my(i8** %10, i32 100)
%41 = call i8* @atoi(i8* %5)
%42 = ptrtoint i8* %41 to i64
%43 = trunc i64 %42 to i8
store i8 %43, i8* %3
%44 = add i8 %43, -1
%45 = icmp ult i8 %44, 12
br i1 %45, label %56, label %66
46: ; preds = %24, %46
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.18, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%49 = call i32 @clear_line(i8** %10)
%50 = call signext i8 @getline_my(i8** %10, i32 100)
%51 = call i8* @atoi(i8* %5)
%52 = ptrtoint i8* %51 to i64
%53 = trunc i64 %52 to i32
%54 = add i32 %53, -1
%55 = icmp ult i32 %54, 2016
br i1 %55, label %33, label %46
56: ; preds = %66, %33
%57 = phi i8 [ %34, %33 ], [ 1, %66 ]
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%59 = call i32 @clear_line(i8** %10)
%60 = call signext i8 @getline_my(i8** %10, i32 100)
%61 = call i8* @atoi(i8* %5)
%62 = ptrtoint i8* %61 to i64
%63 = trunc i64 %62 to i32
store i32 %63, i32* %4
%64 = add i32 %63, -1
%65 = icmp ult i32 %64, 31
br i1 %65, label %86, label %76
66: ; preds = %33, %66
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.17, i64 0, i64 0))
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%69 = call i32 @clear_line(i8** %10)
%70 = call signext i8 @getline_my(i8** %10, i32 100)
%71 = call i8* @atoi(i8* %5)
%72 = ptrtoint i8* %71 to i64
%73 = trunc i64 %72 to i8
store i8 %73, i8* %3
%74 = add i8 %73, -1
%75 = icmp ult i8 %74, 12
br i1 %75, label %56, label %66
76: ; preds = %56, %76
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.16, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%79 = call i32 @clear_line(i8** %10)
%80 = call signext i8 @getline_my(i8** %10, i32 100)
%81 = call i8* @atoi(i8* %5)
%82 = ptrtoint i8* %81 to i64
%83 = trunc i64 %82 to i32
store i32 %83, i32* %4
%84 = add i32 %83, -1
%85 = icmp ult i32 %84, 31
br i1 %85, label %86, label %76
86: ; preds = %76, %56
%87 = phi i8 [ %57, %56 ], [ 1, %76 ]
%88 = icmp eq i8 %87, 1
br i1 %88, label %89, label %92
89: ; preds = %86
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.15, i64 0, i64 0))
br label %91
91: ; preds = %89, %99, %97, %144, %142, %133
br label %11
92: ; preds = %86
%93 = load i8, i8* %3
%94 = load i32, i32* %4
%95 = call i32 @day_of_year(i32 %37, i8 signext %93, i32 %94)
%96 = icmp eq i32 %95, -1
br i1 %96, label %97, label %99
97: ; preds = %92
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.14, i64 0, i64 0))
br label %91
99: ; preds = %92
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %95)
br label %91
101: ; preds = %113, %15
%102 = phi i8* [ %19, %15 ], [ %118, %113 ]
%103 = ptrtoint i8* %102 to i64
%104 = trunc i64 %103 to i32
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%106 = call i32 @clear_line(i8** %10)
%107 = call signext i8 @getline_my(i8** %10, i32 100)
%108 = call i8* @atoi(i8* %5)
%109 = ptrtoint i8* %108 to i64
%110 = trunc i64 %109 to i32
%111 = add i32 %110, -1
%112 = icmp ult i32 %111, 2015
br i1 %112, label %133, label %123
113: ; preds = %15, %113
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.13, i64 0, i64 0))
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0))
%116 = call i32 @clear_line(i8** %10)
%117 = call signext i8 @getline_my(i8** %10, i32 100)
%118 = call i8* @atoi(i8* %5)
%119 = ptrtoint i8* %118 to i64
%120 = trunc i64 %119 to i32
%121 = add i32 %120, -1
%122 = icmp ult i32 %121, 365
br i1 %122, label %101, label %113
123: ; preds = %101, %123
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.18, i64 0, i64 0))
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%126 = call i32 @clear_line(i8** %10)
%127 = call signext i8 @getline_my(i8** %10, i32 100)
%128 = call i8* @atoi(i8* %5)
%129 = ptrtoint i8* %128 to i64
%130 = trunc i64 %129 to i32
%131 = add i32 %130, -1
%132 = icmp ult i32 %131, 2015
br i1 %132, label %133, label %123
133: ; preds = %123, %101
%134 = phi i8* [ %108, %101 ], [ %128, %123 ]
%135 = ptrtoint i8* %134 to i64
%136 = trunc i64 %135 to i32
%137 = call i32 @month_day(i32 %136, i32 %104, i8* %3, i32* %4)
%138 = load i8, i8* %3
%139 = sext i8 %138 to i32
%140 = load i32, i32* %4
%141 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i32 %139, i32 %140)
br label %91
142: ; preds = %11
%143 = call i32 (...) @print_variants()
br label %91
144: ; preds = %11
%145 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.19, i64 0, i64 0))
br label %91
146: ; preds = %11
ret i32 0
}