#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*/ julian_make_y2k_year(char *);
int /*<<< orphan*/ piece(char *, char, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int strlen(char *);
char *date_convert_international2american(char *international) {
  char day[16];
  char month[16];
  char year[16];
  static char american[16];
  if (character_count('-', international) != 2)
    return international;
  piece(year, '-', international, 0);
  if (strlen(year) == 2)
    strcpy(year, julian_make_y2k_year(year));
  piece(month, '-', international, 1);
  piece(day, '-', international, 2);
  sprintf(american, "%.2d/%.2d/%s", atoi(month), atoi(day), year);
  return american;
}


x86 assembly (clang, -O0):
<date_convert_international2american>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x2d,%edi
call   1060 <character_count@plt>
cmp    $0x2,%eax
je     11a0 <date_convert_international2american+0x30>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    124c <date_convert_international2american+0xdc>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2d,%esi
xor    %ecx,%ecx
call   1090 <piece@plt>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jne    11e2 <date_convert_international2american+0x72>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <julian_make_y2k_year@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x1,%ecx
call   1090 <piece@plt>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x2,%ecx
call   1090 <piece@plt>
lea    -0x30(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x4c(%rbp)
lea    -0x20(%rbp),%rdi
call   1070 <atoi@plt>
mov    -0x4c(%rbp),%edx
mov    %eax,%ecx
lea    -0x40(%rbp),%r8
lea    0x2e3b(%rip),%rdi
lea    0xdc4(%rip),%rsi
call   1080 <sprintf@plt>
lea    0x2e28(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date_convert_international2american>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
mov    $0x2d,%edi
mov    %rbx,%rsi
call   1060 <character_count@plt>
cmp    $0x2,%eax
jne    122d <date_convert_international2american+0xbd>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x2d,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1090 <piece@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jne    11ca <date_convert_international2american+0x5a>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <julian_make_y2k_year@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x2d,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1090 <piece@plt>
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x2d,%esi
mov    %rbx,%rdx
mov    $0x2,%ecx
call   1090 <piece@plt>
mov    %r14,%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1070 <atoi@plt>
lea    0x2e59(%rip),%rbx
lea    0xde2(%rip),%rsi
mov    %rsp,%r8
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %eax,%ecx
call   1080 <sprintf@plt>
mov    %rbx,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@date_convert_international2american.american = internal global [16 x i8] zeroinitializer
@.str = [13 x i8] c"%.2d/%.2d/%s\00"
define i8* @date_convert_international2american(i8* %0) {
%2 = alloca [16 x i8]
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%8 = tail call i32 @character_count(i8 signext 45, i8* %0)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %23
10: ; preds = %1
%11 = call i32 @piece(i8* %7, i8 signext 45, i8* %0, i32 0)
%12 = call i32 @strlen(i8* %7)
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @julian_make_y2k_year(i8* %7)
%16 = call i32 @strcpy(i8* %7, i32 %15)
br label %17
17: ; preds = %14, %10
%18 = call i32 @piece(i8* %6, i8 signext 45, i8* %0, i32 1)
%19 = call i32 @piece(i8* %5, i8 signext 45, i8* %0, i32 2)
%20 = call i32 @atoi(i8* %6)
%21 = call i32 @atoi(i8* %5)
%22 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @date_convert_international2american.american, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21, i8* %7)
br label %23
23: ; preds = %1, %17
%24 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @date_convert_international2american.american, i64 0, i64 0), %17 ], [ %0, %1 ]
ret i8* %24
}