#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*/ die(char *);
int open_tracing_on();
int write(int, char *, int);
void write_tracing_on(int on) {
  int ret;
  int fd;
  fd = open_tracing_on();
  if (fd < 0)
    return;
  if (on)
    ret = write(fd, "1", 1);
  else
    ret = write(fd, "0", 1);
  if (ret < 0)
    die("writing 'tracing_on'");
}


x86 assembly (clang, -O0):
<write_tracing_on>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1050 <open_tracing_on@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1154 <write_tracing_on+0x24>
jmp    11a7 <write_tracing_on+0x77>
cmpl   $0x0,-0x4(%rbp)
je     117a <write_tracing_on+0x4a>
mov    -0xc(%rbp),%edi
lea    0xe98(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x8(%rbp)
jmp    1191 <write_tracing_on+0x61>
mov    -0xc(%rbp),%edi
lea    0xe7e(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11a7 <write_tracing_on+0x77>
lea    0xe62(%rip),%rdi
call   1040 <die@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_tracing_on>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <open_tracing_on@plt>
test   %eax,%eax
js     1162 <write_tracing_on+0x32>
test   %ebx,%ebx
lea    0xebb(%rip),%rcx
lea    0xeb2(%rip),%rsi
cmove  %rcx,%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1030 <write@plt>
test   %eax,%eax
js     1164 <write_tracing_on+0x34>
pop    %rbx
ret
lea    0xe99(%rip),%rdi
pop    %rbx
jmp    1040 <die@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [21 x i8] c"writing 'tracing_on'\00"
define void @write_tracing_on(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 (...) @open_tracing_on()
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
br label %23
9: ; preds = %1
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %4
%14 = call i32 @write(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 %14, i32* %3
br label %18
15: ; preds = %9
%16 = load i32, i32* %4
%17 = call i32 @write(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
store i32 %17, i32* %3
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %8, %21, %18
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [21 x i8] c"writing 'tracing_on'\00"
define void @write_tracing_on(i32 %0) {
%2 = tail call i32 (...) @open_tracing_on()
%3 = icmp slt i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = icmp eq i32 %0, 0
%6 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%7 = tail call i32 @write(i32 %2, i8* %6, i32 1)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %4, %9, %1
ret void
}