#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*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
void grafico_linhas_x_y(char *data, char *xtitle, char *ytitle, char *title,
                        char *legend, char *filename) {
  FILE *gnuplotPipe = popen("gnuplot -persistent", "w");
  if (!gnuplotPipe) {
    printf("ERROR in gnuplotPipe!\n");
    return;
  }
  char filename_data[255];
  sprintf(filename_data, "%s.data", filename);
  FILE *f_data = fopen(filename_data, "w");
  fputs(data, f_data);
  fflush(f_data);
  fclose(f_data);
  fputs(" set bmargin 7 \n", gnuplotPipe);
  fputs(" unset colorbox \n", gnuplotPipe);
  fputs(" set terminal png enhanced font 'Verdana,10' \n", gnuplotPipe);
  fputs(" set output '", gnuplotPipe);
  fputs(filename, gnuplotPipe);
  fputs(".png' \n", gnuplotPipe);
  fputs(" set style line 2  lc rgb '#0404E9' lt 1 pt 7 \n", gnuplotPipe);
  char paramaxis[1024];
  sprintf(paramaxis, " set xlabel '%s' \n set ylabel '%s' \n", xtitle, ytitle);
  fputs(paramaxis, gnuplotPipe);
  char paramtitle[1024];
  sprintf(paramtitle, " set title '%s'\n ", title);
  fputs(paramtitle, gnuplotPipe);
  char paramlegend[1024];
  sprintf(paramlegend, " plot '-' title '%s' ls 2 with lines\n", legend);
  fputs(paramlegend, gnuplotPipe);
  fputs(data, gnuplotPipe);
  fputs("e", gnuplotPipe);
  fputs("\nquit", gnuplotPipe);
  fflush(gnuplotPipe);
  fclose(gnuplotPipe);
}


