#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 *);
char *julian_make_y2k_year(char *);
int /*<<< orphan*/ piece(char *, char, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int timlib_ora_month2integer(char *);
char *timlib_ora_date_to_yyyy_mm_dd(char *s) {
  static char ret_buffer[128];
  int mm_int;
  char yyyy[128], mon[128], dd[128];
  strcpy(ret_buffer, s);
  if (!piece(dd, '-', s, 0))
    return ret_buffer;
  if (!piece(mon, '-', s, 1))
    return ret_buffer;
  if (!piece(yyyy, '-', s, 2))
    return ret_buffer;
  if (strlen(yyyy) == 2)
    strcpy(yyyy, julian_make_y2k_year(yyyy));
  mm_int = timlib_ora_month2integer(mon);
  if (mm_int < 1)
    return ret_buffer;
  sprintf(ret_buffer, "%s-%02d-%02d", yyyy, mm_int, atoi(dd));
  return ret_buffer;
}


x86 assembly (clang, -O0):
<timlib_ora_date_to_yyyy_mm_dd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2ee6(%rip),%rdi
call   1030 <strcpy@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2d,%esi
xor    %ecx,%ecx
call   1090 <piece@plt>
cmp    $0x0,%eax
jne    11bf <timlib_ora_date_to_yyyy_mm_dd+0x4f>
lea    0x2eba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12dd <timlib_ora_date_to_yyyy_mm_dd+0x16d>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x1,%ecx
call   1090 <piece@plt>
cmp    $0x0,%eax
jne    11f2 <timlib_ora_date_to_yyyy_mm_dd+0x82>
lea    0x2e87(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12dd <timlib_ora_date_to_yyyy_mm_dd+0x16d>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x2,%ecx
call   1090 <piece@plt>
cmp    $0x0,%eax
jne    1225 <timlib_ora_date_to_yyyy_mm_dd+0xb5>
lea    0x2e54(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12dd <timlib_ora_date_to_yyyy_mm_dd+0x16d>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jne    1263 <timlib_ora_date_to_yyyy_mm_dd+0xf3>
lea    -0xa0(%rbp),%rax
mov    %rax,-0x1a8(%rbp)
lea    -0xa0(%rbp),%rdi
call   1050 <julian_make_y2k_year@plt>
mov    -0x1a8(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
call   1060 <timlib_ora_month2integer@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    128c <timlib_ora_date_to_yyyy_mm_dd+0x11c>
lea    0x2ded(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12dd <timlib_ora_date_to_yyyy_mm_dd+0x16d>
lea    -0xa0(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1ac(%rbp)
lea    -0x1a0(%rbp),%rdi
call   1070 <atoi@plt>
mov    -0x1b8(%rbp),%rdx
mov    -0x1ac(%rbp),%ecx
mov    %eax,%r8d
lea    0x2daa(%rip),%rdi
lea    0xd33(%rip),%rsi
call   1080 <sprintf@plt>
lea    0x2d97(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timlib_ora_date_to_yyyy_mm_dd>:
push   %rbx
sub    $0x180,%rsp
mov    %rdi,%rbx
lea    0x2eee(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0x80(%rsp),%rdi
mov    $0x2d,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1090 <piece@plt>
test   %eax,%eax
je     123e <timlib_ora_date_to_yyyy_mm_dd+0xce>
lea    0x100(%rsp),%rdi
mov    $0x2d,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1090 <piece@plt>
test   %eax,%eax
je     123e <timlib_ora_date_to_yyyy_mm_dd+0xce>
mov    %rsp,%rdi
mov    $0x2d,%esi
mov    %rbx,%rdx
mov    $0x2,%ecx
call   1090 <piece@plt>
test   %eax,%eax
je     123e <timlib_ora_date_to_yyyy_mm_dd+0xce>
mov    %rsp,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jne    1203 <timlib_ora_date_to_yyyy_mm_dd+0x93>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <julian_make_y2k_year@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    0x100(%rsp),%rdi
call   1060 <timlib_ora_month2integer@plt>
test   %eax,%eax
jle    123e <timlib_ora_date_to_yyyy_mm_dd+0xce>
mov    %eax,%ebx
lea    0x80(%rsp),%rdi
call   1070 <atoi@plt>
lea    0x2e46(%rip),%rdi
lea    0xdcf(%rip),%rsi
mov    %rsp,%rdx
mov    %ebx,%ecx
mov    %eax,%r8d
call   1080 <sprintf@plt>
lea    0x2e2b(%rip),%rax
add    $0x180,%rsp
pop    %rbx
ret

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

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