#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 */
char *concatenate_fname(char *, char const *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ write_header(int /*<<< orphan*/ *, char const *,
                                unsigned int, int);
FILE *generate_output_file(const char *rng_name, unsigned int seed, int count) {
  char *fname = concatenate_fname("./output/", rng_name, "_out.txt");
  FILE *f_out = fopen(fname, "w");
  write_header(f_out, rng_name, seed, count);
  free(fname);
  return f_out;
}


x86 assembly (clang, -O0):
<generate_output_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea3(%rip),%rdi
lea    0xea6(%rip),%rdx
call   1060 <concatenate_fname@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1050 <write_header@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_output_file>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
lea    0xea8(%rip),%rdi
lea    0xeab(%rip),%rdx
mov    %r12,%rsi
call   1060 <concatenate_fname@plt>
mov    %rax,%rbp
lea    0xea2(%rip),%rsi
mov    %rax,%rdi
call   1040 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1050 <write_header@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"./output/\00"
@.str.1 = [9 x i8] c"_out.txt\00"
@.str.2 = [2 x i8] c"w\00"
define i32* @generate_output_file(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i8* @concatenate_fname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %12, i32** %8
%13 = load i32*, i32** %8
%14 = load i8*, i8** %4
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 @write_header(i32* %13, i8* %14, i32 %15, i32 %16)
%18 = load i8*, i8** %7
%19 = call i32 @free(i8* %18)
%20 = load i32*, i32** %8
ret i32* %20
}

LLVM IR (-O2):
@.str = [10 x i8] c"./output/\00"
@.str.1 = [9 x i8] c"_out.txt\00"
@.str.2 = [2 x i8] c"w\00"
define i32* @generate_output_file(i8* %0, i32 %1, i32 %2) {
%4 = tail call i8* @concatenate_fname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @write_header(i32* %5, i8* %0, i32 %1, i32 %2)
%7 = tail call i32 @free(i8* %4)
ret i32* %5
}