#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*/ free(char *);
char *pipe2string(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void julian_get_current_century(char *current_century, char *prior_century,
                                int *current_two_digit_year) {
  char *current_year;
  current_year = pipe2string("/bin/date '+%Y'");
  *current_century = *current_year;
  *(current_century + 1) = *(current_year + 1);
  *(current_century + 2) = '\0';
  sprintf(prior_century, "%.2d", atoi(current_century) - 1);
  *current_two_digit_year = atoi(current_year + 2);
  free(current_year);
}


x86 assembly (clang, -O0):
<julian_get_current_century>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea5(%rip),%rdi
call   1040 <pipe2string@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
sub    $0x1,%edx
lea    0xe69(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x20(%rbp),%rdi
add    $0x2,%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<julian_get_current_century>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea8(%rip),%rdi
call   1040 <pipe2string@plt>
mov    %rax,%r12
mov    (%rax),%al
mov    %al,(%rbx)
mov    0x1(%r12),%al
mov    %al,0x1(%rbx)
movb   $0x0,0x2(%rbx)
mov    %rbx,%rdi
call   1050 <atoi@plt>
lea    -0x1(%rax),%edx
lea    0xe8e(%rip),%rsi
mov    %r15,%rdi
call   1060 <sprintf@plt>
lea    0x2(%r12),%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"/bin/date '+%Y'\00"
@.str.1 = [5 x i8] c"%.2d\00"
define void @julian_get_current_century(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = call i8* @pipe2string(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = load i8, i8* %9
%11 = load i8*, i8** %4
store i8 %10, i8* %11
%12 = load i8*, i8** %7
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %14, i8* %16
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 2
store i8 0, i8* %18
%19 = load i8*, i8** %5
%20 = load i8*, i8** %4
%21 = call i32 @atoi(i8* %20)
%22 = sub nsw i32 %21, 1
%23 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i64 2
%26 = call i32 @atoi(i8* %25)
%27 = load i32*, i32** %6
store i32 %26, i32* %27
%28 = load i8*, i8** %7
%29 = call i32 @free(i8* %28)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"/bin/date '+%Y'\00"
@.str.1 = [5 x i8] c"%.2d\00"
define void @julian_get_current_century(i8* nocapture %0, i8* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i8* @pipe2string(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = load i8, i8* %4
store i8 %5, i8* %0
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %7, i8* %8
%9 = getelementptr inbounds i8, i8* %0, i64 2
store i8 0, i8* %9
%10 = tail call i32 @atoi(i8* %0)
%11 = add nsw i32 %10, -1
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i8, i8* %4, i64 2
%14 = tail call i32 @atoi(i8* %13)
store i32 %14, i32* %2
%15 = tail call i32 @free(i8* %4)
ret void
}