#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ pmf_write(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
void stats_pmf_out(int pid) {
  char fname[32];
  FILE *f;
  sprintf(fname, "%d-exec.txt", pid);
  f = fopen(fname, "w");
  pmf_write(f, pid, 2);
  fclose(f);
  sprintf(fname, "%d-interarrival.txt", pid);
  f = fopen(fname, "w");
  pmf_write(f, pid, 0);
  fclose(f);
  sprintf(fname, "%d-response.txt", pid);
  f = fopen(fname, "w");
  pmf_write(f, pid, 1);
  fclose(f);
}


x86 assembly (clang, -O0):
<stats_pmf_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xea7(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    $0x2,%edx
call   1040 <pmf_write@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe74(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x4(%rbp),%esi
xor    %edx,%edx
call   1040 <pmf_write@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe4a(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1040 <pmf_write@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stats_pmf_out>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebp
lea    0xead(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebp,%edx
call   1060 <sprintf@plt>
lea    0xea5(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
call   1040 <pmf_write@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe7b(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1040 <pmf_write@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe5c(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <pmf_write@plt>
mov    %rbx,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%d-exec.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [20 x i8] c"%d-interarrival.txt\00"
@.str.3 = [16 x i8] c"%d-response.txt\00"
define void @stats_pmf_out(i32 %0) {
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = alloca i32*
store i32 %0, i32* %2
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* %2
%7 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = load i32, i32* %2
%12 = call i32 @pmf_write(i32* %10, i32 %11, i32 2)
%13 = load i32*, i32** %4
%14 = call i32 @fclose(i32* %13)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%16 = load i32, i32* %2
%17 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %4
%20 = load i32*, i32** %4
%21 = load i32, i32* %2
%22 = call i32 @pmf_write(i32* %20, i32 %21, i32 0)
%23 = load i32*, i32** %4
%24 = call i32 @fclose(i32* %23)
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%26 = load i32, i32* %2
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %4
%30 = load i32*, i32** %4
%31 = load i32, i32* %2
%32 = call i32 @pmf_write(i32* %30, i32 %31, i32 1)
%33 = load i32*, i32** %4
%34 = call i32 @fclose(i32* %33)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d-exec.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [20 x i8] c"%d-interarrival.txt\00"
@.str.3 = [16 x i8] c"%d-response.txt\00"
define void @stats_pmf_out(i32 %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @pmf_write(i32* %5, i32 %0, i32 2)
%7 = tail call i32 @fclose(i32* %5)
%8 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%9 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @pmf_write(i32* %9, i32 %0, i32 0)
%11 = tail call i32 @fclose(i32* %9)
%12 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%13 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @pmf_write(i32* %13, i32 %0, i32 1)
%15 = tail call i32 @fclose(i32* %13)
ret void
}