#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*/ exit(int);
scalar_t__ find_month_and_day(int, int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read_data(int *, int *);
scalar_t__ validate_data(int, int);
int main() {
  int read_year, read_day, found_month, found_day;
  char *months_map[] = {
      "NULL", "January", "February",  "March",   "April",    "May",     "June",
      "July", "August",  "September", "October", "November", "December"};
  if (read_data(&read_year, &read_day) == 0)
    exit(1);
  if (0)
    printf("DEBUG: read from user --> year = %d, day = %d \n", read_year,
           read_day);
  if (validate_data(read_year, read_day) == 0)
    exit(1);
  if (find_month_and_day(read_year, read_day, &found_month, &found_day) == 0) {
    printf("An internal error occured");
    exit(0);
  }
  printf("The full date (day/month/year): %02d/%02d/%04d \n", found_day,
         found_month, read_year);
  printf("The full date with name (day/month/year): %02d/%s/%04d \n", found_day,
         months_map[found_month], read_year);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
lea    0x2c33(%rip),%rsi
mov    $0x68,%edx
call   1050 <memcpy@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <read_data@plt>
cmp    $0x0,%rax
jne    11a8 <main+0x48>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <validate_data@plt>
cmp    $0x0,%rax
jne    11c7 <main+0x67>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1060 <find_month_and_day@plt>
cmp    $0x0,%rax
jne    11f9 <main+0x99>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
movslq -0x10(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rdx
mov    -0x8(%rbp),%ecx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
lea    0x14(%rsp),%rsi
call   1030 <read_data@plt>
test   %rax,%rax
je     11e0 <main+0x90>
mov    0x8(%rsp),%edi
mov    0x14(%rsp),%esi
call   1060 <validate_data@plt>
test   %rax,%rax
je     11e0 <main+0x90>
mov    0x8(%rsp),%edi
mov    0x14(%rsp),%esi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <find_month_and_day@plt>
test   %rax,%rax
je     11ea <main+0x9a>
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
movslq 0x10(%rsp),%rax
lea    0xf20(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
mov    0x8(%rsp),%ecx
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"NULL\00"
@.str.1 = [8 x i8] c"January\00"
@.str.2 = [9 x i8] c"February\00"
@.str.3 = [6 x i8] c"March\00"
@.str.4 = [6 x i8] c"April\00"
@.str.5 = [4 x i8] c"May\00"
@.str.6 = [5 x i8] c"June\00"
@.str.7 = [5 x i8] c"July\00"
@.str.8 = [7 x i8] c"August\00"
@.str.9 = [10 x i8] c"September\00"
@.str.10 = [8 x i8] c"October\00"
@.str.11 = [9 x i8] c"November\00"
@.str.12 = [9 x i8] c"December\00"
@__const.main.months_map = [13 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i32 0, i32 0)]
@.str.13 = [26 x i8] c"An internal error occured\00"
@.str.14 = [49 x i8] c"The full date (day/month/year): %02d/%02d/%04d \0A\00"
@.str.15 = [57 x i8] c"The full date with name (day/month/year): %02d/%s/%04d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [13 x i8*]
store i32 0, i32* %1
%7 = bitcast [13 x i8*]* %6 to i8*
%8 = call i64 @read_data(i32* %2, i32* %3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = call i64 @validate_data(i32 %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %12
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i64 @find_month_and_day(i32 %20, i32 %21, i32* %4, i32* %5)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %19
%28 = load i32, i32* %5
%29 = load i32, i32* %4
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0), i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [13 x i8*], [13 x i8*]* %6, i64 0, i64 %34
%36 = load i8*, i8** %35
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.15, i64 0, i64 0), i32 %32, i8* %36, i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"NULL\00"
@.str.1 = [8 x i8] c"January\00"
@.str.2 = [9 x i8] c"February\00"
@.str.3 = [6 x i8] c"March\00"
@.str.4 = [6 x i8] c"April\00"
@.str.5 = [4 x i8] c"May\00"
@.str.6 = [5 x i8] c"June\00"
@.str.7 = [5 x i8] c"July\00"
@.str.8 = [7 x i8] c"August\00"
@.str.9 = [10 x i8] c"September\00"
@.str.10 = [8 x i8] c"October\00"
@.str.11 = [9 x i8] c"November\00"
@.str.12 = [9 x i8] c"December\00"
@reltable.main = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32)]
@.str.13 = [26 x i8] c"An internal error occured\00"
@.str.14 = [49 x i8] c"The full date (day/month/year): %02d/%02d/%04d \0A\00"
@.str.15 = [57 x i8] c"The full date with name (day/month/year): %02d/%s/%04d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i64 @read_data(i32* %1, i32* %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i64 @validate_data(i32 %14, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %13
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = call i64 @find_month_and_day(i32 %21, i32 %22, i32* %3, i32* %4)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i64 0, i64 0))
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %20
%29 = load i32, i32* %4
%30 = load i32, i32* %3
%31 = load i32, i32* %1
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0), i32 %29, i32 %30, i32 %31)
%33 = load i32, i32* %4
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = shl i64 %35, 2
%37 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.main to i8*), i64 %36)
%38 = load i32, i32* %1
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.15, i64 0, i64 0), i32 %33, i8* %37, i32 %38)
ret i32 0
}