#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 *);
int character_count(char, char *);
int /*<<< orphan*/ date_time_parse(int *, int *, char *);
int /*<<< orphan*/ piece(char *, char, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, char *, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *google_chart_convert_date(char *destination, char *yyyy_mm_dd,
                                char *hhmm) {
  char date_half[64];
  char time_half[64];
  char year[16];
  char month[16];
  char day[16];
  int hours = 0;
  int minutes = 0;
  if (character_count('-', yyyy_mm_dd) != 2) {
    strcpy(destination, yyyy_mm_dd);
    return destination;
  }
  if (character_count(' ', yyyy_mm_dd) == 1) {
    piece(date_half, ' ', yyyy_mm_dd, 0);
    piece(time_half, ' ', yyyy_mm_dd, 1);
    yyyy_mm_dd = date_half;
    if (*(time_half + 2) == ':') {
      *(time_half + 2) = *(time_half + 3);
      *(time_half + 3) = *(time_half + 4);
      *(time_half + 4) = '\0';
    }
    hhmm = time_half;
  } else if (character_count(':', yyyy_mm_dd) == 1) {
    piece(date_half, ':', yyyy_mm_dd, 0);
    piece(time_half, ':', yyyy_mm_dd, 1);
    yyyy_mm_dd = date_half;
    hhmm = time_half;
  }
  piece(year, '-', yyyy_mm_dd, 0);
  piece(month, '-', yyyy_mm_dd, 1);
  piece(day, '-', yyyy_mm_dd, 2);
  if (hhmm) {
    date_time_parse(&hours, &minutes, hhmm);
  }
  sprintf(destination, "new Date(%s,%d,%s,%d,%d,0)", year, atoi(month) - 1, day,
          hours, minutes);
  return destination;
}


x86 assembly (clang, -O0):
<google_chart_convert_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
mov    -0x18(%rbp),%rsi
mov    $0x2d,%edi
call   1050 <character_count@plt>
cmp    $0x2,%eax
je     11bc <google_chart_convert_date+0x5c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1375 <google_chart_convert_date+0x215>
mov    -0x18(%rbp),%rsi
mov    $0x20,%edi
call   1050 <character_count@plt>
cmp    $0x1,%eax
jne    1248 <google_chart_convert_date+0xe8>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x20,%esi
xor    %ecx,%ecx
call   1080 <piece@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x20,%esi
mov    $0x1,%ecx
call   1080 <piece@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsbl -0x9e(%rbp),%eax
cmp    $0x3a,%eax
jne    1238 <google_chart_convert_date+0xd8>
mov    -0x9d(%rbp),%al
mov    %al,-0x9e(%rbp)
mov    -0x9c(%rbp),%al
mov    %al,-0x9d(%rbp)
movb   $0x0,-0x9c(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    12a5 <google_chart_convert_date+0x145>
mov    -0x18(%rbp),%rsi
mov    $0x3a,%edi
call   1050 <character_count@plt>
cmp    $0x1,%eax
jne    12a0 <google_chart_convert_date+0x140>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3a,%esi
xor    %ecx,%ecx
call   1080 <piece@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3a,%esi
mov    $0x1,%ecx
call   1080 <piece@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    12a5 <google_chart_convert_date+0x145>
lea    -0xb0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2d,%esi
xor    %ecx,%ecx
call   1080 <piece@plt>
lea    -0xc0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x1,%ecx
call   1080 <piece@plt>
lea    -0xd0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x2,%ecx
call   1080 <piece@plt>
cmpq   $0x0,-0x20(%rbp)
je     1312 <google_chart_convert_date+0x1b2>
mov    -0x20(%rbp),%rdx
lea    -0xd4(%rbp),%rdi
lea    -0xd8(%rbp),%rsi
call   1040 <date_time_parse@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
lea    -0xc0(%rbp),%rdi
call   1060 <atoi@plt>
mov    -0xe8(%rbp),%rdi
mov    -0xe0(%rbp),%rdx
mov    %eax,%ecx
sub    $0x1,%ecx
lea    -0xd0(%rbp),%r8
mov    -0xd4(%rbp),%r9d
mov    -0xd8(%rbp),%eax
lea    0xc9b(%rip),%rsi
mov    %eax,(%rsp)
call   1070 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<google_chart_convert_date>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc0,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    $0x2d,%edi
call   1050 <character_count@plt>
cmp    $0x2,%eax
jne    11f5 <google_chart_convert_date+0x95>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1050 <character_count@plt>
cmp    $0x1,%eax
jne    1205 <google_chart_convert_date+0xa5>
lea    0x40(%rsp),%r15
lea    0x80(%rsp),%r12
mov    %r12,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1080 <piece@plt>
mov    %r15,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1080 <piece@plt>
cmpb   $0x3a,0x42(%rsp)
jne    1250 <google_chart_convert_date+0xf0>
movzwl 0x43(%rsp),%eax
mov    %ax,0x42(%rsp)
movb   $0x0,0x44(%rsp)
jmp    1250 <google_chart_convert_date+0xf0>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    12e4 <google_chart_convert_date+0x184>
mov    $0x3a,%edi
mov    %rbx,%rsi
call   1050 <character_count@plt>
cmp    $0x1,%eax
jne    124d <google_chart_convert_date+0xed>
lea    0x40(%rsp),%r15
lea    0x80(%rsp),%r12
mov    %r12,%rdi
mov    $0x3a,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1080 <piece@plt>
mov    %r15,%rdi
mov    $0x3a,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1080 <piece@plt>
jmp    1250 <google_chart_convert_date+0xf0>
mov    %rbx,%r12
lea    0x30(%rsp),%rdi
xor    %ebp,%ebp
mov    $0x2d,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   1080 <piece@plt>
lea    0x20(%rsp),%rdi
mov    $0x2d,%esi
mov    %r12,%rdx
mov    $0x1,%ecx
call   1080 <piece@plt>
lea    0x10(%rsp),%rdi
mov    $0x2d,%esi
mov    %r12,%rdx
mov    $0x2,%ecx
call   1080 <piece@plt>
mov    $0x0,%ebx
test   %r15,%r15
je     12b8 <google_chart_convert_date+0x158>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %r15,%rdx
call   1040 <date_time_parse@plt>
mov    0xc(%rsp),%ebx
mov    0x8(%rsp),%ebp
lea    0x20(%rsp),%rdi
call   1060 <atoi@plt>
lea    -0x1(%rax),%ecx
mov    %ebp,(%rsp)
lea    0xd31(%rip),%rsi
lea    0x30(%rsp),%rdx
lea    0x10(%rsp),%r8
mov    %r14,%rdi
mov    %ebx,%r9d
call   1070 <sprintf@plt>
mov    %r14,%rax
add    $0xc0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [27 x i8] c"new Date(%s,%d,%s,%d,%d,0)\00"
define i8* @google_chart_convert_date(i8* returned %0, i8* %1, i8* %2) {
%4 = alloca [64 x i8]
%5 = alloca [64 x i8]
%6 = alloca [16 x i8]
%7 = alloca [16 x i8]
%8 = alloca [16 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%16 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%17 = bitcast i32* %10 to i8*
store i32 0, i32* %10
%18 = tail call i32 @character_count(i8 signext 45, i8* %1)
%19 = icmp eq i32 %18, 2
br i1 %19, label %22, label %20
20: ; preds = %3
%21 = tail call i32 @strcpy(i8* %0, i8* %1)
br label %59
22: ; preds = %3
%23 = tail call i32 @character_count(i8 signext 32, i8* %1)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = call i32 @piece(i8* %11, i8 signext 32, i8* %1, i32 0)
%27 = call i32 @piece(i8* %12, i8 signext 32, i8* %1, i32 1)
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 2
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 58
br i1 %30, label %31, label %42
31: ; preds = %25
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 3
%33 = load i8, i8* %32
store i8 %33, i8* %28
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 4
%35 = load i8, i8* %34
store i8 %35, i8* %32
store i8 0, i8* %34
br label %42
36: ; preds = %22
%37 = tail call i32 @character_count(i8 signext 58, i8* %1)
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = call i32 @piece(i8* %11, i8 signext 58, i8* %1, i32 0)
%41 = call i32 @piece(i8* %12, i8 signext 58, i8* %1, i32 1)
br label %42
42: ; preds = %25, %31, %36, %39
%43 = phi i8* [ %11, %39 ], [ %1, %36 ], [ %11, %31 ], [ %11, %25 ]
%44 = phi i8* [ %12, %39 ], [ %2, %36 ], [ %12, %31 ], [ %12, %25 ]
%45 = call i32 @piece(i8* %13, i8 signext 45, i8* %43, i32 0)
%46 = call i32 @piece(i8* %14, i8 signext 45, i8* %43, i32 1)
%47 = call i32 @piece(i8* %15, i8 signext 45, i8* %43, i32 2)
%48 = icmp eq i8* %44, null
br i1 %48, label %53, label %49
49: ; preds = %42
%50 = call i32 @date_time_parse(i32* %9, i32* %10, i8* %44)
%51 = load i32, i32* %9
%52 = load i32, i32* %10
br label %53
53: ; preds = %49, %42
%54 = phi i32 [ %52, %49 ], [ 0, %42 ]
%55 = phi i32 [ %51, %49 ], [ 0, %42 ]
%56 = call i32 @atoi(i8* %14)
%57 = add nsw i32 %56, -1
%58 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %57, i8* %15, i32 %55, i32 %54)
br label %59
59: ; preds = %53, %20
ret i8* %0
}