#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*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int plot() {
  char *plottingA[] = {"set terminal png", "set title \"th vs d\'\"",
                       "set output 'a_hist.png'",
                       "plot 'result_iter.dat' using 1:2"};
  char *plottingB[] = {"set terminal png", "set title \"th vs np\"",
                       "set output 'b_hist.png'",
                       "plot 'result_iter.dat' using 1:3"};
  char *plottingC[] = {"set terminal png", "set title \"d\' vs np\"",
                       "set output 'c_hist.png'",
                       "plot 'result_iter.dat' using 2:3"};
  int i;
  FILE *gnuplotPipe = popen("gnuplot -persistent", "w");
  for (i = 0; i < 4; i++)
    fprintf(gnuplotPipe, "%s \n", plottingA[i]);
  for (i = 0; i < 4; i++)
    fprintf(gnuplotPipe, "%s \n", plottingB[i]);
  for (i = 0; i < 4; i++)
    fprintf(gnuplotPipe, "%s \n", plottingC[i]);
  pclose(gnuplotPipe);
  return 0;
}


x86 assembly (clang, -O0):
<plot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x2c81(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c7e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c7b(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2c78(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0x2c75(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c72(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c6f(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c6c(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2c69(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c66(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x2c63(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x2c60(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xf38(%rip),%rdi
lea    0xf45(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x4,-0x64(%rbp)
jge    120b <plot+0xdb>
mov    -0x70(%rbp),%rdi
movslq -0x64(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdx
lea    0xf19(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11da <plot+0xaa>
movl   $0x0,-0x64(%rbp)
cmpl   $0x4,-0x64(%rbp)
jge    1243 <plot+0x113>
mov    -0x70(%rbp),%rdi
movslq -0x64(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdx
lea    0xee1(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1212 <plot+0xe2>
movl   $0x0,-0x64(%rbp)
cmpl   $0x4,-0x64(%rbp)
jge    127b <plot+0x14b>
mov    -0x70(%rbp),%rdi
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdx
lea    0xea9(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    124a <plot+0x11a>
mov    -0x70(%rbp),%rdi
call   1030 <pclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plot>:
push   %r15
push   %r14
push   %rbx
lea    0xfbf(%rip),%rdi
lea    0xfcc(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,%rbx
lea    0xfbf(%rip),%r14
lea    0xea7(%rip),%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
lea    0xea3(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
lea    0xea6(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
lea    0xeac(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
lea    0xead(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
lea    0xeb0(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
lea    0xeb6(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
lea    0xeb7(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
lea    0xeba(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
lea    0xec0(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <pclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"set terminal png\00"
@.str.1 = [21 x i8] c"set title \22th vs d'\22\00"
@.str.2 = [24 x i8] c"set output 'a_hist.png'\00"
@.str.3 = [33 x i8] c"plot 'result_iter.dat' using 1:2\00"
@__const.plot.plottingA = [4 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [21 x i8] c"set title \22th vs np\22\00"
@.str.5 = [24 x i8] c"set output 'b_hist.png'\00"
@.str.6 = [33 x i8] c"plot 'result_iter.dat' using 1:3\00"
@__const.plot.plottingB = [4 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [21 x i8] c"set title \22d' vs np\22\00"
@.str.8 = [24 x i8] c"set output 'c_hist.png'\00"
@.str.9 = [33 x i8] c"plot 'result_iter.dat' using 2:3\00"
@__const.plot.plottingC = [4 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i32 0, i32 0)]
@.str.10 = [20 x i8] c"gnuplot -persistent\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [5 x i8] c"%s \0A\00"
define i32 @plot() {
%1 = alloca [4 x i8*]
%2 = alloca [4 x i8*]
%3 = alloca [4 x i8*]
%4 = alloca i32
%5 = alloca i32*
%6 = bitcast [4 x i8*]* %1 to i8*
%7 = bitcast [4 x i8*]* %2 to i8*
%8 = bitcast [4 x i8*]* %3 to i8*
%9 = call i32* @popen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %9, i32** %5
store i32 0, i32* %4
br label %10
10: ; preds = %20, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32*, i32** %5
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %10
23: ; preds = %10
store i32 0, i32* %4
br label %24
24: ; preds = %34, %23
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 4
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i32*, i32** %5
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %24
37: ; preds = %24
store i32 0, i32* %4
br label %38
38: ; preds = %48, %37
%39 = load i32, i32* %4
%40 = icmp slt i32 %39, 4
br i1 %40, label %41, label %51
41: ; preds = %38
%42 = load i32*, i32** %5
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @fprintf(i32* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %41
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %38
51: ; preds = %38
%52 = load i32*, i32** %5
%53 = call i32 @pclose(i32* %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"set terminal png\00"
@.str.1 = [21 x i8] c"set title \22th vs d'\22\00"
@.str.2 = [24 x i8] c"set output 'a_hist.png'\00"
@.str.3 = [33 x i8] c"plot 'result_iter.dat' using 1:2\00"
@.str.4 = [21 x i8] c"set title \22th vs np\22\00"
@.str.5 = [24 x i8] c"set output 'b_hist.png'\00"
@.str.6 = [33 x i8] c"plot 'result_iter.dat' using 1:3\00"
@.str.7 = [21 x i8] c"set title \22d' vs np\22\00"
@.str.8 = [24 x i8] c"set output 'c_hist.png'\00"
@.str.9 = [33 x i8] c"plot 'result_iter.dat' using 2:3\00"
@.str.10 = [20 x i8] c"gnuplot -persistent\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [5 x i8] c"%s \0A\00"
define i32 @plot() {
%1 = tail call i32* @popen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%2 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%9 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%10 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%12 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%13 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%14 = tail call i32 @pclose(i32* %1)
ret i32 0
}