#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*/ piece(char *, char, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *mysql2american_date(char *date_buffer, char *mysql_date) {
  char piece_buffer[128];
  *date_buffer = '\0';
  if (!piece(piece_buffer, '-', mysql_date, 1))
    return "";
  strcpy(date_buffer, piece_buffer);
  if (!piece(piece_buffer, '-', mysql_date, 2))
    return "";
  strcat(date_buffer, "/");
  strcat(date_buffer, piece_buffer);
  if (!piece(piece_buffer, '-', mysql_date, 0))
    return "";
  strcat(date_buffer, "/");
  strcat(date_buffer, piece_buffer);
  return date_buffer;
}


x86 assembly (clang, -O0):
<mysql2american_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x1,%ecx
call   1050 <piece@plt>
cmp    $0x0,%eax
jne    117d <mysql2american_date+0x4d>
lea    0xe8d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1238 <mysql2american_date+0x108>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x2,%ecx
call   1050 <piece@plt>
cmp    $0x0,%eax
jne    11c0 <mysql2american_date+0x90>
lea    0xe4a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1238 <mysql2american_date+0x108>
mov    -0x10(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcat@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2d,%esi
xor    %ecx,%ecx
call   1050 <piece@plt>
cmp    $0x0,%eax
jne    1210 <mysql2american_date+0xe0>
lea    0xdfa(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1238 <mysql2american_date+0x108>
mov    -0x10(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysql2american_date>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
movb   $0x0,(%rdi)
mov    %rsp,%rdi
mov    $0x2d,%esi
mov    %r15,%rdx
mov    $0x1,%ecx
call   1050 <piece@plt>
lea    0xe9e(%rip),%r14
test   %eax,%eax
je     11de <mysql2american_date+0xae>
mov    %rsp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    $0x2d,%esi
mov    %r15,%rdx
mov    $0x2,%ecx
call   1050 <piece@plt>
test   %eax,%eax
je     11de <mysql2american_date+0xae>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rsp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcat@plt>
mov    %r12,%rdi
mov    $0x2d,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1050 <piece@plt>
test   %eax,%eax
je     11de <mysql2american_date+0xae>
lea    0xe38(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rbx,%r14
mov    %r14,%rax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"/\00"
define i8* @mysql2american_date(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [128 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
store i8 0, i8* %7
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%9 = load i8*, i8** %5
%10 = call i32 @piece(i8* %8, i8 signext 45, i8* %9, i32 1)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %40
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%18 = load i8*, i8** %5
%19 = call i32 @piece(i8* %17, i8 signext 45, i8* %18, i32 2)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %13
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %40
22: ; preds = %13
%23 = load i8*, i8** %4
%24 = call i32 @strcat(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = load i8*, i8** %4
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%27 = call i32 @strcat(i8* %25, i8* %26)
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%29 = load i8*, i8** %5
%30 = call i32 @piece(i8* %28, i8 signext 45, i8* %29, i32 0)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %22
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %3
br label %40
33: ; preds = %22
%34 = load i8*, i8** %4
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%36 = load i8*, i8** %4
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%38 = call i32 @strcat(i8* %36, i8* %37)
%39 = load i8*, i8** %4
store i8* %39, i8** %3
br label %40
40: ; preds = %33, %32, %21, %12
%41 = load i8*, i8** %3
ret i8* %41
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"/\00"
define i8* @mysql2american_date(i8* %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
store i8 0, i8* %0
%5 = call i32 @piece(i8* %4, i8 signext 45, i8* %1, i32 1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %2
%8 = call i32 @strcpy(i8* %0, i8* %4)
%9 = call i32 @piece(i8* %4, i8 signext 45, i8* %1, i32 2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %7
%12 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @strcat(i8* %0, i8* %4)
%14 = call i32 @piece(i8* %4, i8 signext 45, i8* %1, i32 0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @strcat(i8* %0, i8* %4)
br label %19
19: ; preds = %11, %7, %2, %16
%20 = phi i8* [ %0, %16 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %7 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %11 ]
ret i8* %20
}