#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 atoi(char *);
char *malloc(int);
int strlen(char *);
int is_date(char *word) {
  int validDays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31};
  int i = 1;
  if (strlen(word) != 10) {
    return 0;
  } else if (*(word + 2) != '/' || *(word + 5) != '/') {
    return 0;
  }
  char *cmonth = malloc(sizeof(char) * 3);
  *cmonth = *(word);
  *(cmonth + 1) = *(word + 1);
  int month = atoi(cmonth);
  if (month < 1 || month > 12) {
    return 0;
  }
  char *cday = malloc(sizeof(char) * 3);
  *cday = *(word + 3);
  *(cday + 1) = *(word + 4);
  int day = atoi(cday);
  if (day > validDays[month - 1]) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea9(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x1,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xa,%eax
je     1186 <is_date+0x46>
movl   $0x0,-0x4(%rbp)
jmp    126b <is_date+0x12b>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x2f,%eax
jne    11a8 <is_date+0x68>
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%eax
cmp    $0x2f,%eax
je     11b4 <is_date+0x74>
movl   $0x0,-0x4(%rbp)
jmp    126b <is_date+0x12b>
jmp    11b9 <is_date+0x79>
mov    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x50(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x50(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x50(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x1,-0x54(%rbp)
jl     1201 <is_date+0xc1>
cmpl   $0xc,-0x54(%rbp)
jle    120d <is_date+0xcd>
movl   $0x0,-0x4(%rbp)
jmp    126b <is_date+0x12b>
mov    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x60(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x60(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x60(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x40(%rbp,%rcx,4),%eax
jle    1264 <is_date+0x124>
movl   $0x0,-0x4(%rbp)
jmp    126b <is_date+0x12b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_date>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
xor    %ebp,%ebp
cmp    $0xa,%eax
jne    11a9 <is_date+0x79>
cmpb   $0x2f,0x2(%rbx)
jne    11a9 <is_date+0x79>
cmpb   $0x2f,0x5(%rbx)
jne    11a9 <is_date+0x79>
mov    $0x3,%edi
call   1040 <malloc@plt>
mov    (%rbx),%cl
mov    %cl,(%rax)
mov    0x1(%rbx),%cl
mov    %cl,0x1(%rax)
mov    %rax,%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
lea    -0xd(%r14),%eax
cmp    $0xfffffff4,%eax
jb     11a9 <is_date+0x79>
mov    $0x3,%edi
call   1040 <malloc@plt>
mov    0x3(%rbx),%cl
mov    %cl,(%rax)
mov    0x4(%rbx),%cl
mov    %cl,0x1(%rax)
mov    %rax,%rdi
call   1050 <atoi@plt>
add    $0xffffffff,%r14d
lea    0xe61(%rip),%rcx
xor    %ebp,%ebp
cmp    (%rcx,%r14,4),%eax
setle  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.is_date.validDays = [10 x i32] [i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31]
define i32 @is_date(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %3
%10 = bitcast [10 x i32]* %4 to i8*
store i32 1, i32* %5
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 0, i32* %2
br label %69
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 47
br i1 %20, label %27, label %21
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 47
br i1 %26, label %27, label %28
27: ; preds = %21, %15
store i32 0, i32* %2
br label %69
28: ; preds = %21
br label %29
29: ; preds = %28
%30 = call i8* @malloc(i32 3)
store i8* %30, i8** %6
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = load i8*, i8** %6
store i8 %32, i8* %33
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8, i8* %35
%37 = load i8*, i8** %6
%38 = getelementptr inbounds i8, i8* %37, i64 1
store i8 %36, i8* %38
%39 = load i8*, i8** %6
%40 = call i32 @atoi(i8* %39)
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = icmp slt i32 %41, 1
br i1 %42, label %46, label %43
43: ; preds = %29
%44 = load i32, i32* %7
%45 = icmp sgt i32 %44, 12
br i1 %45, label %46, label %47
46: ; preds = %43, %29
store i32 0, i32* %2
br label %69
47: ; preds = %43
%48 = call i8* @malloc(i32 3)
store i8* %48, i8** %8
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i64 3
%51 = load i8, i8* %50
%52 = load i8*, i8** %8
store i8 %51, i8* %52
%53 = load i8*, i8** %3
%54 = getelementptr inbounds i8, i8* %53, i64 4
%55 = load i8, i8* %54
%56 = load i8*, i8** %8
%57 = getelementptr inbounds i8, i8* %56, i64 1
store i8 %55, i8* %57
%58 = load i8*, i8** %8
%59 = call i32 @atoi(i8* %58)
store i32 %59, i32* %9
%60 = load i32, i32* %9
%61 = load i32, i32* %7
%62 = sub nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = icmp sgt i32 %60, %65
br i1 %66, label %67, label %68
67: ; preds = %47
store i32 0, i32* %2
br label %69
68: ; preds = %47
store i32 1, i32* %2
br label %69
69: ; preds = %68, %67, %46, %27, %14
%70 = load i32, i32* %2
ret i32 %70
}

LLVM IR (-O2):
@__const.is_date.validDays = [10 x i32] [i32 31, i32 28, i32 31, i32 30, i32 31, i32 30, i32 31, i32 31, i32 30, i32 31]
define i32 @is_date(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 10
br i1 %3, label %4, label %35
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 47
br i1 %7, label %8, label %35
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 5
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 47
br i1 %11, label %12, label %35
12: ; preds = %8
%13 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%14 = load i8, i8* %0
store i8 %14, i8* %13
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %16, i8* %17
%18 = tail call i32 @atoi(i8* %13)
%19 = add i32 %18, -13
%20 = icmp ult i32 %19, -12
br i1 %20, label %35, label %21
21: ; preds = %12
%22 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%23 = getelementptr inbounds i8, i8* %0, i64 3
%24 = load i8, i8* %23
store i8 %24, i8* %22
%25 = getelementptr inbounds i8, i8* %0, i64 4
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %22, i64 1
store i8 %26, i8* %27
%28 = tail call i32 @atoi(i8* %22)
%29 = add nsw i32 %18, -1
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds [10 x i32], [10 x i32]* @__const.is_date.validDays, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = icmp sle i32 %28, %32
%34 = zext i1 %33 to i32
br label %35
35: ; preds = %21, %12, %4, %8, %1
%36 = phi i32 [ 0, %1 ], [ 0, %8 ], [ 0, %4 ], [ %34, %21 ], [ 0, %12 ]
ret i32 %36
}