#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 tracecmd_input {
  int dummy;
};

/* Variables and functions */
int read_event_files(struct tracecmd_input *, int /*<<< orphan*/);
int read_ftrace_files(struct tracecmd_input *, int /*<<< orphan*/);
int read_ftrace_printk(struct tracecmd_input *);
int read_header_files(struct tracecmd_input *);
int read_proc_kallsyms(struct tracecmd_input *);
int tracecmd_read_headers(struct tracecmd_input *handle) {
  int ret;
  ret = read_header_files(handle);
  if (ret < 0)
    return -1;
  ret = read_ftrace_files(handle, 0);
  if (ret < 0)
    return -1;
  ret = read_event_files(handle, 0);
  if (ret < 0)
    return -1;
  ret = read_proc_kallsyms(handle);
  if (ret < 0)
    return -1;
  ret = read_ftrace_printk(handle);
  if (ret < 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<tracecmd_read_headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <read_header_files@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    117e <tracecmd_read_headers+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <tracecmd_read_headers+0xc1>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1060 <read_ftrace_files@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11a2 <tracecmd_read_headers+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <tracecmd_read_headers+0xc1>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <read_event_files@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11c6 <tracecmd_read_headers+0x76>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <tracecmd_read_headers+0xc1>
mov    -0x10(%rbp),%rdi
call   1030 <read_proc_kallsyms@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11e8 <tracecmd_read_headers+0x98>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <tracecmd_read_headers+0xc1>
mov    -0x10(%rbp),%rdi
call   1070 <read_ftrace_printk@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    120a <tracecmd_read_headers+0xba>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <tracecmd_read_headers+0xc1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tracecmd_read_headers>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <read_header_files@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
js     1199 <tracecmd_read_headers+0x49>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <read_ftrace_files@plt>
test   %eax,%eax
js     1199 <tracecmd_read_headers+0x49>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <read_event_files@plt>
test   %eax,%eax
js     1199 <tracecmd_read_headers+0x49>
mov    %rbx,%rdi
call   1030 <read_proc_kallsyms@plt>
test   %eax,%eax
js     1199 <tracecmd_read_headers+0x49>
mov    %rbx,%rdi
call   1070 <read_ftrace_printk@plt>
mov    %eax,%ebp
sar    $0x1f,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tracecmd_input = type { i32 }
define i32 @tracecmd_read_headers(%struct.tracecmd_input* %0) {
%2 = alloca i32
%3 = alloca %struct.tracecmd_input*
%4 = alloca i32
store %struct.tracecmd_input* %0, %struct.tracecmd_input** %3
%5 = load %struct.tracecmd_input*, %struct.tracecmd_input** %3
%6 = call i32 @read_header_files(%struct.tracecmd_input* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -1, i32* %2
br label %35
10: ; preds = %1
%11 = load %struct.tracecmd_input*, %struct.tracecmd_input** %3
%12 = call i32 @read_ftrace_files(%struct.tracecmd_input* %11, i32 0)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 -1, i32* %2
br label %35
16: ; preds = %10
%17 = load %struct.tracecmd_input*, %struct.tracecmd_input** %3
%18 = call i32 @read_event_files(%struct.tracecmd_input* %17, i32 0)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 -1, i32* %2
br label %35
22: ; preds = %16
%23 = load %struct.tracecmd_input*, %struct.tracecmd_input** %3
%24 = call i32 @read_proc_kallsyms(%struct.tracecmd_input* %23)
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 -1, i32* %2
br label %35
28: ; preds = %22
%29 = load %struct.tracecmd_input*, %struct.tracecmd_input** %3
%30 = call i32 @read_ftrace_printk(%struct.tracecmd_input* %29)
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 -1, i32* %2
br label %35
34: ; preds = %28
store i32 0, i32* %2
br label %35
35: ; preds = %34, %33, %27, %21, %15, %9
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
%struct.tracecmd_input = type { i32 }
define i32 @tracecmd_read_headers(%struct.tracecmd_input* %0) {
%2 = tail call i32 @read_header_files(%struct.tracecmd_input* %0)
%3 = icmp slt i32 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = tail call i32 @read_ftrace_files(%struct.tracecmd_input* %0, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %4
%8 = tail call i32 @read_event_files(%struct.tracecmd_input* %0, i32 0)
%9 = icmp slt i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = tail call i32 @read_proc_kallsyms(%struct.tracecmd_input* %0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @read_ftrace_printk(%struct.tracecmd_input* %0)
%15 = ashr i32 %14, 31
br label %16
16: ; preds = %13, %10, %7, %4, %1
%17 = phi i32 [ -1, %1 ], [ -1, %4 ], [ -1, %7 ], [ -1, %10 ], [ %15, %13 ]
ret i32 %17
}