#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 *);
char *strdup(char *);
int strlen(char *);
char *strtok(char *, char *);
void getFileTimeStamp(char *newFileTime, char *oldFileTime) {
  char *convertMonth(char *);
  char *word, *toParse, *year, *month, *day, *time;
  int numParses;
  numParses = 0;
  word = toParse = NULL;
  toParse = strtok(oldFileTime, "\n");
  if (toParse != NULL)
    word = strtok(toParse, " ");
  while (word != NULL) {
    switch (numParses) {
    case 1:
      month = strdup(convertMonth(word));
      break;
    case 2:
      day = strdup(word);
      break;
    case 3:
      time = strdup(word);
      break;
    case 4:
      year = strdup(word);
      break;
    }
    numParses++;
    word = strtok(NULL, " ");
  }
  if (strlen(day) == 1)
    sprintf(newFileTime, "%s/%s/0%s %s", year, month, day, time);
  else
    sprintf(newFileTime, "%s/%s/%s %s", year, month, day, time);
  free(month);
  free(day);
  free(time);
  free(year);
}


x86 assembly (clang, -O0):
<getFileTimeStamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ba <getFileTimeStamp+0x5a>
mov    -0x20(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    11bf <getFileTimeStamp+0x5f>
cmpq   $0x0,-0x18(%rbp)
je     1260 <getFileTimeStamp+0x100>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x3,%eax
ja     123e <getFileTimeStamp+0xde>
mov    -0x50(%rbp),%rax
lea    0xe16(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
call   1050 <convertMonth@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,-0x30(%rbp)
jmp    123e <getFileTimeStamp+0xde>
mov    -0x18(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x38(%rbp)
jmp    123e <getFileTimeStamp+0xde>
mov    -0x18(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x40(%rbp)
jmp    123e <getFileTimeStamp+0xde>
mov    -0x18(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdc0(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    11bf <getFileTimeStamp+0x5f>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    1297 <getFileTimeStamp+0x137>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x40(%rbp),%r9
lea    0xd87(%rip),%rsi
call   1070 <sprintf@plt>
jmp    12b7 <getFileTimeStamp+0x157>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x40(%rbp),%r9
lea    0xd6f(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFileTimeStamp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rax
mov    %rdi,0x8(%rsp)
lea    0xe93(%rip),%rsi
mov    %rax,%rdi
call   1060 <strtok@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     119e <getFileTimeStamp+0x3e>
lea    0xe7e(%rip),%rsi
mov    %rax,%rdi
call   1060 <strtok@plt>
jmp    11a0 <getFileTimeStamp+0x40>
xor    %eax,%eax
lea    0xe6b(%rip),%rbp
lea    0xe52(%rip),%r15
jmp    11d3 <getFileTimeStamp+0x73>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%r12
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
xor    %edi,%edi
mov    %rbp,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     121f <getFileTimeStamp+0xbf>
lea    -0x1(%r14),%ecx
cmp    $0x3,%ecx
ja     11c0 <getFileTimeStamp+0x60>
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mov    %rax,%rdi
call   1050 <convertMonth@plt>
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%r13
jmp    11c0 <getFileTimeStamp+0x60>
nopw   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
jmp    11c0 <getFileTimeStamp+0x60>
nopl   (%rax)
mov    %rax,%rdi
call   1080 <strdup@plt>
mov    %rax,0x10(%rsp)
jmp    11c0 <getFileTimeStamp+0x60>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
lea    0xde3(%rip),%rax
lea    0xde9(%rip),%rsi
cmove  %rax,%rsi
mov    0x8(%rsp),%rdi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
mov    0x10(%rsp),%rbp
mov    %rbp,%r9
call   1070 <sprintf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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