#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*/ findMonth(char *);
int /*<<< orphan*/ getCompleteYear(char *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char **, char **, char **);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int strlen(char *);
char *parseDate(char *date) {
  char *final = malloc(sizeof(char) * 11);
  char day[3], month[4], year[5];
  char tell = date[2];
  switch (tell) {
  case '/': {
    sscanf(date, "%2s/%2s/%2s", &month, &day, &year);
    strcpy(year, getCompleteYear(year));
    break;
  }
  case '#': {
    sscanf(date, "%2s#%2s#%2s", &month, &year, &day);
    strcpy(year, getCompleteYear(year));
    break;
  }
  case '*': {
    sscanf(date, "%2s*%2s*%4s", &day, &month, &year);
    break;
  }
  default: {
    if (tell > 'a' && tell < 'z') {
      if (strlen(date) == 11) {
        sscanf(date, "%3s %2s, %2s", &month, &day, &year);
        strcpy(month, findMonth(month));
        strcpy(year, getCompleteYear(year));
      } else {
        sscanf(date, "%3s %2s, %4s", &month, &day, &year);
        strcpy(month, findMonth(month));
      }
    } else {
      sscanf(date, "%4s-%2s-%2s", &year, &month, &day);
    }
  }
  }
  sprintf(final, "%4s-%2s-%2s", year, month, day);
  return final;
}


