#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 copy_command_lines(struct tracecmd_input *, int);
int copy_event_files(struct tracecmd_input *, int);
int copy_ftrace_files(struct tracecmd_input *, int);
int copy_ftrace_printk(struct tracecmd_input *, int);
int copy_header_files(struct tracecmd_input *, int);
int copy_proc_kallsyms(struct tracecmd_input *, int);
int tracecmd_copy_headers(struct tracecmd_input *handle, int fd) {
  int ret;
  ret = copy_header_files(handle, fd);
  if (ret < 0)
    return -1;
  ret = copy_ftrace_files(handle, fd);
  if (ret < 0)
    return -1;
  ret = copy_event_files(handle, fd);
  if (ret < 0)
    return -1;
  ret = copy_proc_kallsyms(handle, fd);
  if (ret < 0)
    return -1;
  ret = copy_ftrace_printk(handle, fd);
  if (ret < 0)
    return -1;
  ret = copy_command_lines(handle, fd);
  if (ret < 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<tracecmd_copy_headers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <copy_header_files@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1194 <tracecmd_copy_headers+0x34>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <tracecmd_copy_headers+0xf4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <copy_ftrace_files@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11b9 <tracecmd_copy_headers+0x59>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <tracecmd_copy_headers+0xf4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <copy_event_files@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11de <tracecmd_copy_headers+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <tracecmd_copy_headers+0xf4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <copy_proc_kallsyms@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1203 <tracecmd_copy_headers+0xa3>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <tracecmd_copy_headers+0xf4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <copy_ftrace_printk@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1228 <tracecmd_copy_headers+0xc8>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <tracecmd_copy_headers+0xf4>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <copy_command_lines@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    124d <tracecmd_copy_headers+0xed>
movl   $0xffffffff,-0x4(%rbp)
jmp    1254 <tracecmd_copy_headers+0xf4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tracecmd_copy_headers>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
call   1080 <copy_header_files@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
js     11c1 <tracecmd_copy_headers+0x61>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <copy_ftrace_files@plt>
test   %eax,%eax
js     11c1 <tracecmd_copy_headers+0x61>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <copy_event_files@plt>
test   %eax,%eax
js     11c1 <tracecmd_copy_headers+0x61>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <copy_proc_kallsyms@plt>
test   %eax,%eax
js     11c1 <tracecmd_copy_headers+0x61>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <copy_ftrace_printk@plt>
test   %eax,%eax
js     11c1 <tracecmd_copy_headers+0x61>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <copy_command_lines@plt>
mov    %eax,%r14d
sar    $0x1f,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tracecmd_input = type { i32 }
define i32 @tracecmd_copy_headers(%struct.tracecmd_input* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.tracecmd_input*
%5 = alloca i32
%6 = alloca i32
store %struct.tracecmd_input* %0, %struct.tracecmd_input** %4
store i32 %1, i32* %5
%7 = load %struct.tracecmd_input*, %struct.tracecmd_input** %4
%8 = load i32, i32* %5
%9 = call i32 @copy_header_files(%struct.tracecmd_input* %7, i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %49
13: ; preds = %2
%14 = load %struct.tracecmd_input*, %struct.tracecmd_input** %4
%15 = load i32, i32* %5
%16 = call i32 @copy_ftrace_files(%struct.tracecmd_input* %14, i32 %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 -1, i32* %3
br label %49
20: ; preds = %13
%21 = load %struct.tracecmd_input*, %struct.tracecmd_input** %4
%22 = load i32, i32* %5
%23 = call i32 @copy_event_files(%struct.tracecmd_input* %21, i32 %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 -1, i32* %3
br label %49
27: ; preds = %20
%28 = load %struct.tracecmd_input*, %struct.tracecmd_input** %4
%29 = load i32, i32* %5
%30 = call i32 @copy_proc_kallsyms(%struct.tracecmd_input* %28, i32 %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
store i32 -1, i32* %3
br label %49
34: ; preds = %27
%35 = load %struct.tracecmd_input*, %struct.tracecmd_input** %4
%36 = load i32, i32* %5
%37 = call i32 @copy_ftrace_printk(%struct.tracecmd_input* %35, i32 %36)
store i32 %37, i32* %6
%38 = load i32, i32* %6
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 -1, i32* %3
br label %49
41: ; preds = %34
%42 = load %struct.tracecmd_input*, %struct.tracecmd_input** %4
%43 = load i32, i32* %5
%44 = call i32 @copy_command_lines(%struct.tracecmd_input* %42, i32 %43)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %41
store i32 -1, i32* %3
br label %49
48: ; preds = %41
store i32 0, i32* %3
br label %49
49: ; preds = %48, %47, %40, %33, %26, %19, %12
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
%struct.tracecmd_input = type { i32 }
define i32 @tracecmd_copy_headers(%struct.tracecmd_input* %0, i32 %1) {
%3 = tail call i32 @copy_header_files(%struct.tracecmd_input* %0, i32 %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %2
%6 = tail call i32 @copy_ftrace_files(%struct.tracecmd_input* %0, i32 %1)
%7 = icmp slt i32 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %5
%9 = tail call i32 @copy_event_files(%struct.tracecmd_input* %0, i32 %1)
%10 = icmp slt i32 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %8
%12 = tail call i32 @copy_proc_kallsyms(%struct.tracecmd_input* %0, i32 %1)
%13 = icmp slt i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = tail call i32 @copy_ftrace_printk(%struct.tracecmd_input* %0, i32 %1)
%16 = icmp slt i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = tail call i32 @copy_command_lines(%struct.tracecmd_input* %0, i32 %1)
%19 = ashr i32 %18, 31
br label %20
20: ; preds = %17, %14, %11, %8, %5, %2
%21 = phi i32 [ -1, %2 ], [ -1, %5 ], [ -1, %8 ], [ -1, %11 ], [ -1, %14 ], [ %19, %17 ]
ret i32 %21
}