#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*/ julian_get_current_century(char *, char *, int *);
int strlen(char *);
char *julian_make_y2k_year(char *two_digit_year_buffer) {
  static char year_buffer[5];
  char *ptr = year_buffer;
  char current_century[3];
  char prior_century[3];
  int current_two_digit_year;
  if (strlen(two_digit_year_buffer) == 4) {
    return two_digit_year_buffer;
  }
  if (strlen(two_digit_year_buffer) != 2)
    return "";
  julian_get_current_century(current_century, prior_century,
                             &current_two_digit_year);
  if (atoi(two_digit_year_buffer) > current_two_digit_year) {
    *ptr++ = *prior_century;
    *ptr++ = *(prior_century + 1);
  } else {
    *ptr++ = *current_century;
    *ptr++ = *(current_century + 1);
  }
  *ptr++ = *two_digit_year_buffer++;
  *ptr++ = *two_digit_year_buffer++;
  *ptr = '\0';
  return year_buffer;
}


x86 assembly (clang, -O0):
<julian_make_y2k_year>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0x2ef6(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jne    1166 <julian_make_y2k_year+0x36>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1256 <julian_make_y2k_year+0x126>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
je     1188 <julian_make_y2k_year+0x58>
lea    0xe81(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1256 <julian_make_y2k_year+0x126>
lea    -0x1b(%rbp),%rdi
lea    -0x1e(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <julian_get_current_century@plt>
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
cmp    -0x24(%rbp),%eax
jle    11d8 <julian_make_y2k_year+0xa8>
mov    -0x1e(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x1d(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1200 <julian_make_y2k_year+0xd0>
mov    -0x1b(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x1a(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2de7(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<julian_make_y2k_year>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x4,%eax
je     11b8 <julian_make_y2k_year+0x88>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jne    11b1 <julian_make_y2k_year+0x81>
lea    0xd(%rsp),%r14
lea    0xa(%rsp),%r15
lea    0x4(%rsp),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <julian_get_current_century@plt>
mov    %rbx,%rdi
call   1040 <atoi@plt>
cmp    0x4(%rsp),%eax
cmovg  %r15,%r14
mov    (%r14),%al
mov    %al,0x2eb3(%rip)
mov    0x1(%r14),%al
mov    %al,0x2eaa(%rip)
mov    (%rbx),%al
mov    %al,0x2ea3(%rip)
mov    0x1(%rbx),%al
lea    0x2e97(%rip),%rbx
mov    %al,0x2e94(%rip)
movb   $0x0,0x2e8e(%rip)
jmp    11b8 <julian_make_y2k_year+0x88>
lea    0xe48(%rip),%rbx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@julian_make_y2k_year.year_buffer = internal global [5 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @julian_make_y2k_year(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [3 x i8]
%6 = alloca [3 x i8]
%7 = alloca i32
store i8* %0, i8** %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @julian_make_y2k_year.year_buffer, i64 0, i64 0), i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp eq i32 %9, 4
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i8*, i8** %3
store i8* %12, i8** %2
br label %58
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %58
18: ; preds = %13
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%21 = call i32 @julian_get_current_century(i8* %19, i8* %20, i32* %7)
%22 = load i8*, i8** %3
%23 = call i32 @atoi(i8* %22)
%24 = load i32, i32* %7
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %36
26: ; preds = %18
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%28 = load i8, i8* %27
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
store i8 %28, i8* %29
%31 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
store i8 %33, i8* %34
br label %46
36: ; preds = %18
%37 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%38 = load i8, i8* %37
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
store i8 %38, i8* %39
%41 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %4
store i8 %43, i8* %44
br label %46
46: ; preds = %36, %26
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %3
%49 = load i8, i8* %47
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %4
store i8 %49, i8* %50
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %3
%54 = load i8, i8* %52
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %4
store i8 %54, i8* %55
%57 = load i8*, i8** %4
store i8 0, i8* %57
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @julian_make_y2k_year.year_buffer, i64 0, i64 0), i8** %2
br label %58
58: ; preds = %46, %17, %11
%59 = load i8*, i8** %2
ret i8* %59
}

LLVM IR (-O2):
@julian_make_y2k_year.year_buffer = internal global [5 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @julian_make_y2k_year(i8* %0) {
%2 = alloca [3 x i8]
%3 = alloca [3 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp eq i32 %8, 4
br i1 %9, label %27, label %10
10: ; preds = %1
%11 = tail call i32 @strlen(i8* %0)
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = call i32 @julian_get_current_century(i8* %5, i8* %6, i32* %4)
%15 = call i32 @atoi(i8* %0)
%16 = load i32, i32* %4
%17 = icmp sgt i32 %15, %16
%18 = load i8, i8* %5
%19 = load i8, i8* %6
%20 = select i1 %17, i8 %19, i8 %18
%21 = select i1 %17, [3 x i8]* %3, [3 x i8]* %2
store i8 %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @julian_make_y2k_year.year_buffer, i64 0, i64 0)
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %21, i64 0, i64 1
%23 = load i8, i8* %22
store i8 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @julian_make_y2k_year.year_buffer, i64 0, i64 1)
%24 = getelementptr inbounds i8, i8* %0, i64 1
%25 = load i8, i8* %0
store i8 %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @julian_make_y2k_year.year_buffer, i64 0, i64 2)
%26 = load i8, i8* %24
store i8 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @julian_make_y2k_year.year_buffer, i64 0, i64 3)
store i8 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @julian_make_y2k_year.year_buffer, i64 0, i64 4)
br label %27
27: ; preds = %10, %1, %13
%28 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @julian_make_y2k_year.year_buffer, i64 0, i64 0), %13 ], [ %0, %1 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %10 ]
ret i8* %28
}