#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[], double u[], double v[], int points) {
  char *commandsForGnuplot[] = {
      "set terminal png",
      "set output 'energy.png'",
      "set title \"Integral Values as a Function of Distance\"",
      "set logscale x 2",
      "set logscale y 10",
      "plot 'data.temp' u 1:2 title 'VEGAS' w l, 'data.temp' u 1:3 title "
      "'Handmade Integrator' w l, 'data.temp' u 1:4 title 'Dipole "
      "Approximation' 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 %lf %lf\n", x[q], y[q], u[q], v[q]);
  }
  for (i = 0; i < 6; i++) {
    fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]);
  }
}


x86 assembly (clang, -O0):
<pfun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xe8a(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe90(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xec8(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xece(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xed5(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xf5a(%rip),%rdi
lea    0xf5d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x68(%rbp)
lea    0xf4f(%rip),%rdi
lea    0xf46(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1246 <pfun+0x106>
mov    -0x68(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x78(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x78(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x78(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x78(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
lea    0xf01(%rip),%rsi
mov    $0x4,%al
call   1040 <fprintf@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11e6 <pfun+0xa6>
movl   $0x0,-0x74(%rbp)
cmpl   $0x6,-0x74(%rbp)
jge    1280 <pfun+0x140>
mov    -0x70(%rbp),%rdi
movslq -0x74(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdx
lea    0xed8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    124d <pfun+0x10d>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pfun>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r15d
mov    %rcx,0x10(%rsp)
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0xfbc(%rip),%rdi
lea    0xfbf(%rip),%r14
mov    %r14,%rsi
call   1050 <fopen@plt>
mov    %rax,%rbp
lea    0xfaf(%rip),%rdi
mov    %r14,%rsi
call   1040 <popen@plt>
mov    %rax,0x8(%rsp)
test   %r15d,%r15d
jle    11c8 <pfun+0x98>
mov    %r15d,%r14d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%r15,8),%xmm0
movsd  0x0(%r13,%r15,8),%xmm1
movsd  (%r12,%r15,8),%xmm2
mov    0x10(%rsp),%rax
movsd  (%rax,%r15,8),%xmm3
mov    %rbp,%rdi
lea    0xf7a(%rip),%rsi
mov    $0x4,%al
call   1030 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    1190 <pfun+0x60>
lea    0xf74(%rip),%rbx
lea    0xe2a(%rip),%rdx
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe22(%rip),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe26(%rip),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe48(%rip),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe45(%rip),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xe43(%rip),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"set terminal png\00"
@.str.1 = [24 x i8] c"set output 'energy.png'\00"
@.str.2 = [54 x i8] c"set title \22Integral Values as a Function of Distance\22\00"
@.str.3 = [17 x i8] c"set logscale x 2\00"
@.str.4 = [18 x i8] c"set logscale y 10\00"
@.str.5 = [144 x i8] c"plot 'data.temp' u 1:2 title 'VEGAS' w l, 'data.temp' u 1:3 title 'Handmade Integrator' w l, 'data.temp' u 1:4 title 'Dipole Approximation' w l\00"
@.str.6 = [10 x i8] c"data.temp\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [20 x i8] c"gnuplot -persistent\00"
@.str.9 = [17 x i8] c"%lf %lf %lf %lf\0A\00"
@.str.10 = [5 x i8] c"%s \0A\00"
define void @pfun(double* %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca [6 x i8*]
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
%16 = bitcast [6 x i8*]* %11 to i8*
%17 = bitcast i8* %16 to [6 x i8*]*
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 2
store i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 3
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), i8** %21
%22 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 4
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i32 0, i32 0), i8** %22
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 5
store i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.5, i32 0, i32 0), i8** %23
%24 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %24, i32** %12
%25 = call i32* @popen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %25, i32** %13
store i32 0, i32* %15
br label %26
26: ; preds = %53, %5
%27 = load i32, i32* %15
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %56
30: ; preds = %26
%31 = load i32*, i32** %12
%32 = load double*, double** %6
%33 = load i32, i32* %15
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = load double*, double** %7
%38 = load i32, i32* %15
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = load double*, double** %8
%43 = load i32, i32* %15
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = load double*, double** %9
%48 = load i32, i32* %15
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), double %36, double %41, double %46, double %51)
br label %53
53: ; preds = %30
%54 = load i32, i32* %15
%55 = add nsw i32 %54, 1
store i32 %55, i32* %15
br label %26
56: ; preds = %26
store i32 0, i32* %14
br label %57
57: ; preds = %67, %56
%58 = load i32, i32* %14
%59 = icmp slt i32 %58, 6
br i1 %59, label %60, label %70
60: ; preds = %57
%61 = load i32*, i32** %13
%62 = load i32, i32* %14
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [6 x i8*], [6 x i8*]* %11, i64 0, i64 %63
%65 = load i8*, i8** %64
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %60
%68 = load i32, i32* %14
%69 = add nsw i32 %68, 1
store i32 %69, i32* %14
br label %57
70: ; preds = %57
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"set terminal png\00"
@.str.1 = [24 x i8] c"set output 'energy.png'\00"
@.str.2 = [54 x i8] c"set title \22Integral Values as a Function of Distance\22\00"
@.str.3 = [17 x i8] c"set logscale x 2\00"
@.str.4 = [18 x i8] c"set logscale y 10\00"
@.str.5 = [144 x i8] c"plot 'data.temp' u 1:2 title 'VEGAS' w l, 'data.temp' u 1:3 title 'Handmade Integrator' w l, 'data.temp' u 1:4 title 'Dipole Approximation' w l\00"
@.str.6 = [10 x i8] c"data.temp\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [20 x i8] c"gnuplot -persistent\00"
@.str.9 = [17 x i8] c"%lf %lf %lf %lf\0A\00"
@.str.10 = [5 x i8] c"%s \0A\00"
define void @pfun(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, i32 %4) {
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%7 = tail call i32* @popen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%8 = icmp sgt i32 %4, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = zext i32 %4 to i64
br label %18
11: ; preds = %18, %5
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.5, i64 0, i64 0))
ret void
18: ; preds = %9, %18
%19 = phi i64 [ 0, %9 ], [ %29, %18 ]
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %1, i64 %19
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %2, i64 %19
%25 = load double, double* %24
%26 = getelementptr inbounds double, double* %3, i64 %19
%27 = load double, double* %26
%28 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), double %21, double %23, double %25, double %27)
%29 = add nuw nsw i64 %19, 1
%30 = icmp eq i64 %29, %10
br i1 %30, label %11, label %18
}