#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*/ free(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
int strlen(char *);
char *strtok(char *, char *);
void getMailDate(char *value, char *dateLine) {
  char *convertMonth(char *);
  char *word, *toParse, *year, *month, *day, *time;
  char dateValue[1000] = {'\0'};
  int numParses;
  numParses = 0;
  word = toParse = NULL;
  strcpy(dateValue, dateLine);
  word = strtok(dateValue, " ");
  while (word != NULL) {
    numParses++;
    switch (numParses) {
    case 3:
      day = strdup(word);
      break;
    case 4:
      month = strdup(convertMonth(word));
      break;
    case 5:
      year = strdup(word);
      break;
    case 6:
      time = strdup(word);
      break;
    }
    word = strtok(NULL, " ");
  }
  if (strlen(day) == 1)
    sprintf(value, "%s/%s/0%s %s", year, month, day, time);
  else
    sprintf(value, "%s/%s/%s %s", year, month, day, time);
  free(month);
  free(day);
  free(year);
  free(time);
}


x86 assembly (clang, -O0):
<getMailDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e8,%edx
call   1070 <memset@plt>
movl   $0x0,-0x434(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x430(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1297 <getMailDate+0x117>
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
mov    -0x434(%rbp),%eax
add    $0xfffffffd,%eax
mov    %eax,%ecx
mov    %rcx,-0x440(%rbp)
sub    $0x3,%eax
ja     127e <getMailDate+0xfe>
mov    -0x440(%rbp),%rax
lea    0xdd6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x38(%rbp)
jmp    127e <getMailDate+0xfe>
mov    -0x18(%rbp),%rdi
call   1060 <convertMonth@plt>
mov    %rax,%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x30(%rbp)
jmp    127e <getMailDate+0xfe>
mov    -0x18(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x28(%rbp)
jmp    127e <getMailDate+0xfe>
mov    -0x18(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd87(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    11e7 <getMailDate+0x67>
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jne    12ce <getMailDate+0x14e>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x40(%rbp),%r9
lea    0xd4e(%rip),%rsi
call   1090 <sprintf@plt>
jmp    12ee <getMailDate+0x16e>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x40(%rbp),%r9
lea    0xd36(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMailDate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f8,%rsp
mov    %rsi,%rbx
mov    %rdi,(%rsp)
lea    0x10(%rsp),%rbp
xor    %r14d,%r14d
mov    $0x3e8,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe4f(%rip),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <strtok@plt>
lea    0xe2d(%rip),%r15
jmp    1203 <getMailDate+0x83>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,%rdi
call   10a0 <strdup@plt>
mov    %rax,0x8(%rsp)
nopl   (%rax)
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <strtok@plt>
add    $0x1,%r14d
test   %rax,%rax
je     125d <getMailDate+0xdd>
lea    -0x2(%r14),%ecx
cmp    $0x3,%ecx
ja     11f0 <getMailDate+0x70>
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mov    %rax,%rdi
call   10a0 <strdup@plt>
mov    %rax,%r13
jmp    11f0 <getMailDate+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,%rdi
call   1060 <convertMonth@plt>
mov    %rax,%rdi
call   10a0 <strdup@plt>
mov    %rax,%rbp
jmp    11f0 <getMailDate+0x70>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rax,%rdi
call   10a0 <strdup@plt>
mov    %rax,%r12
jmp    11f0 <getMailDate+0x70>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
lea    0xda3(%rip),%rax
lea    0xda9(%rip),%rsi
cmove  %rax,%rsi
mov    (%rsp),%rdi
mov    %r12,%rdx
mov    %rbp,%rcx
mov    %r13,%r8
mov    0x8(%rsp),%rbx
mov    %rbx,%r9
call   1090 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [13 x i8] c"%s/%s/0%s %s\00"
@.str.2 = [12 x i8] c"%s/%s/%s %s\00"
define void @getMailDate(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [1000 x i8]
%12 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%13 = bitcast [1000 x i8]* %11 to i8*
store i32 0, i32* %12
store i8* null, i8** %6
store i8* null, i8** %5
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%18 = call i8* @strtok(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %18, i8** %5
br label %19
19: ; preds = %39, %2
%20 = load i8*, i8** %5
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %41
22: ; preds = %19
%23 = load i32, i32* %12
%24 = add nsw i32 %23, 1
store i32 %24, i32* %12
%25 = load i32, i32* %12
switch i32 %25, label %39 [
i32 3, label %26
i32 4, label %29
i32 5, label %33
i32 6, label %36
]
26: ; preds = %22
%27 = load i8*, i8** %5
%28 = call i8* @strdup(i8* %27)
store i8* %28, i8** %9
br label %39
29: ; preds = %22
%30 = load i8*, i8** %5
%31 = call i8* @convertMonth(i8* %30)
%32 = call i8* @strdup(i8* %31)
store i8* %32, i8** %8
br label %39
33: ; preds = %22
%34 = load i8*, i8** %5
%35 = call i8* @strdup(i8* %34)
store i8* %35, i8** %7
br label %39
36: ; preds = %22
%37 = load i8*, i8** %5
%38 = call i8* @strdup(i8* %37)
store i8* %38, i8** %10
br label %39
39: ; preds = %22, %36, %33, %29, %26
%40 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %40, i8** %5
br label %19
41: ; preds = %19
%42 = load i8*, i8** %9
%43 = call i32 @strlen(i8* %42)
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %52
45: ; preds = %41
%46 = load i8*, i8** %3
%47 = load i8*, i8** %7
%48 = load i8*, i8** %8
%49 = load i8*, i8** %9
%50 = load i8*, i8** %10
%51 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %47, i8* %48, i8* %49, i8* %50)
br label %59
52: ; preds = %41
%53 = load i8*, i8** %3
%54 = load i8*, i8** %7
%55 = load i8*, i8** %8
%56 = load i8*, i8** %9
%57 = load i8*, i8** %10
%58 = call i32 @sprintf(i8* %53, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %54, i8* %55, i8* %56, i8* %57)
br label %59
59: ; preds = %52, %45
%60 = load i8*, i8** %8
%61 = call i32 @free(i8* %60)
%62 = load i8*, i8** %9
%63 = call i32 @free(i8* %62)
%64 = load i8*, i8** %7
%65 = call i32 @free(i8* %64)
%66 = load i8*, i8** %10
%67 = call i32 @free(i8* %66)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [13 x i8] c"%s/%s/0%s %s\00"
@.str.2 = [12 x i8] c"%s/%s/%s %s\00"
define void @getMailDate(i8* nocapture writeonly %0, i8* %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %1)
%6 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i8* %6, null
br label %8
8: ; preds = %2, %25
%9 = phi i32 [ %15, %25 ], [ 0, %2 ]
%10 = phi i8* [ %29, %25 ], [ undef, %2 ]
%11 = phi i8* [ %28, %25 ], [ undef, %2 ]
%12 = phi i8* [ %27, %25 ], [ undef, %2 ]
%13 = phi i8* [ %26, %25 ], [ undef, %2 ]
%14 = phi i8* [ %30, %25 ], [ %6, %2 ]
%15 = add nuw nsw i32 %9, 1
switch i32 %9, label %25 [
i32 2, label %16
i32 3, label %18
i32 4, label %21
i32 5, label %23
]
16: ; preds = %8
%17 = call i8* @strdup(i8* %14)
br label %25
18: ; preds = %8
%19 = call i8* @convertMonth(i8* %14)
%20 = call i8* @strdup(i8* %19)
br label %25
21: ; preds = %8
%22 = call i8* @strdup(i8* %14)
br label %25
23: ; preds = %8
%24 = call i8* @strdup(i8* %14)
br label %25
25: ; preds = %8, %23, %21, %18, %16
%26 = phi i8* [ %13, %8 ], [ %13, %23 ], [ %22, %21 ], [ %13, %18 ], [ %13, %16 ]
%27 = phi i8* [ %12, %8 ], [ %12, %23 ], [ %12, %21 ], [ %20, %18 ], [ %12, %16 ]
%28 = phi i8* [ %11, %8 ], [ %11, %23 ], [ %11, %21 ], [ %11, %18 ], [ %17, %16 ]
%29 = phi i8* [ %10, %8 ], [ %24, %23 ], [ %10, %21 ], [ %10, %18 ], [ %10, %16 ]
%30 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %8
32: ; preds = %25
%33 = call i32 @strlen(i8* %28)
%34 = icmp eq i32 %33, 1
%35 = select i1 %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0)
%36 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) %35, i8* %26, i8* %27, i8* %28, i8* %29)
%37 = call i32 @free(i8* %27)
%38 = call i32 @free(i8* %28)
%39 = call i32 @free(i8* %26)
%40 = call i32 @free(i8* %29)
ret void
}