#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*/ time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *concat(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int);
int /*<<< orphan*/ free(char *);
char *getenv(char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
unsigned int create_storage() {
  char *home = getenv("HOME");
  char *exp_p = concat(home, "/.expense.trkr");
  char *inc_p = concat(home, "/.income.trkr");
  char *cat_p = concat(home, "/.category.trkr");
  FILE *exp_fp = fopen(exp_p, "w");
  FILE *inc_fp = fopen(inc_p, "w");
  FILE *cat_fp = fopen(cat_p, "w");
  if (exp_fp == NULL || inc_fp == NULL || cat_fp == NULL)
    return 0;
  time_t t = time(NULL);
  struct tm tm = *localtime(&t);
  fprintf(exp_fp, "--- %d-%d-%d ---\n", tm.tm_year + 1900, tm.tm_mon + 1,
          tm.tm_mday);
  fprintf(inc_fp, "--- %d-%d-%d ---\n", tm.tm_year + 1900, tm.tm_mon + 1,
          tm.tm_mday);
  fprintf(cat_fp, "--- %d-%d-%d ---\n", tm.tm_year + 1900, tm.tm_mon + 1,
          tm.tm_mday);
  fclose(exp_fp);
  fclose(inc_fp);
  fclose(cat_fp);
  free(exp_p);
  free(inc_p);
  free(cat_p);
  return 1;
}


x86 assembly (clang, -O0):
<create_storage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xe71(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1070 <concat@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <concat@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe57(%rip),%rsi
call   1070 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1231 <create_storage+0xb1>
cmpq   $0x0,-0x38(%rbp)
je     1231 <create_storage+0xb1>
cmpq   $0x0,-0x40(%rbp)
jne    123d <create_storage+0xbd>
movl   $0x0,-0x4(%rbp)
jmp    1305 <create_storage+0x185>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,-0x44(%rbp)
lea    -0x44(%rbp),%rdi
call   1050 <localtime@plt>
mov    (%rax),%rcx
mov    %rcx,-0x50(%rbp)
mov    0x8(%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x50(%rbp),%edx
add    $0x76c,%edx
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x48(%rbp),%r8d
lea    0xdb7(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x50(%rbp),%edx
add    $0x76c,%edx
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x48(%rbp),%r8d
lea    0xd94(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%edx
add    $0x76c,%edx
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x48(%rbp),%r8d
lea    0xd71(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_storage>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe6b(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xe61(%rip),%rsi
mov    %rax,%rdi
call   1070 <concat@plt>
mov    %rax,%r14
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <concat@plt>
mov    %rax,%r15
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <concat@plt>
mov    %rax,%r12
lea    0xe58(%rip),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   10a0 <fopen@plt>
mov    %rax,%r13
mov    %r15,%rdi
mov    %rbp,%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rbp,%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
xor    %eax,%eax
test   %r13,%r13
je     12dd <create_storage+0x15d>
test   %rbx,%rbx
je     12dd <create_storage+0x15d>
test   %rbp,%rbp
je     12dd <create_storage+0x15d>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <localtime@plt>
mov    %r14,0x10(%rsp)
mov    0x4(%rax),%r14d
mov    %r15,0x18(%rsp)
mov    0x8(%rax),%r15d
mov    %r12,0x20(%rsp)
mov    $0x76c,%r12d
add    (%rax),%r12d
add    $0x1,%r14d
lea    0xdd3(%rip),%rsi
mov    %r13,%rdi
mov    %r12d,%edx
mov    %r14d,%ecx
mov    %r15d,%r8d
call   1080 <fprintf@plt>
mov    %rbx,%rdi
lea    0xdb8(%rip),%rsi
mov    %r12d,%edx
mov    %r14d,%ecx
mov    %r15d,%r8d
call   1080 <fprintf@plt>
mov    %rbp,%rdi
lea    0xda0(%rip),%rsi
mov    %r12d,%edx
mov    %r14d,%ecx
mov    %r15d,%r8d
call   1080 <fprintf@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1040 <free@plt>
mov    0x18(%rsp),%rdi
call   1040 <free@plt>
mov    0x20(%rsp),%rdi
call   1040 <free@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [5 x i8] c"HOME\00"
@.str.1 = [15 x i8] c"/.expense.trkr\00"
@.str.2 = [14 x i8] c"/.income.trkr\00"
@.str.3 = [16 x i8] c"/.category.trkr\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [18 x i8] c"--- %d-%d-%d ---\0A\00"
define i32 @create_storage() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca %struct.tm
%11 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = call i8* @concat(i8* %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %3
%14 = load i8*, i8** %2
%15 = call i8* @concat(i8* %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i8* %15, i8** %4
%16 = load i8*, i8** %2
%17 = call i8* @concat(i8* %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i8* %17, i8** %5
%18 = load i8*, i8** %3
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %19, i32** %6
%20 = load i8*, i8** %4
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %21, i32** %7
%22 = load i8*, i8** %5
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %23, i32** %8
%24 = load i32*, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %32, label %26
26: ; preds = %0
%27 = load i32*, i32** %7
%28 = icmp eq i32* %27, null
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32*, i32** %8
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %33
32: ; preds = %29, %26, %0
store i32 0, i32* %1
br label %80
33: ; preds = %29
%34 = call i32 @time(i32* null)
store i32 %34, i32* %9
%35 = call %struct.tm* @localtime(i32* %9)
%36 = bitcast %struct.tm* %10 to i8*
%37 = bitcast %struct.tm* %35 to i8*
%38 = load i32*, i32** %6
%39 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1900
%42 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
%43 = load i32, i32* %42
%44 = add nsw i32 %43, 1
%45 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 2
%46 = load i32, i32* %45
%47 = call i32 @fprintf(i32* %38, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %41, i32 %44, i32 %46)
%48 = load i32*, i32** %7
%49 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1900
%52 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
%53 = load i32, i32* %52
%54 = add nsw i32 %53, 1
%55 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 2
%56 = load i32, i32* %55
%57 = call i32 @fprintf(i32* %48, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %51, i32 %54, i32 %56)
%58 = load i32*, i32** %8
%59 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%60 = load i32, i32* %59
%61 = add nsw i32 %60, 1900
%62 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
%63 = load i32, i32* %62
%64 = add nsw i32 %63, 1
%65 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 2
%66 = load i32, i32* %65
%67 = call i32 @fprintf(i32* %58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %61, i32 %64, i32 %66)
%68 = load i32*, i32** %6
%69 = call i32 @fclose(i32* %68)
%70 = load i32*, i32** %7
%71 = call i32 @fclose(i32* %70)
%72 = load i32*, i32** %8
%73 = call i32 @fclose(i32* %72)
%74 = load i8*, i8** %3
%75 = call i32 @free(i8* %74)
%76 = load i8*, i8** %4
%77 = call i32 @free(i8* %76)
%78 = load i8*, i8** %5
%79 = call i32 @free(i8* %78)
store i32 1, i32* %1
br label %80
80: ; preds = %33, %32
%81 = load i32, i32* %1
ret i32 %81
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [5 x i8] c"HOME\00"
@.str.1 = [15 x i8] c"/.expense.trkr\00"
@.str.2 = [14 x i8] c"/.income.trkr\00"
@.str.3 = [16 x i8] c"/.category.trkr\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [18 x i8] c"--- %d-%d-%d ---\0A\00"
define i32 @create_storage() {
%1 = alloca i32
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @concat(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @concat(i8* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i8* @concat(i8* %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i32* %6, null
%10 = icmp eq i32* %7, null
%11 = or i1 %9, %10
%12 = icmp eq i32* %8, null
%13 = or i1 %11, %12
br i1 %13, label %35, label %14
14: ; preds = %0
%15 = bitcast i32* %1 to i8*
%16 = tail call i32 @time(i32* null)
store i32 %16, i32* %1
%17 = call %struct.tm* @localtime(i32* %1)
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.tm, %struct.tm* %17, i64 0, i32 2
%23 = load i32, i32* %22
%24 = add nsw i32 %19, 1900
%25 = add nsw i32 %21, 1
%26 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 %25, i32 %23)
%27 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 %25, i32 %23)
%28 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 %25, i32 %23)
%29 = call i32 @fclose(i32* %6)
%30 = call i32 @fclose(i32* %7)
%31 = call i32 @fclose(i32* %8)
%32 = call i32 @free(i8* %3)
%33 = call i32 @free(i8* %4)
%34 = call i32 @free(i8* %5)
br label %35
35: ; preds = %0, %14
%36 = phi i32 [ 1, %14 ], [ 0, %0 ]
ret i32 %36
}