#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int check_args_validation(int, char **);
int /*<<< orphan*/ close_dump(int /*<<< orphan*/ *);
int get_dumpsize(int /*<<< orphan*/ *);
int /*<<< orphan*/ *open_dump(char *);
int read_tracebuffer(int /*<<< orphan*/ *, int);
int main(int argc, char **args) {
  FILE *file;
  int filesize, ret;
  if (-1 == check_args_validation(argc, args)) {
    return -1;
  }
  file = open_dump(args[1]);
  if (file == NULL) {
    return -1;
  }
  filesize = get_dumpsize(file);
  if (filesize <= 0) {
    return -1;
  }
  ret = read_tracebuffer(file, filesize);
  close_dump(file);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <check_args_validation@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    118d <main+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <open_dump@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b5 <main+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <main+0xa5>
mov    -0x18(%rbp),%rdi
call   1030 <get_dumpsize@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     11d7 <main+0x87>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <main+0xa5>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <read_tracebuffer@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <close_dump@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1060 <check_args_validation@plt>
cmp    $0xffffffff,%eax
je     1195 <main+0x45>
mov    0x8(%rbx),%rdi
call   1040 <open_dump@plt>
test   %rax,%rax
je     1195 <main+0x45>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <get_dumpsize@plt>
test   %eax,%eax
jle    1195 <main+0x45>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <read_tracebuffer@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <close_dump@plt>
mov    %ebp,%eax
jmp    119a <main+0x4a>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @check_args_validation(i32 %9, i8** %10)
%12 = icmp eq i32 -1, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %35
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @open_dump(i8* %17)
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %22
21: ; preds = %14
store i32 -1, i32* %3
br label %35
22: ; preds = %14
%23 = load i32*, i32** %6
%24 = call i32 @get_dumpsize(i32* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp sle i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 -1, i32* %3
br label %35
28: ; preds = %22
%29 = load i32*, i32** %6
%30 = load i32, i32* %7
%31 = call i32 @read_tracebuffer(i32* %29, i32 %30)
store i32 %31, i32* %8
%32 = load i32*, i32** %6
%33 = call i32 @close_dump(i32* %32)
%34 = load i32, i32* %8
store i32 %34, i32* %3
br label %35
35: ; preds = %28, %27, %21, %13
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @check_args_validation(i32 %0, i8** %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @open_dump(i8* %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = tail call i32 @get_dumpsize(i32* %8)
%12 = icmp slt i32 %11, 1
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @read_tracebuffer(i32* %8, i32 %11)
%15 = tail call i32 @close_dump(i32* %8)
br label %16
16: ; preds = %10, %5, %2, %13
%17 = phi i32 [ %14, %13 ], [ -1, %2 ], [ -1, %5 ], [ -1, %10 ]
ret i32 %17
}