#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 */
struct buffer_instance {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ die(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
char *get_instance_file(struct buffer_instance *, char *);
int /*<<< orphan*/ tracecmd_put_tracing_file(char *);
void __clear_trace(struct buffer_instance *instance) {
  FILE *fp;
  char *path;
  path = get_instance_file(instance, "trace");
  fp = fopen(path, "w");
  if (!fp)
    die("writing to '%s'", path);
  tracecmd_put_tracing_file(path);
  fwrite("0", 1, 1, fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<__clear_trace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1040 <get_instance_file@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11af <__clear_trace+0x4f>
mov    -0x18(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1070 <die@plt>
mov    -0x18(%rbp),%rdi
call   1030 <tracecmd_put_tracing_file@plt>
mov    -0x10(%rbp),%rcx
lea    0xe55(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1080 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__clear_trace>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rsi
call   1040 <get_instance_file@plt>
mov    %rax,%r14
lea    0xe8c(%rip),%rsi
mov    %rax,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1199 <__clear_trace+0x39>
lea    0xe77(%rip),%rdi
mov    %r14,%rsi
call   1080 <die@plt>
mov    %r14,%rdi
call   1030 <tracecmd_put_tracing_file@plt>
mov    $0x30,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fclose@plt>

LLVM IR (-O0):
%struct.buffer_instance = type { i32 }
@.str = [6 x i8] c"trace\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [16 x i8] c"writing to '%s'\00"
@.str.3 = [2 x i8] c"0\00"
define void @__clear_trace(%struct.buffer_instance* %0) {
%2 = alloca %struct.buffer_instance*
%3 = alloca i32*
%4 = alloca i8*
store %struct.buffer_instance* %0, %struct.buffer_instance** %2
%5 = load %struct.buffer_instance*, %struct.buffer_instance** %2
%6 = call i8* @get_instance_file(%struct.buffer_instance* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = icmp ne i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %1
%15 = load i8*, i8** %4
%16 = call i32 @tracecmd_put_tracing_file(i8* %15)
%17 = load i32*, i32** %3
%18 = call i32 @fwrite(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 1, i32* %17)
%19 = load i32*, i32** %3
%20 = call i32 @fclose(i32* %19)
ret void
}

LLVM IR (-O2):
%struct.buffer_instance = type { i32 }
@.str = [6 x i8] c"trace\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [16 x i8] c"writing to '%s'\00"
define void @__clear_trace(%struct.buffer_instance* %0) {
%2 = tail call i8* @get_instance_file(%struct.buffer_instance* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %7
7: ; preds = %5, %1
%8 = tail call i32 @tracecmd_put_tracing_file(i8* %2)
%9 = tail call i32 @fputc(i32 48, i32* %3)
%10 = tail call i32 @fclose(i32* %3)
ret void
}