#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 *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *popen(char *, char *);
void pfun(double x[], double y[], int points) {
  char *commandsForGnuplot[] = {
      "set title \"Specific Heat versus Temperature\"", "plot 'data.temp' w l"};
  FILE *temp = fopen("data.temp", "w");
  FILE *gnuplotPipe = popen("gnuplot -persistent", "w");
  int i;
  int q;
  for (q = 0; q < points; q++) {
    fprintf(temp, "%lf %lf \n", x[q], y[q]);
  }
  for (i = 0; i < 2; i++) {
    fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]);
  }
}


x86 assembly (clang, -O0):
<pfun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2cc6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc3(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xee2(%rip),%rdi
lea    0xee5(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
lea    0xed7(%rip),%rdi
lea    0xece(%rip),%rsi
call   1040 <popen@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d4 <pfun+0xa4>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xea3(%rip),%rsi
mov    $0x2,%al
call   1030 <fprintf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    118e <pfun+0x5e>
movl   $0x0,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jge    120e <pfun+0xde>
mov    -0x40(%rbp),%rdi
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11db <pfun+0xab>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pfun>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xef8(%rip),%rdi
lea    0xefb(%rip),%r15
mov    %r15,%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xeeb(%rip),%rdi
mov    %r15,%rsi
call   1040 <popen@plt>
mov    %rax,(%rsp)
test   %ebp,%ebp
jle    11a2 <pfun+0x72>
mov    %ebp,%ebp
xor    %r15d,%r15d
lea    0xee3(%rip),%r13
nop
movsd  (%r12,%r15,8),%xmm0
movsd  (%r14,%r15,8),%xmm1
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x2,%al
call   1030 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1180 <pfun+0x50>
lea    0xec3(%rip),%rbx
lea    0xe50(%rip),%rdx
mov    (%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe65(%rip),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [45 x i8] c"set title \22Specific Heat versus Temperature\22\00"
@.str.1 = [21 x i8] c"plot 'data.temp' w l\00"
@__const.pfun.commandsForGnuplot = [2 x i8*] [i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i32 0, i32 0)]
@.str.2 = [10 x i8] c"data.temp\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [20 x i8] c"gnuplot -persistent\00"
@.str.5 = [10 x i8] c"%lf %lf \0A\00"
@.str.6 = [5 x i8] c"%s \0A\00"
define void @pfun(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca [2 x i8*]
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%12 = bitcast [2 x i8*]* %7 to i8*
%13 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %13, i32** %8
%14 = call i32* @popen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %14, i32** %9
store i32 0, i32* %11
br label %15
15: ; preds = %32, %3
%16 = load i32, i32* %11
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %35
19: ; preds = %15
%20 = load i32*, i32** %8
%21 = load double*, double** %4
%22 = load i32, i32* %11
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = load double*, double** %5
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), double %25, double %30)
br label %32
32: ; preds = %19
%33 = load i32, i32* %11
%34 = add nsw i32 %33, 1
store i32 %34, i32* %11
br label %15
35: ; preds = %15
store i32 0, i32* %10
br label %36
36: ; preds = %46, %35
%37 = load i32, i32* %10
%38 = icmp slt i32 %37, 2
br i1 %38, label %39, label %49
39: ; preds = %36
%40 = load i32*, i32** %9
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %39
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %36
49: ; preds = %36
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"set title \22Specific Heat versus Temperature\22\00"
@.str.1 = [21 x i8] c"plot 'data.temp' w l\00"
@.str.2 = [10 x i8] c"data.temp\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [20 x i8] c"gnuplot -persistent\00"
@.str.5 = [10 x i8] c"%lf %lf \0A\00"
@.str.6 = [5 x i8] c"%s \0A\00"
define void @pfun(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32* @popen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %12
9: ; preds = %12, %3
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
ret void
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %19, %12 ]
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %1, i64 %13
%17 = load double, double* %16
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), double %15, double %17)
%19 = add nuw nsw i64 %13, 1
%20 = icmp eq i64 %19, %8
br i1 %20, label %9, label %12
}