#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;
};

/* Variables and functions */
int /*<<< orphan*/ die(char *);
int open_tracing_on(struct buffer_instance *);
int write(int, char *, int);
void write_tracing_on(struct buffer_instance *instance, int on) {
  int ret;
  int fd;
  fd = open_tracing_on(instance);
  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    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <open_tracing_on@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    115a <write_tracing_on+0x2a>
jmp    11ad <write_tracing_on+0x7d>
cmpl   $0x0,-0xc(%rbp)
je     1180 <write_tracing_on+0x50>
mov    -0x14(%rbp),%edi
lea    0xe92(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x10(%rbp)
jmp    1197 <write_tracing_on+0x67>
mov    -0x14(%rbp),%edi
lea    0xe78(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11ad <write_tracing_on+0x7d>
lea    0xe5c(%rip),%rdi
call   1040 <die@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_tracing_on>:
push   %rbx
mov    %esi,%ebx
call   1050 <open_tracing_on@plt>
test   %eax,%eax
js     1160 <write_tracing_on+0x30>
test   %ebx,%ebx
lea    0xebd(%rip),%rcx
lea    0xeb4(%rip),%rsi
cmove  %rcx,%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1030 <write@plt>
test   %eax,%eax
js     1162 <write_tracing_on+0x32>
pop    %rbx
ret
lea    0xe9b(%rip),%rdi
pop    %rbx
jmp    1040 <die@plt>

LLVM IR (-O0):
%struct.buffer_instance = type { i32 }
@.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(%struct.buffer_instance* %0, i32 %1) {
%3 = alloca %struct.buffer_instance*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.buffer_instance* %0, %struct.buffer_instance** %3
store i32 %1, i32* %4
%7 = load %struct.buffer_instance*, %struct.buffer_instance** %3
%8 = call i32 @open_tracing_on(%struct.buffer_instance* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
br label %26
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %6
%17 = call i32 @write(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 %17, i32* %5
br label %21
18: ; preds = %12
%19 = load i32, i32* %6
%20 = call i32 @write(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
store i32 %20, i32* %5
br label %21
21: ; preds = %18, %15
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %11, %24, %21
ret void
}

LLVM IR (-O2):
%struct.buffer_instance = type { i32 }
@.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(%struct.buffer_instance* %0, i32 %1) {
%3 = tail call i32 @open_tracing_on(%struct.buffer_instance* %0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, 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)
%8 = tail call i32 @write(i32 %3, i8* %7, i32 1)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %5, %10, %2
ret void
}