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


x86 assembly (clang, -O0):
<date_convert_international_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
movb   $0x0,0x2edd(%rip)
mov    -0x10(%rbp),%rdi
call   1070 <date_convert_valid_american@plt>
cmp    $0x0,%eax
jne    11b5 <date_convert_international_string+0x35>
lea    0x2ec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b0 <date_convert_international_string+0x130>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2f,%esi
xor    %ecx,%ecx
call   10a0 <piece@plt>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2f,%esi
mov    $0x1,%ecx
call   10a0 <piece@plt>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2f,%esi
mov    $0x2,%ecx
call   10a0 <piece@plt>
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jne    123c <date_convert_international_string+0xbc>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
mov    $0x2d,%edx
call   1050 <search_replace_character@plt>
mov    -0x10(%rbp),%rsi
lea    0x2e49(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2e3d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b0 <date_convert_international_string+0x130>
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jne    126b <date_convert_international_string+0xeb>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1060 <julian_make_y2k_year@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x30(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x4c(%rbp)
lea    -0x20(%rbp),%rdi
call   1080 <atoi@plt>
mov    -0x58(%rbp),%rdx
mov    -0x4c(%rbp),%ecx
mov    %eax,%r8d
lea    0x2dd7(%rip),%rdi
lea    0xd60(%rip),%rsi
call   1090 <sprintf@plt>
lea    0x2dc4(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date_convert_international_string>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
movb   $0x0,0x2edf(%rip)
call   1070 <date_convert_valid_american@plt>
test   %eax,%eax
je     1265 <date_convert_international_string+0xe5>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x2f,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   10a0 <piece@plt>
lea    0x20(%rsp),%rdi
mov    $0x2f,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   10a0 <piece@plt>
mov    %rsp,%rdi
mov    $0x2f,%esi
mov    %rbx,%rdx
mov    $0x2,%ecx
call   10a0 <piece@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x4,%eax
jne    1211 <date_convert_international_string+0x91>
mov    %rbx,%rdi
mov    $0x2f,%esi
mov    $0x2d,%edx
call   1050 <search_replace_character@plt>
lea    0x2e69(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    1265 <date_convert_international_string+0xe5>
mov    %rsp,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jne    1234 <date_convert_international_string+0xb4>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <julian_make_y2k_year@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    0x10(%rsp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
lea    0x20(%rsp),%rdi
call   1080 <atoi@plt>
lea    0x2e1f(%rip),%rdi
lea    0xda8(%rip),%rsi
mov    %rsp,%rdx
mov    %ebx,%ecx
mov    %eax,%r8d
call   1090 <sprintf@plt>
lea    0x2e04(%rip),%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@date_convert_international_string.international = internal global [256 x i8] zeroinitializer
@.str = [13 x i8] c"%s-%.2d-%.2d\00"
define i8* @date_convert_international_string(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
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0)
%7 = load i8*, i8** %3
%8 = call i32 @date_convert_valid_american(i8* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0), i8** %2
br label %45
11: ; preds = %1
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %3
%14 = call i32 @piece(i8* %12, i8 signext 47, i8* %13, i32 0)
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = call i32 @piece(i8* %15, i8 signext 47, i8* %16, i32 1)
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%19 = load i8*, i8** %3
%20 = call i32 @piece(i8* %18, i8 signext 47, i8* %19, i32 2)
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = icmp eq i32 %22, 4
br i1 %23, label %24, label %29
24: ; preds = %11
%25 = load i8*, i8** %3
%26 = call i32 @search_replace_character(i8* %25, i8 signext 47, i8 signext 45)
%27 = load i8*, i8** %3
%28 = call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0), i8* %27)
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0), i8** %2
br label %45
29: ; preds = %11
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%36 = call i8* @julian_make_y2k_year(i8* %35)
%37 = call i32 @strcpy(i8* %34, i8* %36)
br label %38
38: ; preds = %33, %29
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%40 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%41 = call i32 @atoi(i8* %40)
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%43 = call i32 @atoi(i8* %42)
%44 = call i32 @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %39, i32 %41, i32 %43)
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0), i8** %2
br label %45
45: ; preds = %38, %24, %10
%46 = load i8*, i8** %2
ret i8* %46
}

LLVM IR (-O2):
@date_convert_international_string.international = internal global [256 x i8] zeroinitializer
@.str = [13 x i8] c"%s-%.2d-%.2d\00"
define i8* @date_convert_international_string(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
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0)
%8 = tail call i32 @date_convert_valid_american(i8* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %29, label %10
10: ; preds = %1
%11 = call i32 @piece(i8* %6, i8 signext 47, i8* %0, i32 0)
%12 = call i32 @piece(i8* %5, i8 signext 47, i8* %0, i32 1)
%13 = call i32 @piece(i8* %7, i8 signext 47, i8* %0, i32 2)
%14 = call i32 @strlen(i8* %6)
%15 = icmp eq i32 %14, 4
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = call i32 @search_replace_character(i8* %0, i8 signext 47, i8 signext 45)
%18 = call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0), i8* %0)
br label %29
19: ; preds = %10
%20 = call i32 @strlen(i8* %7)
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = call i8* @julian_make_y2k_year(i8* %7)
%24 = call i32 @strcpy(i8* %7, i8* %23)
br label %25
25: ; preds = %22, %19
%26 = call i32 @atoi(i8* %6)
%27 = call i32 @atoi(i8* %5)
%28 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %26, i32 %27)
br label %29
29: ; preds = %1, %25, %16
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @date_convert_international_string.international, i64 0, i64 0)
}