#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int get_full_year_with_sed(char *sed_command, int optional_current_year) {
  int full_year;
  FILE *p;
  char sys_str[1024];
  if (optional_current_year) {
    sprintf(sys_str,
            "echo %d			|"
            "sed 's/%s/'			 ",
            optional_current_year, sed_command);
  } else {
    sprintf(sys_str,
            "current_year.sh		|"
            "sed 's/%s/'			 ",
            sed_command);
  }
  p = popen(sys_str, "r");
  fscanf(p, "%d", &full_year);
  pclose(p);
  return full_year;
}


x86 assembly (clang, -O0):
<get_full_year_with_sed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     117d <get_full_year_with_sed+0x3d>
lea    -0x420(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rcx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
jmp    1196 <get_full_year_with_sed+0x56>
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x420(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe87(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <pclose@plt>
mov    -0x10(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_full_year_with_sed>:
push   %rbx
sub    $0x410,%rsp
mov    %rdi,%rcx
test   %esi,%esi
je     1166 <get_full_year_with_sed+0x26>
mov    %esi,%edx
lea    0xea8(%rip),%rsi
lea    0x10(%rsp),%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
jmp    117c <get_full_year_with_sed+0x3c>
lea    0xeae(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xeba(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1050 <popen@plt>
mov    %rax,%rbx
lea    0xea8(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <pclose@plt>
mov    0xc(%rsp),%eax
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"echo %d\09\09\09|sed 's/%s/'\09\09\09 \00"
@.str.1 = [34 x i8] c"current_year.sh\09\09|sed 's/%s/'\09\09\09 \00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @get_full_year_with_sed(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca [1024 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%12 = load i32, i32* %4
%13 = load i8*, i8** %3
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %13)
br label %19
15: ; preds = %2
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = load i8*, i8** %3
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %15, %10
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%21 = call i32* @popen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = call i32 @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%24 = load i32*, i32** %6
%25 = call i32 @pclose(i32* %24)
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
@.str = [27 x i8] c"echo %d\09\09\09|sed 's/%s/'\09\09\09 \00"
@.str.1 = [34 x i8] c"current_year.sh\09\09|sed 's/%s/'\09\09\09 \00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @get_full_year_with_sed(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %1, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %0)
br label %12
10: ; preds = %2
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %10, %8
%13 = call i32* @popen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%15 = call i32 @pclose(i32* %13)
%16 = load i32, i32* %3
ret i32 %16
}