#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 0;
  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    116e <read_tracing_on+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11ae <read_tracing_on+0x6e>
mov    -0x14(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0xa,%edx
call   1030 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     1198 <read_tracing_on+0x58>
lea    0xe6d(%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     1182 <read_tracing_on+0x42>
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
xor    %eax,%eax
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 %12
11: ; preds = %1
store i32 0, i32* %2
br label %25
12: ; preds = %1
%13 = load i32, i32* %4
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%15 = call i32 @read(i32 %13, i8* %14, i32 10)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp sle i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 @die(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %12
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 9
store i8 0, i8* %21
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
store i32 %24, i32* %2
br label %25
25: ; preds = %20, %11
%26 = load i32, i32* %2
ret i32 %26
}

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 ], [ 0, %1 ]
ret i32 %15
}