#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 */
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ die(char *, char *);
int open(char *, int /*<<< orphan*/);
char *tracecmd_get_tracing_file(char *);
int /*<<< orphan*/ tracecmd_put_tracing_file(char *);
int write(int, char *, int);
void reset_trace(void) {
  char *path;
  char buf[1];
  int fd;
  int n;
  path = tracecmd_get_tracing_file("stack_max_size");
  fd = open(path, O_WRONLY);
  if (fd < 0)
    die("writing %s", path);
  buf[0] = '0';
  n = write(fd, buf, 1);
  if (n < 0)
    die("writing into %s", path);
  tracecmd_put_tracing_file(path);
  close(fd);
}


x86 assembly (clang, -O0):
<reset_trace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1060 <tracecmd_get_tracing_file@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11a7 <reset_trace+0x47>
mov    -0x8(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1080 <die@plt>
movb   $0x30,-0x9(%rbp)
mov    -0x10(%rbp),%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11d9 <reset_trace+0x79>
mov    -0x8(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1080 <die@plt>
mov    -0x8(%rbp),%rdi
call   1030 <tracecmd_put_tracing_file@plt>
mov    -0x10(%rbp),%edi
call   1050 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_trace>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
call   1060 <tracecmd_get_tracing_file@plt>
mov    %rax,%rbx
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1198 <reset_trace+0x38>
lea    0xe7f(%rip),%rdi
mov    %rbx,%rsi
call   1080 <die@plt>
movb   $0x30,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1040 <write@plt>
test   %eax,%eax
jns    11c1 <reset_trace+0x61>
lea    0xe61(%rip),%rdi
mov    %rbx,%rsi
call   1080 <die@plt>
mov    %rbx,%rdi
call   1030 <tracecmd_put_tracing_file@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <close@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"stack_max_size\00"
@O_WRONLY = global i32 0
@.str.1 = [11 x i8] c"writing %s\00"
@.str.2 = [16 x i8] c"writing into %s\00"
define void @reset_trace() {
%1 = alloca i8*
%2 = alloca [1 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = call i8* @tracecmd_get_tracing_file(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = load i32, i32* @O_WRONLY
%8 = call i32 @open(i8* %6, i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i8*, i8** %1
%13 = call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %0
%15 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
store i8 48, i8* %15
%16 = load i32, i32* %3
%17 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
%18 = call i32 @write(i32 %16, i8* %17, i32 1)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i8*, i8** %1
%23 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %14
%25 = load i8*, i8** %1
%26 = call i32 @tracecmd_put_tracing_file(i8* %25)
%27 = load i32, i32* %3
%28 = call i32 @close(i32 %27)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"stack_max_size\00"
@O_WRONLY = global i32 0
@.str.1 = [11 x i8] c"writing %s\00"
@.str.2 = [16 x i8] c"writing into %s\00"
define void @reset_trace() {
%1 = alloca [1 x i8]
%2 = getelementptr inbounds [1 x i8], [1 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @tracecmd_get_tracing_file(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @O_WRONLY
%5 = tail call i32 @open(i8* %3, i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %9
9: ; preds = %7, %0
store i8 48, i8* %2
%10 = call i32 @write(i32 %5, i8* %2, i32 1)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %14
14: ; preds = %12, %9
%15 = tail call i32 @tracecmd_put_tracing_file(i8* %3)
%16 = tail call i32 @close(i32 %5)
ret void
}