#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 atoi(char *);
int /*<<< orphan*/ die(char *);
int open_tracing_on();
int read(int, char *, int);
int read_tracing_on(void) {
  int fd;
  char buf[10];
  int ret;
  fd = open_tracing_on();
  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    $0x20,%rsp
mov    $0x0,%al
call   1060 <open_tracing_on@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1168 <read_tracing_on+0x28>
movl   $0x0,-0x4(%rbp)
jmp    11a8 <read_tracing_on+0x68>
mov    -0x8(%rbp),%edi
lea    -0x12(%rbp),%rsi
mov    $0xa,%edx
call   1030 <read@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     1192 <read_tracing_on+0x52>
lea    0xe73(%rip),%rdi
call   1040 <die@plt>
movb   $0x0,-0x9(%rbp)
lea    -0x12(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_tracing_on>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <open_tracing_on@plt>
test   %eax,%eax
js     1184 <read_tracing_on+0x44>
lea    0x6(%rsp),%rsi
mov    %eax,%edi
mov    $0xa,%edx
call   1030 <read@plt>
test   %eax,%eax
jg     1173 <read_tracing_on+0x33>
lea    0xe92(%rip),%rdi
call   1040 <die@plt>
movb   $0x0,0xf(%rsp)
lea    0x6(%rsp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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