#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*/ *fopen(char *, char const *);
int /*<<< orphan*/ get_storage_path(char *);
int snprintf(char *, int, char *, char *, char const *);
FILE *get_persistent_storage(const char *tag, const char *mode) {
  char buf[1024];
  char path[1024];
  get_storage_path(buf);
  if (snprintf(path, 1024, "%s_%s", buf, tag) >= 1024)
    path[1024 - 1] = '\0';
  return fopen(path, mode);
}


x86 assembly (clang, -O0):
<get_persistent_storage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
call   1030 <get_storage_path@plt>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    $0x400,%esi
lea    0xe93(%rip),%rdx
call   1040 <snprintf@plt>
cmp    $0x400,%eax
jl     1184 <get_persistent_storage+0x54>
movb   $0x0,-0x411(%rbp)
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <fopen@plt>
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_persistent_storage>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x400(%rsp),%r15
mov    %r15,%rdi
call   1030 <get_storage_path@plt>
lea    0xea7(%rip),%rdx
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r15,%rcx
mov    %rbx,%r8
call   1040 <snprintf@plt>
cmp    $0x400,%eax
jl     117b <get_persistent_storage+0x4b>
movb   $0x0,0x3ff(%rsp)
mov    %rsp,%rdi
mov    %r14,%rsi
call   1050 <fopen@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s_%s\00"
define i32* @get_persistent_storage(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = call i32 @get_storage_path(i8* %7)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = call i32 @snprintf(i8* %9, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = icmp sge i32 %12, 1024
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 1023
store i8 0, i8* %15
br label %16
16: ; preds = %14, %2
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = load i8*, i8** %4
%19 = call i32* @fopen(i8* %17, i8* %18)
ret i32* %19
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s_%s\00"
define noalias i32* @get_persistent_storage(i8* %0, i8* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = call i32 @get_storage_path(i8* %5)
%8 = call i32 @snprintf(i8* %6, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %0)
%9 = icmp sgt i32 %8, 1023
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 1023
store i8 0, i8* %11
br label %12
12: ; preds = %10, %2
%13 = call i32* @fopen(i8* %6, i8* %1)
ret i32* %13
}