x86 assembly (clang, -O0):
<parseDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xb,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%al
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x23,%eax
je     1208 <parseDate+0x98>
jmp    11a9 <parseDate+0x39>
mov    -0x24(%rbp),%eax
sub    $0x2a,%eax
je     1245 <parseDate+0xd5>
jmp    11ba <parseDate+0x4a>
mov    -0x24(%rbp),%eax
sub    $0x2f,%eax
jne    1266 <parseDate+0xf6>
jmp    11cb <parseDate+0x5b>
mov    -0x8(%rbp),%rdi
lea    -0x17(%rbp),%rdx
lea    -0x13(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    0xe1e(%rip),%rsi
call   1070 <sscanf@plt>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x1c(%rbp),%rdi
call   1080 <getCompleteYear@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
jmp    1349 <parseDate+0x1d9>
mov    -0x8(%rbp),%rdi
lea    -0x17(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x13(%rbp),%r8
lea    0xded(%rip),%rsi
call   1070 <sscanf@plt>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x1c(%rbp),%rdi
call   1080 <getCompleteYear@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
jmp    1349 <parseDate+0x1d9>
mov    -0x8(%rbp),%rdi
lea    -0x13(%rbp),%rdx
lea    -0x17(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    0xdbc(%rip),%rsi
call   1070 <sscanf@plt>
jmp    1349 <parseDate+0x1d9>
movsbl -0x1d(%rbp),%eax
cmp    $0x61,%eax
jle    1328 <parseDate+0x1b8>
movsbl -0x1d(%rbp),%eax
cmp    $0x7a,%eax
jge    1328 <parseDate+0x1b8>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xb,%eax
jne    12eb <parseDate+0x17b>
mov    -0x8(%rbp),%rdi
lea    -0x17(%rbp),%rdx
lea    -0x13(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    0xd7b(%rip),%rsi
call   1070 <sscanf@plt>
lea    -0x17(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x17(%rbp),%rdi
call   1050 <findMonth@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x1c(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x1c(%rbp),%rdi
call   1080 <getCompleteYear@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
jmp    1323 <parseDate+0x1b3>
mov    -0x8(%rbp),%rdi
lea    -0x17(%rbp),%rdx
lea    -0x13(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    0xd2f(%rip),%rsi
call   1070 <sscanf@plt>
lea    -0x17(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x17(%rbp),%rdi
call   1050 <findMonth@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
jmp    1344 <parseDate+0x1d4>
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rdx
lea    -0x17(%rbp),%rcx
lea    -0x13(%rbp),%r8
lea    0xcff(%rip),%rsi
call   1070 <sscanf@plt>
jmp    1349 <parseDate+0x1d9>
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rdx
lea    -0x17(%rbp),%rcx
lea    -0x13(%rbp),%r8
lea    0xcde(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseDate>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    $0xb,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    0x2(%rbx),%al
movsbl %al,%ecx
cmp    $0x23,%ecx
je     11be <parseDate+0x4e>
cmp    $0x2a,%ecx
je     11f6 <parseDate+0x86>
cmp    $0x2f,%ecx
jne    120e <parseDate+0x9e>
lea    0xe59(%rip),%rsi
lea    0xf(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x13(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%r8
jmp    11da <parseDate+0x6a>
lea    0xe47(%rip),%rsi
lea    0xf(%rsp),%rdx
lea    0x13(%rsp),%r15
lea    0xc(%rsp),%r8
mov    %rbx,%rdi
mov    %r15,%rcx
call   1070 <sscanf@plt>
mov    %r15,%rdi
call   1080 <getCompleteYear@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
jmp    1286 <parseDate+0x116>
lea    0xe1b(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0xf(%rsp),%rcx
lea    0x13(%rsp),%r8
jmp    127e <parseDate+0x10e>
add    $0x9e,%al
cmp    $0x17,%al
ja     1268 <parseDate+0xf8>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0xb,%eax
jne    12b3 <parseDate+0x143>
lea    0xdf8(%rip),%rsi
lea    0xf(%rsp),%r15
lea    0xc(%rsp),%rcx
lea    0x13(%rsp),%r12
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%r8
call   1070 <sscanf@plt>
mov    %r15,%rdi
call   1050 <findMonth@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1080 <getCompleteYear@plt>
mov    %r12,%rdi
jmp    11ea <parseDate+0x7a>
lea    0xdcf(%rip),%rsi
lea    0x13(%rsp),%rdx
lea    0xf(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %rbx,%rdi
call   1070 <sscanf@plt>
lea    0xdb1(%rip),%rsi
lea    0x13(%rsp),%rdx
lea    0xf(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %r14,%rdi
call   1090 <sprintf@plt>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xd77(%rip),%rsi
lea    0xf(%rsp),%r15
lea    0xc(%rsp),%rcx
lea    0x13(%rsp),%r8
mov    %rbx,%rdi
mov    %r15,%rdx
call   1070 <sscanf@plt>
mov    %r15,%rdi
call   1050 <findMonth@plt>
jmp    11e7 <parseDate+0x77>

LLVM IR (-O0):
@.str = [12 x i8] c"%2s/%2s/%2s\00"
@.str.1 = [12 x i8] c"%2s#%2s#%2s\00"
@.str.2 = [12 x i8] c"%2s*%2s*%4s\00"
@.str.3 = [13 x i8] c"%3s %2s, %2s\00"
@.str.4 = [13 x i8] c"%3s %2s, %4s\00"
@.str.5 = [12 x i8] c"%4s-%2s-%2s\00"
define i8* @parseDate(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [3 x i8]
%5 = alloca [4 x i8]
%6 = alloca [5 x i8]
%7 = alloca i8
store i8* %0, i8** %2
%8 = call i8* @malloc(i32 11)
store i8* %8, i8** %3
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 2
%11 = load i8, i8* %10
store i8 %11, i8* %7
%12 = load i8, i8* %7
%13 = sext i8 %12 to i32
switch i32 %13, label %40 [
i32 47, label %14
i32 35, label %24
i32 42, label %34
]
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = bitcast [4 x i8]* %5 to i8**
%17 = bitcast [3 x i8]* %4 to i8**
%18 = bitcast [5 x i8]* %6 to i8**
%19 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %16, i8** %17, i8** %18)
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%22 = call i32 @getCompleteYear(i8* %21)
%23 = call i32 @strcpy(i8* %20, i32 %22)
br label %84
24: ; preds = %1
%25 = load i8*, i8** %2
%26 = bitcast [4 x i8]* %5 to i8**
%27 = bitcast [5 x i8]* %6 to i8**
%28 = bitcast [3 x i8]* %4 to i8**
%29 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %26, i8** %27, i8** %28)
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%32 = call i32 @getCompleteYear(i8* %31)
%33 = call i32 @strcpy(i8* %30, i32 %32)
br label %84
34: ; preds = %1
%35 = load i8*, i8** %2
%36 = bitcast [3 x i8]* %4 to i8**
%37 = bitcast [4 x i8]* %5 to i8**
%38 = bitcast [5 x i8]* %6 to i8**
%39 = call i32 @sscanf(i8* %35, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %36, i8** %37, i8** %38)
br label %84
40: ; preds = %1
%41 = load i8, i8* %7
%42 = sext i8 %41 to i32
%43 = icmp sgt i32 %42, 97
br i1 %43, label %44, label %77
44: ; preds = %40
%45 = load i8, i8* %7
%46 = sext i8 %45 to i32
%47 = icmp slt i32 %46, 122
br i1 %47, label %48, label %77
48: ; preds = %44
%49 = load i8*, i8** %2
%50 = call i32 @strlen(i8* %49)
%51 = icmp eq i32 %50, 11
br i1 %51, label %52, label %66
52: ; preds = %48
%53 = load i8*, i8** %2
%54 = bitcast [4 x i8]* %5 to i8**
%55 = bitcast [3 x i8]* %4 to i8**
%56 = bitcast [5 x i8]* %6 to i8**
%57 = call i32 @sscanf(i8* %53, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %54, i8** %55, i8** %56)
%58 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%59 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%60 = call i32 @findMonth(i8* %59)
%61 = call i32 @strcpy(i8* %58, i32 %60)
%62 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%63 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%64 = call i32 @getCompleteYear(i8* %63)
%65 = call i32 @strcpy(i8* %62, i32 %64)
br label %76
66: ; preds = %48
%67 = load i8*, i8** %2
%68 = bitcast [4 x i8]* %5 to i8**
%69 = bitcast [3 x i8]* %4 to i8**
%70 = bitcast [5 x i8]* %6 to i8**
%71 = call i32 @sscanf(i8* %67, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %68, i8** %69, i8** %70)
%72 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%73 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%74 = call i32 @findMonth(i8* %73)
%75 = call i32 @strcpy(i8* %72, i32 %74)
br label %76
76: ; preds = %66, %52
br label %83
77: ; preds = %44, %40
%78 = load i8*, i8** %2
%79 = bitcast [5 x i8]* %6 to i8**
%80 = bitcast [4 x i8]* %5 to i8**
%81 = bitcast [3 x i8]* %4 to i8**
%82 = call i32 @sscanf(i8* %78, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8** %79, i8** %80, i8** %81)
br label %83
83: ; preds = %77, %76
br label %84
84: ; preds = %83, %34, %24, %14
%85 = load i8*, i8** %3
%86 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%87 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%88 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%89 = call i32 @sprintf(i8* %85, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %86, i8* %87, i8* %88)
%90 = load i8*, i8** %3
ret i8* %90
}

LLVM IR (-O2):
@.str = [12 x i8] c"%2s/%2s/%2s\00"
@.str.1 = [12 x i8] c"%2s#%2s#%2s\00"
@.str.2 = [12 x i8] c"%2s*%2s*%4s\00"
@.str.3 = [13 x i8] c"%3s %2s, %2s\00"
@.str.4 = [13 x i8] c"%3s %2s, %4s\00"
@.str.5 = [12 x i8] c"%4s-%2s-%2s\00"
define noalias i8* @parseDate(i8* %0) {
%2 = alloca [3 x i8]
%3 = alloca [4 x i8]
%4 = alloca [5 x i8]
%5 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %31 [
i32 47, label %12
i32 35, label %19
i32 42, label %26
]
12: ; preds = %1
%13 = bitcast [4 x i8]* %3 to i8**
%14 = bitcast [3 x i8]* %2 to i8**
%15 = bitcast [5 x i8]* %4 to i8**
%16 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %13, i8** %14, i8** %15)
%17 = call i32 @getCompleteYear(i8* %8)
%18 = call i32 @strcpy(i8* %8, i32 %17)
br label %55
19: ; preds = %1
%20 = bitcast [4 x i8]* %3 to i8**
%21 = bitcast [5 x i8]* %4 to i8**
%22 = bitcast [3 x i8]* %2 to i8**
%23 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %20, i8** %21, i8** %22)
%24 = call i32 @getCompleteYear(i8* %8)
%25 = call i32 @strcpy(i8* %8, i32 %24)
br label %55
26: ; preds = %1
%27 = bitcast [3 x i8]* %2 to i8**
%28 = bitcast [4 x i8]* %3 to i8**
%29 = bitcast [5 x i8]* %4 to i8**
%30 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %27, i8** %28, i8** %29)
br label %55
31: ; preds = %1
%32 = add i8 %10, -98
%33 = icmp ult i8 %32, 24
br i1 %33, label %34, label %50
34: ; preds = %31
%35 = tail call i32 @strlen(i8* %0)
%36 = icmp eq i32 %35, 11
%37 = bitcast [4 x i8]* %3 to i8**
%38 = bitcast [3 x i8]* %2 to i8**
%39 = bitcast [5 x i8]* %4 to i8**
br i1 %36, label %40, label %46
40: ; preds = %34
%41 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %37, i8** %38, i8** %39)
%42 = call i32 @findMonth(i8* %7)
%43 = call i32 @strcpy(i8* %7, i32 %42)
%44 = call i32 @getCompleteYear(i8* %8)
%45 = call i32 @strcpy(i8* %8, i32 %44)
br label %55
46: ; preds = %34
%47 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %37, i8** %38, i8** %39)
%48 = call i32 @findMonth(i8* %7)
%49 = call i32 @strcpy(i8* %7, i32 %48)
br label %55
50: ; preds = %31
%51 = bitcast [5 x i8]* %4 to i8**
%52 = bitcast [4 x i8]* %3 to i8**
%53 = bitcast [3 x i8]* %2 to i8**
%54 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8** %51, i8** %52, i8** %53)
br label %55
55: ; preds = %50, %46, %40, %26, %19, %12
%56 = call i32 @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %8, i8* %7, i8* %6)
ret i8* %5
}