#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 atoi(char *);
int /*<<< orphan*/ die(char *);
int open_tracing_on(struct buffer_instance *);
int read(int, char *, int);
int read_tracing_on(struct buffer_instance *instance) {
  int fd;
  char buf[10];
  int ret;
  fd = open_tracing_on(instance);
  if (fd < 0)
    return fd;
  ret = read(fd, buf, 10);
  if (ret <= 0)
    die("Reading 'tracing_on'");
  buf[9] = 0;
  ret = atoi(buf);
  return ret;
}


x86 assembly (clang, -O0):
<read_tracing_on>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <open_tracing_on@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    116d <read_tracing_on+0x2d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <read_tracing_on+0x6d>
mov    -0x14(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0xa,%edx
call   1030 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     1197 <read_tracing_on+0x57>
lea    0xe6e(%rip),%rdi
call   1040 <die@plt>
movb   $0x0,-0x15(%rbp)
lea    -0x1e(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_tracing_on>:
sub    $0x18,%rsp
call   1060 <open_tracing_on@plt>
test   %eax,%eax
js     117d <read_tracing_on+0x3d>
lea    0xe(%rsp),%rsi
mov    %eax,%edi
mov    $0xa,%edx
call   1030 <read@plt>
test   %eax,%eax
jg     116e <read_tracing_on+0x2e>
lea    0xe97(%rip),%rdi
call   1040 <die@plt>
movb   $0x0,0x17(%rsp)
lea    0xe(%rsp),%rdi
call   1050 <atoi@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
%struct.buffer_instance = type { i32 }
@.str = [21 x i8] c"Reading 'tracing_on'\00"
define i32 @read_tracing_on(%struct.buffer_instance* %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @open_tracing_on(%struct.buffer_instance* %0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = call i32 @read(i32 %4, i8* %3, i32 10)
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 9
store i8 0, i8* %12
%13 = call i32 @atoi(i8* %3)
br label %14
14: ; preds = %1, %11
%15 = phi i32 [ %13, %11 ], [ %4, %1 ]
ret i32 %15
}