#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*/ add_slashes_maybe(char *, char *);
int date_years_between(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ get_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ stderr;
int age(char *birth_date) {
  char today[64];
  char with_slashes[64];
  FILE *p;
  p = popen("date '+%m/%d/%y'", "r");
  if (!p) {
    fprintf(stderr, "ERROR: age() cannot open pipe to get today's date\n");
    exit(1);
  }
  get_line(today, p);
  pclose(p);
  add_slashes_maybe(with_slashes, birth_date);
  return date_years_between(with_slashes, today);
}


x86 assembly (clang, -O0):
<age>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    11c6 <age+0x56>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    -0x50(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1030 <get_line@plt>
mov    -0x98(%rbp),%rdi
call   1040 <pclose@plt>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <add_slashes_maybe@plt>
lea    -0x90(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <date_years_between@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<age>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%r14
lea    0xe7a(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1080 <popen@plt>
test   %rax,%rax
je     11d8 <age+0x68>
mov    %rax,%rbx
lea    0x40(%rsp),%r15
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <get_line@plt>
mov    %rbx,%rdi
call   1040 <pclose@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <add_slashes_maybe@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <date_years_between@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"date '+%m/%d/%y'\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [51 x i8] c"ERROR: age() cannot open pipe to get today's date\0A\00"
define i32 @age(i8* %0) {
%2 = alloca i8*
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = alloca i32*
store i8* %0, i8** %2
%6 = call i32* @popen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
%7 = load i32*, i32** %5
%8 = icmp ne i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %1
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%15 = load i32*, i32** %5
%16 = call i32 @get_line(i8* %14, i32* %15)
%17 = load i32*, i32** %5
%18 = call i32 @pclose(i32* %17)
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%20 = load i8*, i8** %2
%21 = call i32 @add_slashes_maybe(i8* %19, i8* %20)
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%24 = call i32 @date_years_between(i8* %22, i8* %23)
ret i32 %24
}

LLVM IR (-O2):
@.str = [17 x i8] c"date '+%m/%d/%y'\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [51 x i8] c"ERROR: age() cannot open pipe to get today's date\0A\00"
define i32 @age(i8* %0) {
%2 = alloca [64 x i8]
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @popen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = call i32 @get_line(i8* %4, i32* %6)
%14 = call i32 @pclose(i32* %6)
%15 = call i32 @add_slashes_maybe(i8* %5, i8* %0)
%16 = call i32 @date_years_between(i8* %5, i8* %4)
ret i32 %16
}