#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 /*<<< orphan*/ evt_store(int, int, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int ftell(int /*<<< orphan*/ *);
int jtrace_common(int /*<<< orphan*/ *, int *, int *, int *, int *);
int jtrace_header_read(int /*<<< orphan*/ *);
int /*<<< orphan*/ name_register(int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stderr;
int trace_read_int(int /*<<< orphan*/ *);
int jtrace_read(FILE *f) {
  int len, type, time, task, cpu, res;
  char name[32];
  int name_len, name_len1, d;
  res = ftell(f);
  if (res < 0) {
    return -1;
  }
  if (res == 0) {
    res = jtrace_header_read(f);
    if (res < 0) {
      return -2;
    }
  }
  res = jtrace_common(f, &len, &type, &time, &task);
  if (res < 0) {
    return res;
  }
  switch (type) {
  case 9:
    name_len = len - 4;
    name_len1 = trace_read_int(f);
    if (name_len != name_len1) {
      fprintf(stderr, "Error: name len %d != %d\n", name_len, name_len1);
      return -3;
    }
    fread(name, name_len1, 1, f);
    name[name_len1] = 0;
    name_register(task, 0, name);
    evt_store(9, time, task, 0);
    break;
  case 1:
    if (len != 4) {
      fprintf(stderr, "Error: len = %d != 4 (CPU) - %d\n", len, type);
      return -4;
    }
    cpu = trace_read_int(f);
    evt_store(1, time, task, cpu);
    break;
  case 2:
    if (len != 4) {
      fprintf(stderr, "Error: len = %d != 4 (CPU) - %d\n", len, type);
      return -5;
    }
    cpu = trace_read_int(f);
    evt_store(2, time, task, cpu);
    break;
  case 0:
    if (len != 0) {
      fprintf(stderr, "Error: len = %d != 0 - %d\n", len, type);
      return -6;
    }
    evt_store(0, time, task, 0);
    break;
  case 3:
    if (len != 4) {
      fprintf(stderr, "Error: len = %d != 4 (CPU) - %d\n", len, type);
      return -7;
    }
    cpu = trace_read_int(f);
    evt_store(3, time, task, cpu);
    evt_store(2, time, task, cpu);
    break;
  case 5:
    if (len != 4) {
      fprintf(stderr, "Error: len = %d != 4 (deadline) - %d\n", len, type);
      return -8;
    }
    d = trace_read_int(f);
    break;
  default:
    printf("Event %d - Len %d\n", type, len);
    return -9;
  }
  return time;
}


x86 assembly (clang, -O0):
<jtrace_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    11be <jtrace_read+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
cmpl   $0x0,-0x28(%rbp)
jne    11ef <jtrace_read+0x5f>
mov    -0x10(%rbp),%rdi
call   1080 <jtrace_header_read@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    11ea <jtrace_read+0x5a>
movl   $0xfffffffe,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
jmp    11ef <jtrace_read+0x5f>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   10a0 <jtrace_common@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1220 <jtrace_read+0x90>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
mov    -0x18(%rbp),%eax
mov    %rax,-0x68(%rbp)
sub    $0x9,%rax
ja     1469 <jtrace_read+0x2d9>
mov    -0x68(%rbp),%rax
lea    0xdc4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <trace_read_int@plt>
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x58(%rbp),%eax
je     128d <jtrace_read+0xfd>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
mov    -0x54(%rbp),%edx
mov    -0x58(%rbp),%ecx
lea    0xdac(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%esi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
movslq -0x58(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
mov    -0x20(%rbp),%edi
lea    -0x50(%rbp),%rdx
xor    %esi,%esi
call   1090 <name_register@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    $0x9,%edi
xor    %ecx,%ecx
call   10b0 <evt_store@plt>
jmp    1487 <jtrace_read+0x2f7>
cmpl   $0x4,-0x14(%rbp)
je     1301 <jtrace_read+0x171>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xd52(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
mov    -0x10(%rbp),%rdi
call   1030 <trace_read_int@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    $0x1,%edi
call   10b0 <evt_store@plt>
jmp    1487 <jtrace_read+0x2f7>
cmpl   $0x4,-0x14(%rbp)
je     1356 <jtrace_read+0x1c6>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xcfd(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
mov    -0x10(%rbp),%rdi
call   1030 <trace_read_int@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    $0x2,%edi
call   10b0 <evt_store@plt>
jmp    1487 <jtrace_read+0x2f7>
cmpl   $0x0,-0x14(%rbp)
je     13ab <jtrace_read+0x21b>
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xcc9(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xfffffffa,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
xor    %ecx,%ecx
mov    %ecx,%edi
call   10b0 <evt_store@plt>
jmp    1487 <jtrace_read+0x2f7>
cmpl   $0x4,-0x14(%rbp)
je     13f0 <jtrace_read+0x260>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xc63(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xfffffff9,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
mov    -0x10(%rbp),%rdi
call   1030 <trace_read_int@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    $0x3,%edi
call   10b0 <evt_store@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    $0x2,%edi
call   10b0 <evt_store@plt>
jmp    1487 <jtrace_read+0x2f7>
cmpl   $0x4,-0x14(%rbp)
je     1458 <jtrace_read+0x2c8>
mov    0x2ba8(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xc37(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xfffffff8,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
mov    -0x10(%rbp),%rdi
call   1030 <trace_read_int@plt>
mov    %eax,-0x5c(%rbp)
jmp    1487 <jtrace_read+0x2f7>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xc2e(%rip),%rdi
call   1050 <printf@plt>
movl   $0xfffffff7,-0x4(%rbp)
jmp    148d <jtrace_read+0x2fd>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jtrace_read>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
call   1070 <ftell@plt>
test   %eax,%eax
js     1220 <jtrace_read+0x90>
jne    11b3 <jtrace_read+0x23>
mov    %rbx,%rdi
call   1080 <jtrace_header_read@plt>
test   %eax,%eax
js     122a <jtrace_read+0x9a>
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rsp,%r8
mov    %rbx,%rdi
call   10a0 <jtrace_common@plt>
test   %eax,%eax
js     1407 <jtrace_read+0x277>
mov    0xc(%rsp),%esi
cmp    $0x9,%rsi
ja     12c1 <jtrace_read+0x131>
lea    0xe16(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    0x8(%rsp),%edx
test   %edx,%edx
je     13f3 <jtrace_read+0x263>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
xor    %ecx,%ecx
call   1060 <fprintf@plt>
mov    $0xfffffffa,%eax
jmp    1407 <jtrace_read+0x277>
mov    $0xffffffff,%eax
jmp    1407 <jtrace_read+0x277>
mov    $0xfffffffe,%eax
jmp    1407 <jtrace_read+0x277>
mov    0x8(%rsp),%edx
cmp    $0x4,%edx
jne    134b <jtrace_read+0x1bb>
mov    %rbx,%rdi
call   1030 <trace_read_int@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    $0x1,%edi
mov    %eax,%ecx
jmp    13fe <jtrace_read+0x26e>
mov    0x8(%rsp),%edx
cmp    $0x4,%edx
jne    136f <jtrace_read+0x1df>
mov    %rbx,%rdi
call   1030 <trace_read_int@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    $0x2,%edi
mov    %eax,%ecx
jmp    13fe <jtrace_read+0x26e>
mov    0x8(%rsp),%edx
cmp    $0x4,%edx
jne    1390 <jtrace_read+0x200>
mov    %rbx,%rdi
call   1030 <trace_read_int@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    $0x3,%edi
mov    %eax,%ecx
call   10b0 <evt_store@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    $0x2,%edi
mov    %ebx,%ecx
jmp    13fe <jtrace_read+0x26e>
mov    0x8(%rsp),%edx
lea    0xdd8(%rip),%rdi
call   1050 <printf@plt>
mov    $0xfffffff7,%eax
jmp    1407 <jtrace_read+0x277>
mov    0x8(%rsp),%edx
cmp    $0x4,%edx
jne    13b1 <jtrace_read+0x221>
mov    %rbx,%rdi
call   1030 <trace_read_int@plt>
jmp    1403 <jtrace_read+0x273>
movslq 0x8(%rsp),%r14
add    $0xfffffffffffffffc,%r14
mov    %rbx,%rdi
call   1030 <trace_read_int@plt>
cmp    %eax,%r14d
jne    13d2 <jtrace_read+0x242>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
movb   $0x0,0x10(%rsp,%r14,1)
mov    (%rsp),%edi
xor    %esi,%esi
mov    %r15,%rdx
call   1090 <name_register@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    $0x9,%edi
jmp    13fc <jtrace_read+0x26c>
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
lea    0xce7(%rip),%rsi
mov    $0x1,%ecx
call   1060 <fprintf@plt>
mov    $0xfffffffc,%eax
jmp    1407 <jtrace_read+0x277>
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
lea    0xcc3(%rip),%rsi
mov    $0x2,%ecx
call   1060 <fprintf@plt>
mov    $0xfffffffb,%eax
jmp    1407 <jtrace_read+0x277>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
lea    0xca2(%rip),%rsi
mov    $0x3,%ecx
call   1060 <fprintf@plt>
mov    $0xfffffff9,%eax
jmp    1407 <jtrace_read+0x277>
mov    0x2c28(%rip),%rax
mov    (%rax),%edi
lea    0xcbd(%rip),%rsi
mov    $0x5,%ecx
call   1060 <fprintf@plt>
mov    $0xfffffff8,%eax
jmp    1407 <jtrace_read+0x277>
mov    0x2c07(%rip),%rcx
mov    (%rcx),%edi
lea    0xc46(%rip),%rsi
mov    %r14d,%edx
mov    %eax,%ecx
call   1060 <fprintf@plt>
mov    $0xfffffffd,%eax
jmp    1407 <jtrace_read+0x277>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
xor    %edi,%edi
xor    %ecx,%ecx
call   10b0 <evt_store@plt>
mov    0x4(%rsp),%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Error: name len %d != %d\0A\00"
@.str.1 = [33 x i8] c"Error: len = %d != 4 (CPU) - %d\0A\00"
@.str.2 = [27 x i8] c"Error: len = %d != 0 - %d\0A\00"
@.str.3 = [38 x i8] c"Error: len = %d != 4 (deadline) - %d\0A\00"
@.str.4 = [19 x i8] c"Event %d - Len %d\0A\00"
define i32 @jtrace_read(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [32 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %3
%14 = load i32*, i32** %3
%15 = call i32 @ftell(i32* %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %1
store i32 -1, i32* %2
br label %143
19: ; preds = %1
%20 = load i32, i32* %9
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32*, i32** %3
%24 = call i32 @jtrace_header_read(i32* %23)
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 -2, i32* %2
br label %143
28: ; preds = %22
br label %29
29: ; preds = %28, %19
%30 = load i32*, i32** %3
%31 = call i32 @jtrace_common(i32* %30, i32* %4, i32* %5, i32* %6, i32* %7)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = load i32, i32* %9
store i32 %35, i32* %2
br label %143
36: ; preds = %29
%37 = load i32, i32* %5
switch i32 %37, label %137 [
i32 9, label %38
i32 1, label %65
i32 2, label %80
i32 0, label %95
i32 3, label %107
i32 5, label %126
]
38: ; preds = %36
%39 = load i32, i32* %4
%40 = sub nsw i32 %39, 4
store i32 %40, i32* %11
%41 = load i32*, i32** %3
%42 = call i32 @trace_read_int(i32* %41)
store i32 %42, i32* %12
%43 = load i32, i32* %11
%44 = load i32, i32* %12
%45 = icmp ne i32 %43, %44
br i1 %45, label %46, label %51
46: ; preds = %38
%47 = load i32, i32* @stderr
%48 = load i32, i32* %11
%49 = load i32, i32* %12
%50 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %48, i32 %49)
store i32 -3, i32* %2
br label %143
51: ; preds = %38
%52 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%53 = load i32, i32* %12
%54 = load i32*, i32** %3
%55 = call i32 @fread(i8* %52, i32 %53, i32 1, i32* %54)
%56 = load i32, i32* %12
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 %57
store i8 0, i8* %58
%59 = load i32, i32* %7
%60 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%61 = call i32 @name_register(i32 %59, i32 0, i8* %60)
%62 = load i32, i32* %6
%63 = load i32, i32* %7
%64 = call i32 @evt_store(i32 9, i32 %62, i32 %63, i32 0)
br label %141
65: ; preds = %36
%66 = load i32, i32* %4
%67 = icmp ne i32 %66, 4
br i1 %67, label %68, label %73
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = load i32, i32* %4
%71 = load i32, i32* %5
%72 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %70, i32 %71)
store i32 -4, i32* %2
br label %143
73: ; preds = %65
%74 = load i32*, i32** %3
%75 = call i32 @trace_read_int(i32* %74)
store i32 %75, i32* %8
%76 = load i32, i32* %6
%77 = load i32, i32* %7
%78 = load i32, i32* %8
%79 = call i32 @evt_store(i32 1, i32 %76, i32 %77, i32 %78)
br label %141
80: ; preds = %36
%81 = load i32, i32* %4
%82 = icmp ne i32 %81, 4
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = load i32, i32* @stderr
%85 = load i32, i32* %4
%86 = load i32, i32* %5
%87 = call i32 @fprintf(i32 %84, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %85, i32 %86)
store i32 -5, i32* %2
br label %143
88: ; preds = %80
%89 = load i32*, i32** %3
%90 = call i32 @trace_read_int(i32* %89)
store i32 %90, i32* %8
%91 = load i32, i32* %6
%92 = load i32, i32* %7
%93 = load i32, i32* %8
%94 = call i32 @evt_store(i32 2, i32 %91, i32 %92, i32 %93)
br label %141
95: ; preds = %36
%96 = load i32, i32* %4
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %103
98: ; preds = %95
%99 = load i32, i32* @stderr
%100 = load i32, i32* %4
%101 = load i32, i32* %5
%102 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %100, i32 %101)
store i32 -6, i32* %2
br label %143
103: ; preds = %95
%104 = load i32, i32* %6
%105 = load i32, i32* %7
%106 = call i32 @evt_store(i32 0, i32 %104, i32 %105, i32 0)
br label %141
107: ; preds = %36
%108 = load i32, i32* %4
%109 = icmp ne i32 %108, 4
br i1 %109, label %110, label %115
110: ; preds = %107
%111 = load i32, i32* @stderr
%112 = load i32, i32* %4
%113 = load i32, i32* %5
%114 = call i32 @fprintf(i32 %111, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %112, i32 %113)
store i32 -7, i32* %2
br label %143
115: ; preds = %107
%116 = load i32*, i32** %3
%117 = call i32 @trace_read_int(i32* %116)
store i32 %117, i32* %8
%118 = load i32, i32* %6
%119 = load i32, i32* %7
%120 = load i32, i32* %8
%121 = call i32 @evt_store(i32 3, i32 %118, i32 %119, i32 %120)
%122 = load i32, i32* %6
%123 = load i32, i32* %7
%124 = load i32, i32* %8
%125 = call i32 @evt_store(i32 2, i32 %122, i32 %123, i32 %124)
br label %141
126: ; preds = %36
%127 = load i32, i32* %4
%128 = icmp ne i32 %127, 4
br i1 %128, label %129, label %134
129: ; preds = %126
%130 = load i32, i32* @stderr
%131 = load i32, i32* %4
%132 = load i32, i32* %5
%133 = call i32 @fprintf(i32 %130, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %131, i32 %132)
store i32 -8, i32* %2
br label %143
134: ; preds = %126
%135 = load i32*, i32** %3
%136 = call i32 @trace_read_int(i32* %135)
store i32 %136, i32* %13
br label %141
137: ; preds = %36
%138 = load i32, i32* %5
%139 = load i32, i32* %4
%140 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %138, i32 %139)
store i32 -9, i32* %2
br label %143
141: ; preds = %134, %115, %103, %88, %73, %51
%142 = load i32, i32* %6
store i32 %142, i32* %2
br label %143
143: ; preds = %141, %137, %129, %110, %98, %83, %68, %46, %34, %27, %18
%144 = load i32, i32* %2
ret i32 %144
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Error: name len %d != %d\0A\00"
@.str.1 = [33 x i8] c"Error: len = %d != 4 (CPU) - %d\0A\00"
@.str.2 = [27 x i8] c"Error: len = %d != 0 - %d\0A\00"
@.str.3 = [38 x i8] c"Error: len = %d != 4 (deadline) - %d\0A\00"
@.str.4 = [19 x i8] c"Event %d - Len %d\0A\00"
define i32 @jtrace_read(i32* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [32 x i8]
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%12 = tail call i32 @ftell(i32* %0)
%13 = icmp slt i32 %12, 0
br i1 %13, label %100, label %14
14: ; preds = %1
%15 = icmp eq i32 %12, 0
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = tail call i32 @jtrace_header_read(i32* %0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %100, label %19
19: ; preds = %16, %14
%20 = call i32 @jtrace_common(i32* %0, i32* %2, i32* %3, i32* %4, i32* %5)
%21 = icmp slt i32 %20, 0
br i1 %21, label %100, label %22
22: ; preds = %19
%23 = load i32, i32* %3
switch i32 %23, label %95 [
i32 9, label %24
i32 1, label %41
i32 2, label %52
i32 0, label %63
i32 3, label %73
i32 5, label %87
]
24: ; preds = %22
%25 = load i32, i32* %2
%26 = add nsw i32 %25, -4
%27 = call i32 @trace_read_int(i32* %0)
%28 = icmp eq i32 %26, %27
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27)
br label %100
32: ; preds = %24
%33 = call i32 @fread(i8* %11, i32 %26, i32 1, i32* %0)
%34 = sext i32 %26 to i64
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 %34
store i8 0, i8* %35
%36 = load i32, i32* %5
%37 = call i32 @name_register(i32 %36, i32 0, i8* %11)
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = call i32 @evt_store(i32 9, i32 %38, i32 %39, i32 0)
br label %98
41: ; preds = %22
%42 = load i32, i32* %2
%43 = icmp eq i32 %42, 4
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 1)
br label %100
47: ; preds = %41
%48 = call i32 @trace_read_int(i32* %0)
%49 = load i32, i32* %4
%50 = load i32, i32* %5
%51 = call i32 @evt_store(i32 1, i32 %49, i32 %50, i32 %48)
br label %98
52: ; preds = %22
%53 = load i32, i32* %2
%54 = icmp eq i32 %53, 4
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %53, i32 2)
br label %100
58: ; preds = %52
%59 = call i32 @trace_read_int(i32* %0)
%60 = load i32, i32* %4
%61 = load i32, i32* %5
%62 = call i32 @evt_store(i32 2, i32 %60, i32 %61, i32 %59)
br label %98
63: ; preds = %22
%64 = load i32, i32* %2
%65 = icmp eq i32 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = load i32, i32* @stderr
%68 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %64, i32 0)
br label %100
69: ; preds = %63
%70 = load i32, i32* %4
%71 = load i32, i32* %5
%72 = call i32 @evt_store(i32 0, i32 %70, i32 %71, i32 0)
br label %98
73: ; preds = %22
%74 = load i32, i32* %2
%75 = icmp eq i32 %74, 4
br i1 %75, label %79, label %76
76: ; preds = %73
%77 = load i32, i32* @stderr
%78 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %74, i32 3)
br label %100
79: ; preds = %73
%80 = call i32 @trace_read_int(i32* %0)
%81 = load i32, i32* %4
%82 = load i32, i32* %5
%83 = call i32 @evt_store(i32 3, i32 %81, i32 %82, i32 %80)
%84 = load i32, i32* %4
%85 = load i32, i32* %5
%86 = call i32 @evt_store(i32 2, i32 %84, i32 %85, i32 %80)
br label %98
87: ; preds = %22
%88 = load i32, i32* %2
%89 = icmp eq i32 %88, 4
br i1 %89, label %93, label %90
90: ; preds = %87
%91 = load i32, i32* @stderr
%92 = call i32 @fprintf(i32 %91, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %88, i32 5)
br label %100
93: ; preds = %87
%94 = call i32 @trace_read_int(i32* %0)
br label %98
95: ; preds = %22
%96 = load i32, i32* %2
%97 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %23, i32 %96)
br label %100
98: ; preds = %93, %79, %69, %58, %47, %32
%99 = load i32, i32* %4
br label %100
100: ; preds = %19, %16, %1, %98, %95, %90, %76, %66, %55, %44, %29
%101 = phi i32 [ -9, %95 ], [ -8, %90 ], [ %99, %98 ], [ -7, %76 ], [ -6, %66 ], [ -5, %55 ], [ -4, %44 ], [ -3, %29 ], [ -1, %1 ], [ -2, %16 ], [ %20, %19 ]
ret i32 %101
}