#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 *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
char *strtok(char *, char *);
void formatTimeStamp(char *newTimeStamp, char *oldTimeStamp) {
  void formatTime(char *, char *);
  void formatDate(char *, char *);
  char *word, *toParse, *date, *time;
  char formattedTime[9] = {'\0'};
  char formattedDate[11] = {'\0'};
  char oldTime[9] = {'\0'};
  char oldDate[11] = {'\0'};
  int numParses;
  numParses = 0;
  word = toParse = date = time = NULL;
  toParse = strdup(oldTimeStamp);
  word = strtok(toParse, "-");
  while (word != NULL) {
    switch (numParses) {
    case 0:
      strcpy(oldDate, word);
      break;
    case 1:
      strcpy(oldTime, word);
      break;
    }
    numParses++;
    word = strtok(NULL, "-");
  }
  formatDate(formattedDate, oldDate);
  date = strdup(formattedDate);
  formatTime(formattedTime, oldTime);
  time = strdup(formattedTime);
  sprintf(newTimeStamp, "%s %s", date, time);
  free(date);
  free(time);
  free(toParse);
}


x86 assembly (clang, -O0):
<formatTimeStamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x39(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
lea    -0x44(%rbp),%rdi
xor    %esi,%esi
mov    $0xb,%edx
call   1050 <memset@plt>
lea    -0x4d(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1050 <memset@plt>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0xb,%edx
call   1050 <memset@plt>
movl   $0x0,-0x5c(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1288 <formatTimeStamp+0x108>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x60(%rbp)
test   %eax,%eax
je     1247 <formatTimeStamp+0xc7>
jmp    1236 <formatTimeStamp+0xb6>
mov    -0x60(%rbp),%eax
sub    $0x1,%eax
je     1259 <formatTimeStamp+0xd9>
jmp    1266 <formatTimeStamp+0xe6>
lea    -0x58(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1266 <formatTimeStamp+0xe6>
lea    -0x4d(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd86(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    1218 <formatTimeStamp+0x98>
lea    -0x44(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1060 <formatDate@plt>
lea    -0x44(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x28(%rbp)
lea    -0x39(%rbp),%rdi
lea    -0x4d(%rbp),%rsi
call   10a0 <formatTime@plt>
lea    -0x39(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xd33(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<formatTimeStamp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%r14
movb   $0x0,0x30(%rsp)
movq   $0x0,0x28(%rsp)
movl   $0x0,0x3f(%rsp)
movq   $0x0,0x38(%rsp)
movb   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movl   $0x0,0x1f(%rsp)
movq   $0x0,0x18(%rsp)
mov    %rsi,%rdi
call   1080 <strdup@plt>
mov    %rax,%r15
lea    0xe2f(%rip),%rsi
mov    %rax,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     122b <formatTimeStamp+0xbb>
xor    %ebx,%ebx
lea    0x18(%rsp),%r13
lea    0xe14(%rip),%r12
lea    0x8(%rsp),%rbp
jmp    121a <formatTimeStamp+0xaa>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,%rsi
call   1040 <strcpy@plt>
add    $0x1,%ebx
xor    %edi,%edi
mov    %r12,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     122b <formatTimeStamp+0xbb>
mov    %r13,%rdi
test   %ebx,%ebx
je     1200 <formatTimeStamp+0x90>
cmp    $0x1,%ebx
jne    1208 <formatTimeStamp+0x98>
mov    %rbp,%rdi
jmp    1200 <formatTimeStamp+0x90>
lea    0x38(%rsp),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <formatDate@plt>
mov    %rbx,%rdi
call   1080 <strdup@plt>
mov    %rax,%r13
lea    0x28(%rsp),%r12
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1090 <formatTime@plt>
mov    %r12,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
lea    0xd96(%rip),%rsi
mov    %r14,%rdi
mov    %r13,%rdx
mov    %rax,%rcx
call   1070 <sprintf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
add    $0x48,%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 = [6 x i8] c"%s %s\00"
define void @formatTimeStamp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [9 x i8]
%10 = alloca [11 x i8]
%11 = alloca [9 x i8]
%12 = alloca [11 x i8]
%13 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%14 = bitcast [9 x i8]* %9 to i8*
%15 = bitcast [11 x i8]* %10 to i8*
%16 = bitcast [9 x i8]* %11 to i8*
%17 = bitcast [11 x i8]* %12 to i8*
store i32 0, i32* %13
store i8* null, i8** %8
store i8* null, i8** %7
store i8* null, i8** %6
store i8* null, i8** %5
%18 = load i8*, i8** %4
%19 = call i8* @strdup(i8* %18)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i8* @strtok(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %5
br label %22
22: ; preds = %35, %2
%23 = load i8*, i8** %5
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %39
25: ; preds = %22
%26 = load i32, i32* %13
switch i32 %26, label %35 [
i32 0, label %27
i32 1, label %31
]
27: ; preds = %25
%28 = getelementptr inbounds [11 x i8], [11 x i8]* %12, i64 0, i64 0
%29 = load i8*, i8** %5
%30 = call i32 @strcpy(i8* %28, i8* %29)
br label %35
31: ; preds = %25
%32 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
%33 = load i8*, i8** %5
%34 = call i32 @strcpy(i8* %32, i8* %33)
br label %35
35: ; preds = %25, %31, %27
%36 = load i32, i32* %13
%37 = add nsw i32 %36, 1
store i32 %37, i32* %13
%38 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %38, i8** %5
br label %22
39: ; preds = %22
%40 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%41 = getelementptr inbounds [11 x i8], [11 x i8]* %12, i64 0, i64 0
%42 = getelementptr inbounds [11 x i8], [11 x i8]* %10, i64 0, i64 0
%43 = call i8* @strdup(i8* %42)
store i8* %43, i8** %7
%44 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%45 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
%46 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%47 = call i8* @strdup(i8* %46)
store i8* %47, i8** %8
%48 = load i8*, i8** %3
%49 = load i8*, i8** %7
%50 = load i8*, i8** %8
%51 = call i32 @sprintf(i8* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %49, i8* %50)
%52 = load i8*, i8** %7
%53 = call i32 @free(i8* %52)
%54 = load i8*, i8** %8
%55 = call i32 @free(i8* %54)
%56 = load i8*, i8** %6
%57 = call i32 @free(i8* %56)
ret void
}

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