#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 */

/* Variables and functions */
scalar_t__ file_exists(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int system(char *);
int plot_cleanup() {
  char commandstr[1024];
  int retval = 0, i;
  char str[1024];
  if (file_exists("gnuplot.plot") != 0) {
    sprintf(commandstr, "%s", "rm gnuplot.plot");
    retval = system(commandstr);
  }
  for (i = 1; i <= 3; i++) {
    sprintf(str, "gnuplot%d.csv", i);
    if (file_exists(str) != 0) {
      sprintf(commandstr, "rm %s", str);
      retval = system(commandstr);
    }
  }
  return retval;
}


x86 assembly (clang, -O0):
<plot_cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x404(%rbp)
lea    0xeb7(%rip),%rdi
call   1030 <file_exists@plt>
cmp    $0x0,%rax
je     1189 <plot_cleanup+0x59>
lea    -0x400(%rbp),%rdi
lea    0xeb8(%rip),%rsi
lea    0xe90(%rip),%rdx
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x400(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x404(%rbp)
movl   $0x1,-0x408(%rbp)
cmpl   $0x3,-0x408(%rbp)
jg     1218 <plot_cleanup+0xe8>
lea    -0x810(%rbp),%rdi
mov    -0x408(%rbp),%edx
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x810(%rbp),%rdi
call   1030 <file_exists@plt>
cmp    $0x0,%rax
je     11ff <plot_cleanup+0xcf>
lea    -0x400(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x400(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x404(%rbp)
jmp    1204 <plot_cleanup+0xd4>
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    1193 <plot_cleanup+0x63>
mov    -0x404(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plot_cleanup>:
push   %rbp
push   %rbx
sub    $0x808,%rsp
lea    0xec3(%rip),%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
je     116a <plot_cleanup+0x3a>
movups 0xeaf(%rip),%xmm0
movaps %xmm0,0x400(%rsp)
lea    0x400(%rsp),%rdi
call   1040 <system@plt>
mov    %eax,%ebp
jmp    116c <plot_cleanup+0x3c>
xor    %ebp,%ebp
lea    0xe9d(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
je     11b8 <plot_cleanup+0x88>
lea    0xe85(%rip),%rsi
lea    0x400(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %eax,%ebp
lea    0xe51(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
je     1204 <plot_cleanup+0xd4>
lea    0xe39(%rip),%rsi
lea    0x400(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %eax,%ebp
lea    0xe05(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
je     1250 <plot_cleanup+0x120>
lea    0xded(%rip),%rsi
lea    0x400(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x808,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"gnuplot.plot\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"rm gnuplot.plot\00"
@.str.3 = [14 x i8] c"gnuplot%d.csv\00"
@.str.4 = [6 x i8] c"rm %s\00"
define i32 @plot_cleanup() {
%1 = alloca [1024 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
store i32 0, i32* %2
%5 = call i64 @file_exists(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%11 = call i32 @system(i8* %10)
store i32 %11, i32* %2
br label %12
12: ; preds = %7, %0
store i32 1, i32* %3
br label %13
13: ; preds = %30, %12
%14 = load i32, i32* %3
%15 = icmp sle i32 %14, 3
br i1 %15, label %16, label %33
16: ; preds = %13
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%18 = load i32, i32* %3
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%21 = call i64 @file_exists(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %16
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%28 = call i32 @system(i8* %27)
store i32 %28, i32* %2
br label %29
29: ; preds = %23, %16
br label %30
30: ; preds = %29
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %13
33: ; preds = %13
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
@.str = [13 x i8] c"gnuplot.plot\00"
@.str.2 = [16 x i8] c"rm gnuplot.plot\00"
@.str.3 = [14 x i8] c"gnuplot%d.csv\00"
@.str.4 = [6 x i8] c"rm %s\00"
define i32 @plot_cleanup() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = tail call i64 @file_exists(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @system(i8* %3)
br label %9
9: ; preds = %7, %0
%10 = phi i32 [ %8, %7 ], [ 0, %0 ]
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 1)
%12 = call i64 @file_exists(i8* %4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%16 = call i32 @system(i8* %3)
br label %17
17: ; preds = %9, %14
%18 = phi i32 [ %16, %14 ], [ %10, %9 ]
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 2)
%20 = call i64 @file_exists(i8* %4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%24 = call i32 @system(i8* %3)
br label %25
25: ; preds = %22, %17
%26 = phi i32 [ %24, %22 ], [ %18, %17 ]
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 3)
%28 = call i64 @file_exists(i8* %4)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%32 = call i32 @system(i8* %3)
br label %33
33: ; preds = %30, %25
%34 = phi i32 [ %32, %30 ], [ %26, %25 ]
ret i32 %34
}