#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*/ *fopen(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int /*<<< orphan*/ system(char *);
void create_cpu_mem_rrd(void) {
  FILE *fp;
  char cmd[1024];
  if ((fp = fopen("/var/cpu_mem.rrd", "rb"))) {
    fclose(fp);
    return;
  }
  snprintf(
      cmd, 1024,
      "%s create %s  -s 3 DS:cpu:GAUGE:6:0:10000000 DS:mem:GAUGE:6:0:10000000 "
      "RRA:AVERAGE:0.5:1:144	RRA:AVERAGE:0.5:6:48		"
      "RRA:AVERAGE:0.5:24:12		RRA:AVERAGE:0.5:288:6",
      "/bin/rrdtool", "/var/cpu_mem.rrd");
  system(cmd);
}


x86 assembly (clang, -O0):
<create_cpu_mem_rrd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    0xeae(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     117a <create_cpu_mem_rrd+0x3a>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11ac <create_cpu_mem_rrd+0x6c>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
lea    0xe87(%rip),%rdx
lea    0xf20(%rip),%rcx
lea    0xe65(%rip),%r8
call   1050 <snprintf@plt>
lea    -0x410(%rbp),%rdi
call   1040 <system@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_cpu_mem_rrd>:
push   %rbx
sub    $0x400,%rsp
lea    0xeb1(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1170 <create_cpu_mem_rrd+0x30>
mov    %rax,%rdi
add    $0x400,%rsp
pop    %rbx
jmp    1030 <fclose@plt>
lea    0xe9d(%rip),%rdx
lea    0xf36(%rip),%rcx
lea    0xe7b(%rip),%r8
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"/var/cpu_mem.rrd\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [160 x i8] c"%s create %s -s 3 DS:cpu:GAUGE:6:0:10000000 DS:mem:GAUGE:6:0:10000000 RRA:AVERAGE:0.5:1:144\09RRA:AVERAGE:0.5:6:48\09\09RRA:AVERAGE:0.5:24:12\09\09RRA:AVERAGE:0.5:288:6\00"
@.str.3 = [13 x i8] c"/bin/rrdtool\00"
define void @create_cpu_mem_rrd() {
%1 = alloca i32*
%2 = alloca [1024 x i8]
%3 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = icmp ne i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32*, i32** %1
%7 = call i32 @fclose(i32* %6)
br label %13
8: ; preds = %0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%10 = call i32 @snprintf(i8* %9, i32 1024, i8* getelementptr inbounds ([160 x i8], [160 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%12 = call i32 @system(i8* %11)
br label %13
13: ; preds = %8, %5
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"/var/cpu_mem.rrd\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [160 x i8] c"%s create %s -s 3 DS:cpu:GAUGE:6:0:10000000 DS:mem:GAUGE:6:0:10000000 RRA:AVERAGE:0.5:1:144\09RRA:AVERAGE:0.5:6:48\09\09RRA:AVERAGE:0.5:24:12\09\09RRA:AVERAGE:0.5:288:6\00"
@.str.3 = [13 x i8] c"/bin/rrdtool\00"
define void @create_cpu_mem_rrd() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @fclose(i32* %3)
br label %10
7: ; preds = %0
%8 = call i32 @snprintf(i8* %2, i32 1024, i8* getelementptr inbounds ([160 x i8], [160 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @system(i8* %2)
br label %10
10: ; preds = %7, %5
ret void
}