#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 */
scalar_t__ calloc(int, int);
scalar_t__ get_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strdup(char *);
char **load_date_string_array(char *year) {
  FILE *p;
  char buffer[128];
  char **date_array_ptr;
  char **date_string_array = (char **)calloc(366, sizeof(char *));
  if (!date_string_array)
    return (char **)0;
  date_array_ptr = date_string_array;
  sprintf(buffer, "%s %s", "cal2linear", year);
  p = popen(buffer, "r");
  if (!p)
    return (char **)0;
  while (get_line(buffer, p))
    *date_array_ptr++ = strdup(buffer);
  pclose(p);
  return date_string_array;
}


x86 assembly (clang, -O0):
<load_date_string_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x16e,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
jne    11a0 <load_date_string_array+0x40>
movq   $0x0,-0x8(%rbp)
jmp    125a <load_date_string_array+0xfa>
mov    -0xb0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
lea    0xe40(%rip),%rsi
lea    0xe3f(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11fb <load_date_string_array+0x9b>
movq   $0x0,-0x8(%rbp)
jmp    125a <load_date_string_array+0xfa>
jmp    1200 <load_date_string_array+0xa0>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     1246 <load_date_string_array+0xe6>
lea    -0xa0(%rbp),%rdi
call   1080 <strdup@plt>
movslq %eax,%rcx
mov    -0xa8(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0xa8(%rbp)
mov    %rcx,(%rax)
jmp    1200 <load_date_string_array+0xa0>
mov    -0x18(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0xb0(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_date_string_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
mov    $0x16e,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     120b <load_date_string_array+0xab>
mov    %rax,%r14
lea    0xe6d(%rip),%rsi
lea    0xe6c(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rcx
call   1070 <sprintf@plt>
lea    0xe60(%rip),%rsi
mov    %r15,%rdi
call   1060 <popen@plt>
test   %rax,%rax
je     120b <load_date_string_array+0xab>
mov    %rax,%r15
mov    %rsp,%rdi
mov    %rax,%rsi
call   1030 <get_line@plt>
test   %rax,%rax
je     1201 <load_date_string_array+0xa1>
mov    %rsp,%r12
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1080 <strdup@plt>
cltq
mov    %rax,(%rbx)
add    $0x8,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <get_line@plt>
test   %rax,%rax
jne    11e0 <load_date_string_array+0x80>
mov    %r15,%rdi
call   1040 <pclose@plt>
jmp    120e <load_date_string_array+0xae>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [11 x i8] c"cal2linear\00"
@.str.2 = [2 x i8] c"r\00"
define i8** @load_date_string_array(i8* %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [128 x i8]
%6 = alloca i8**
%7 = alloca i8**
store i8* %0, i8** %3
%8 = call i64 @calloc(i32 366, i32 8)
%9 = inttoptr i64 %8 to i8**
store i8** %9, i8*** %7
%10 = load i8**, i8*** %7
%11 = icmp ne i8** %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
store i8** null, i8*** %2
br label %40
13: ; preds = %1
%14 = load i8**, i8*** %7
store i8** %14, i8*** %6
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%19 = call i32* @popen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %4
%20 = load i32*, i32** %4
%21 = icmp ne i32* %20, null
br i1 %21, label %23, label %22
22: ; preds = %13
store i8** null, i8*** %2
br label %40
23: ; preds = %13
br label %24
24: ; preds = %29, %23
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%26 = load i32*, i32** %4
%27 = call i64 @get_line(i8* %25, i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%31 = call i32 @strdup(i8* %30)
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i8*
%34 = load i8**, i8*** %6
%35 = getelementptr inbounds i8*, i8** %34, i32 1
store i8** %35, i8*** %6
store i8* %33, i8** %34
br label %24
36: ; preds = %24
%37 = load i32*, i32** %4
%38 = call i32 @pclose(i32* %37)
%39 = load i8**, i8*** %7
store i8** %39, i8*** %2
br label %40
40: ; preds = %36, %22, %12
%41 = load i8**, i8*** %2
ret i8** %41
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [11 x i8] c"cal2linear\00"
@.str.2 = [2 x i8] c"r\00"
define i8** @load_date_string_array(i8* %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @calloc(i32 366, i32 8)
%5 = inttoptr i64 %4 to i8**
%6 = icmp eq i64 %4, 0
br i1 %6, label %24, label %7
7: ; preds = %1
%8 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%9 = call i32* @popen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %24, label %11
11: ; preds = %7
%12 = call i64 @get_line(i8* %3, i32* %9)
%13 = icmp eq i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %11, %14
%15 = phi i8** [ %19, %14 ], [ %5, %11 ]
%16 = call i32 @strdup(i8* %3)
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
%19 = getelementptr inbounds i8*, i8** %15, i64 1
store i8* %18, i8** %15
%20 = call i64 @get_line(i8* %3, i32* %9)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %14
22: ; preds = %14, %11
%23 = call i32 @pclose(i32* %9)
br label %24
24: ; preds = %7, %1, %22
%25 = phi i8** [ %5, %22 ], [ null, %1 ], [ null, %7 ]
ret i8** %25
}