#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*/ die(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(char const *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char const *);
char *tracecmd_get_tracing_file(char *);
int /*<<< orphan*/ tracecmd_put_tracing_file(char *);
void set_option(const char *option) {
  FILE *fp;
  char *path;
  path = tracecmd_get_tracing_file("trace_options");
  fp = fopen(path, "w");
  if (!fp)
    die("writing to '%s'", path);
  tracecmd_put_tracing_file(path);
  fwrite(option, 1, strlen(option), fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<set_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe7d(%rip),%rdi
call   1060 <tracecmd_get_tracing_file@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11bb <set_option+0x4b>
mov    -0x18(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1080 <die@plt>
mov    -0x18(%rbp),%rdi
call   1030 <tracecmd_put_tracing_file@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1090 <fwrite@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_option>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xe81(%rip),%rdi
call   1060 <tracecmd_get_tracing_file@plt>
mov    %rax,%r15
lea    0xe80(%rip),%rsi
mov    %rax,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11ad <set_option+0x3d>
lea    0xe6b(%rip),%rdi
mov    %r15,%rsi
call   1080 <die@plt>
mov    %r15,%rdi
call   1030 <tracecmd_put_tracing_file@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1090 <fwrite@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>

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

LLVM IR (-O2):
@.str = [14 x i8] c"trace_options\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [16 x i8] c"writing to '%s'\00"
define void @set_option(i8* %0) {
%2 = tail call i8* @tracecmd_get_tracing_file(i8* getelementptr inbounds ([14 x i8], [14 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 @strlen(i8* %0)
%10 = tail call i32 @fwrite(i8* %0, i32 1, i32 %9, i32* %3)
%11 = tail call i32 @fclose(i32* %3)
ret void
}