x86 assembly (clang, -O0):
<grafico_linhas_x_y>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    0xe66(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11c6 <grafico_linhas_x_y+0x56>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
jmp    134c <grafico_linhas_x_y+0x1dc>
lea    -0x140(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x140(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x148(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x148(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x148(%rbp),%rdi
call   1060 <fflush@plt>
mov    -0x148(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x38(%rbp),%rsi
lea    0xe09(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rsi
lea    0xe0a(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rsi
lea    0xe0c(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rsi
lea    0xe2b(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rsi
lea    0xe1c(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x550(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x550(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <fputs@plt>
lea    -0x950(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x950(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <fputs@plt>
lea    -0xd50(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe0e(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0xd50(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rsi
lea    0xdf7(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x38(%rbp),%rdi
call   1060 <fflush@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xd50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grafico_linhas_x_y>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd28,%rsp
mov    %r9,%r15
mov    %r8,%r12
mov    %rcx,%rbp
mov    %rdx,0x18(%rsp)
mov    %rsi,%r13
mov    %rdi,%r14
lea    0xe44(%rip),%rdi
lea    0xe51(%rip),%rsi
call   1080 <popen@plt>
test   %rax,%rax
je     1395 <grafico_linhas_x_y+0x205>
mov    %rax,%rbx
lea    0xe3b(%rip),%rsi
mov    %r12,0x10(%rsp)
mov    %rbp,0x8(%rsp)
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    0xe16(%rip),%rsi
mov    %r12,%rdi
call   1090 <fopen@plt>
mov    %rax,%rbp
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <fputs@plt>
mov    %rbp,%rdi
call   1070 <fflush@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xdf3(%rip),%rdi
mov    $0x10,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xdeb(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xde4(%rip),%rdi
mov    $0x2e,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xdfa(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
lea    0xde4(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xdd3(%rip),%rdi
mov    $0x2f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
lea    0xdea(%rip),%rsi
lea    0x920(%rsp),%rbp
mov    %rbp,%rdi
mov    %r13,%rdx
mov    0x18(%rsp),%rcx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
lea    0xde3(%rip),%rsi
lea    0x520(%rsp),%rbp
mov    %rbp,%rdi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
lea    0xdcc(%rip),%rsi
lea    0x120(%rsp),%rbp
mov    %rbp,%rdi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fputs@plt>
mov    $0x65,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
lea    0xdb1(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
call   1070 <fflush@plt>
mov    %rbx,%rdi
add    $0xd28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>
lea    0xd7d(%rip),%rdi
add    $0xd28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"gnuplot -persistent\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [23 x i8] c"ERROR in gnuplotPipe!\0A\00"
@.str.3 = [8 x i8] c"%s.data\00"
@.str.4 = [17 x i8] c" set bmargin 7 \0A\00"
@.str.5 = [18 x i8] c" unset colorbox \0A\00"
@.str.6 = [47 x i8] c" set terminal png enhanced font 'Verdana,10' \0A\00"
@.str.7 = [14 x i8] c" set output '\00"
@.str.8 = [8 x i8] c".png' \0A\00"
@.str.9 = [48 x i8] c" set style line 2 lc rgb 'E9' lt 1 pt 7 \0A\00"
@.str.10 = [37 x i8] c" set xlabel '%s' \0A set ylabel '%s' \0A\00"
@.str.11 = [18 x i8] c" set title '%s'\0A \00"
@.str.12 = [38 x i8] c" plot '-' title '%s' ls 2 with lines\0A\00"
@.str.13 = [2 x i8] c"e\00"
@.str.14 = [6 x i8] c"\0Aquit\00"
define void @grafico_linhas_x_y(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca [255 x i8]
%15 = alloca i32*
%16 = alloca [1024 x i8]
%17 = alloca [1024 x i8]
%18 = alloca [1024 x i8]
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%19 = call i32* @popen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %13
%20 = load i32*, i32** %13
%21 = icmp ne i32* %20, null
br i1 %21, label %24, label %22
22: ; preds = %6
%23 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %82
24: ; preds = %6
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %14, i64 0, i64 0
%26 = load i8*, i8** %12
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %14, 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** %15
%30 = load i8*, i8** %7
%31 = load i32*, i32** %15
%32 = call i32 @fputs(i8* %30, i32* %31)
%33 = load i32*, i32** %15
%34 = call i32 @fflush(i32* %33)
%35 = load i32*, i32** %15
%36 = call i32 @fclose(i32* %35)
%37 = load i32*, i32** %13
%38 = call i32 @fputs(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32* %37)
%39 = load i32*, i32** %13
%40 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32* %39)
%41 = load i32*, i32** %13
%42 = call i32 @fputs(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i32* %41)
%43 = load i32*, i32** %13
%44 = call i32 @fputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32* %43)
%45 = load i8*, i8** %12
%46 = load i32*, i32** %13
%47 = call i32 @fputs(i8* %45, i32* %46)
%48 = load i32*, i32** %13
%49 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32* %48)
%50 = load i32*, i32** %13
%51 = call i32 @fputs(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i32* %50)
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%53 = load i8*, i8** %8
%54 = load i8*, i8** %9
%55 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %53, i8* %54)
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%57 = load i32*, i32** %13
%58 = call i32 @fputs(i8* %56, i32* %57)
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%60 = load i8*, i8** %10
%61 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %59, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i8* %60)
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%63 = load i32*, i32** %13
%64 = call i32 @fputs(i8* %62, i32* %63)
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%66 = load i8*, i8** %11
%67 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %65, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0), i8* %66)
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %18, i64 0, i64 0
%69 = load i32*, i32** %13
%70 = call i32 @fputs(i8* %68, i32* %69)
%71 = load i8*, i8** %7
%72 = load i32*, i32** %13
%73 = call i32 @fputs(i8* %71, i32* %72)
%74 = load i32*, i32** %13
%75 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i32* %74)
%76 = load i32*, i32** %13
%77 = call i32 @fputs(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i32* %76)
%78 = load i32*, i32** %13
%79 = call i32 @fflush(i32* %78)
%80 = load i32*, i32** %13
%81 = call i32 @fclose(i32* %80)
br label %82
82: ; preds = %24, %22
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"gnuplot -persistent\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [8 x i8] c"%s.data\00"
@.str.4 = [17 x i8] c" set bmargin 7 \0A\00"
@.str.5 = [18 x i8] c" unset colorbox \0A\00"
@.str.6 = [47 x i8] c" set terminal png enhanced font 'Verdana,10' \0A\00"
@.str.7 = [14 x i8] c" set output '\00"
@.str.8 = [8 x i8] c".png' \0A\00"
@.str.9 = [48 x i8] c" set style line 2 lc rgb 'E9' lt 1 pt 7 \0A\00"
@.str.10 = [37 x i8] c" set xlabel '%s' \0A set ylabel '%s' \0A\00"
@.str.11 = [18 x i8] c" set title '%s'\0A \00"
@.str.12 = [38 x i8] c" plot '-' title '%s' ls 2 with lines\0A\00"
@.str.14 = [6 x i8] c"\0Aquit\00"
@str = [22 x i8] c"ERROR in gnuplotPipe!\00"
define void @grafico_linhas_x_y(i8* nocapture %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca [255 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = tail call i32* @popen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %43
15: ; preds = %6
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%17 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%18 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 @fputs(i8* %0, i32* %18)
%20 = tail call i32 @fflush(i32* %18)
%21 = tail call i32 @fclose(i32* %18)
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 16, i64 1, i32* %11)
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i64 17, i64 1, i32* %11)
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i64 46, i64 1, i32* %11)
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i64 13, i64 1, i32* %11)
%26 = tail call i32 @fputs(i8* %5, i32* %11)
%27 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i64 7, i64 1, i32* %11)
%28 = tail call i64 @fwrite(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0), i64 47, i64 1, i32* %11)
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%30 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %29, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i8* %1, i8* %2)
%31 = call i32 @fputs(i8* %29, i32* %11)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%33 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %32, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i8* %3)
%34 = call i32 @fputs(i8* %32, i32* %11)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%36 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %35, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0), i8* %4)
%37 = call i32 @fputs(i8* %35, i32* %11)
%38 = tail call i32 @fputs(i8* %0, i32* %11)
%39 = tail call i32 @fputc(i32 101, i32* %11)
%40 = tail call i64 @fwrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i64 5, i64 1, i32* %11)
%41 = tail call i32 @fflush(i32* %11)
%42 = tail call i32 @fclose(i32* %11)
br label %43
43: ; preds = %15, %13
ret void
}