#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int *);
void test1() {
  FILE *fp = NULL;
  fp = fopen("/tmp/cpu_memory_measurement.txt", "a+");
  fprintf(fp, "%s : %d : %f\n", "apple", 1, 2.1);
  fprintf(fp, "%s : %d : %f\n", "banana", 2, 2.7);
  fprintf(fp, "%s\n", "fox 1");
  fprintf(fp, "%%CPU: %f\n", 1.2);
  fputc('\n', fp);
  fputs("\n", fp);
  fclose(fp);
  int *pi = NULL;
  free(pi);
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
lea    0xea1(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
lea    0xeb0(%rip),%rdx
mov    $0x1,%ecx
movsd  0xe6a(%rip),%xmm0
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe83(%rip),%rsi
lea    0xe90(%rip),%rdx
mov    $0x2,%ecx
movsd  0xe3c(%rip),%xmm0
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe78(%rip),%rsi
lea    0xe75(%rip),%rdx
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
movsd  0xe01(%rip),%xmm0
mov    $0x1,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1060 <fputc@plt>
mov    -0x8(%rbp),%rsi
lea    0xe28(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %r14
push   %rbx
push   %rax
lea    0xebd(%rip),%rdi
lea    0xed6(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xeca(%rip),%r14
lea    0xed1(%rip),%rdx
movsd  0xe80(%rip),%xmm0
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x1,%ecx
mov    $0x1,%al
call   1060 <fprintf@plt>
lea    0xeb6(%rip),%rdx
movsd  0xe67(%rip),%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%ecx
mov    $0x1,%al
call   1060 <fprintf@plt>
lea    0xe9c(%rip),%rsi
lea    0xe99(%rip),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe8e(%rip),%rsi
movsd  0xe36(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"/tmp/cpu_memory_measurement.txt\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [14 x i8] c"%s : %d : %f\0A\00"
@.str.3 = [6 x i8] c"apple\00"
@.str.4 = [7 x i8] c"banana\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [6 x i8] c"fox 1\00"
@.str.7 = [11 x i8] c"%%CPU: %f\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @test1() {
%1 = alloca i32*
%2 = alloca i32*
store i32* null, i32** %1
%3 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 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 = load i32*, i32** %1
%5 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 1, double 2.100000e+00)
%6 = load i32*, i32** %1
%7 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 2, double 2.700000e+00)
%8 = load i32*, i32** %1
%9 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%10 = load i32*, i32** %1
%11 = call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), double 1.200000e+00)
%12 = load i32*, i32** %1
%13 = call i32 @fputc(i8 signext 10, i32* %12)
%14 = load i32*, i32** %1
%15 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %14)
%16 = load i32*, i32** %1
%17 = call i32 @fclose(i32* %16)
store i32* null, i32** %2
%18 = load i32*, i32** %2
%19 = call i32 @free(i32* %18)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"/tmp/cpu_memory_measurement.txt\00"
@.str.1 = [3 x i8] c"a+\00"
@.str.2 = [14 x i8] c"%s : %d : %f\0A\00"
@.str.3 = [6 x i8] c"apple\00"
@.str.4 = [7 x i8] c"banana\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [6 x i8] c"fox 1\00"
@.str.7 = [11 x i8] c"%%CPU: %f\0A\00"
define void @test1() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 1, double 2.100000e+00)
%3 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 2, double 2.700000e+00)
%4 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), double 1.200000e+00)
%6 = tail call i32 @fputc(i8 signext 10, i32* %1)
%7 = tail call i32 bitcast (i32 (i8, i32*)* @fputc to i32 (i32, i32*)*)(i32 10, i32* %1)
%8 = tail call i32 @fclose(i32* %1)
%9 = tail call i32 @free(i32* null)
ret void
}