#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*/ uint64_t;
typedef int uint32_t;
typedef scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fwrite(char *, scalar_t__, int, int /*<<< orphan*/);
int le32toh(int);
int /*<<< orphan*/ le64toh(int);
scalar_t__ malloc(scalar_t__);
scalar_t__ read(int, char *, scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int parse_playback_log_header(int fd, char *header) {
  if (header[0] != 1) {
    fprintf(stderr, "ERROR: Invalid playback log entry type %d\n", header[0]);
    return -1;
  }
  uint64_t general_rows = le64toh(*(uint32_t *)(header + 1 + (6 * 4) + 8));
  uint32_t thread_id = le32toh(*(uint32_t *)(header + 1 + 2 * 4));
  ssize_t user_length = (ssize_t)le32toh(*(uint32_t *)(header + 1 + 3 * 4));
  ssize_t command_length = (ssize_t)le32toh(*(uint32_t *)(header + 1 + 4 * 4));
  ssize_t query_length = (ssize_t)le32toh(*(uint32_t *)(header + 1 + 5 * 4));
  fprintf(stdout, "/* Thread Id: %d Rows: %ld ", thread_id, general_rows);
  char static_buf[1024];
  char *buf;
  ssize_t maxlen =
      (user_length > command_length) ? user_length : command_length;
  if (query_length > maxlen)
    maxlen = query_length;
  if (maxlen < 1024)
    buf = static_buf;
  else
    buf = (char *)malloc(query_length);
  ssize_t r;
  r = read(fd, buf, user_length);
  if (r != user_length) {
    fprintf(stderr, "ERROR: Couldn't read all of user\n");
    return -2;
  }
  fprintf(stdout, "User: ");
  fwrite(buf, user_length, 1, stdout);
  r = read(fd, buf, command_length);
  if (r != command_length) {
    fprintf(stderr, "ERROR: Couldn't read all of command\n");
    return -2;
  }
  fprintf(stdout, " Command: ");
  fwrite(buf, command_length, 1, stdout);
  r = read(fd, buf, query_length);
  if (r != query_length) {
    fprintf(stderr, "ERROR: Couldn't read all of query\n");
    return -2;
  }
  fprintf(stdout, " */ ");
  fwrite(buf, query_length, 1, stdout);
  fprintf(stdout, ";\n");
  if (static_buf != buf)
    free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<parse_playback_log_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1,%eax
je     11bc <parse_playback_log_header+0x4c>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movsbl (%rax),%edx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    147b <parse_playback_log_header+0x30b>
mov    -0x10(%rbp),%rax
mov    0x21(%rax),%edi
call   1030 <le64toh@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x9(%rax),%edi
call   1050 <le32toh@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0xd(%rax),%edi
call   1050 <le32toh@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x11(%rax),%edi
call   1050 <le32toh@plt>
cltq
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x15(%rax),%edi
call   1050 <le32toh@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jle    124b <parse_playback_log_header+0xdb>
mov    -0x20(%rbp),%rax
mov    %rax,-0x450(%rbp)
jmp    1256 <parse_playback_log_header+0xe6>
mov    -0x28(%rbp),%rax
mov    %rax,-0x450(%rbp)
mov    -0x450(%rbp),%rax
mov    %rax,-0x440(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x440(%rbp),%rax
jle    1280 <parse_playback_log_header+0x110>
mov    -0x30(%rbp),%rax
mov    %rax,-0x440(%rbp)
cmpq   $0x400,-0x440(%rbp)
jge    12a4 <parse_playback_log_header+0x134>
lea    -0x430(%rbp),%rax
mov    %rax,-0x438(%rbp)
jmp    12b4 <parse_playback_log_header+0x144>
mov    -0x30(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x438(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x438(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <read@plt>
mov    %rax,-0x448(%rbp)
mov    -0x448(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     1302 <parse_playback_log_header+0x192>
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
lea    0xd58(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    147b <parse_playback_log_header+0x30b>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
lea    0xd57(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x438(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2cad(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    -0x8(%rbp),%edi
mov    -0x438(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <read@plt>
mov    %rax,-0x448(%rbp)
mov    -0x448(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1385 <parse_playback_log_header+0x215>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    0xcfe(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    147b <parse_playback_log_header+0x30b>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
lea    0xd00(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x438(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x2c2a(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    -0x8(%rbp),%edi
mov    -0x438(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <read@plt>
mov    %rax,-0x448(%rbp)
mov    -0x448(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1408 <parse_playback_log_header+0x298>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
lea    0xcab(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    147b <parse_playback_log_header+0x30b>
mov    0x2bc9(%rip),%rax
mov    (%rax),%edi
lea    0xcab(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x438(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x2ba7(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    0x2b94(%rip),%rax
mov    (%rax),%edi
lea    0xc7b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    -0x430(%rbp),%rax
cmp    -0x438(%rbp),%rax
je     1474 <parse_playback_log_header+0x304>
mov    -0x438(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_playback_log_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
movsbl (%rsi),%edx
cmp    $0x1,%edx
jne    1204 <parse_playback_log_header+0x94>
mov    %rsi,%rbp
mov    %edi,0xc(%rsp)
mov    0x21(%rsi),%edi
call   1030 <le64toh@plt>
mov    %eax,%r15d
mov    0x9(%rbp),%edi
call   1050 <le32toh@plt>
mov    %eax,%r14d
mov    0xd(%rbp),%edi
call   1050 <le32toh@plt>
movslq %eax,%rbx
mov    0x11(%rbp),%edi
call   1050 <le32toh@plt>
movslq %eax,%r13
mov    0x15(%rbp),%edi
call   1050 <le32toh@plt>
movslq %eax,%r12
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
mov    %r14d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    %r13,%rbx
mov    %r13,%rax
cmovg  %rbx,%rax
cmp    %r12,%rax
cmovl  %r12,%rax
cmp    $0x400,%rax
jge    1225 <parse_playback_log_header+0xb5>
lea    0x10(%rsp),%r15
jmp    1230 <parse_playback_log_header+0xc0>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
lea    0xdec(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    134c <parse_playback_log_header+0x1dc>
mov    %r12,%rdi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <read@plt>
cmp    %rbx,%rax
mov    0x2d8d(%rip),%r14
jne    130c <parse_playback_log_header+0x19c>
mov    (%r14),%edi
lea    0xe0e(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%ecx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r13,%rdx
call   1060 <read@plt>
cmp    %r13,%rax
jne    131e <parse_playback_log_header+0x1ae>
mov    (%r14),%edi
lea    0xe00(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%ecx
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <read@plt>
cmp    %r12,%rax
jne    1330 <parse_playback_log_header+0x1c0>
mov    (%r14),%edi
lea    0xdf6(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%ecx
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1090 <fwrite@plt>
mov    (%r14),%edi
lea    0xdd7(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0x10(%rsp),%rax
cmp    %r15,%rax
je     134c <parse_playback_log_header+0x1dc>
mov    %r15,%rdi
call   1040 <free@plt>
jmp    134c <parse_playback_log_header+0x1dc>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
lea    0xd2b(%rip),%rsi
jmp    1340 <parse_playback_log_header+0x1d0>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
jmp    1340 <parse_playback_log_header+0x1d0>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
lea    0xd60(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xfffffffe,%ebx
mov    %ebx,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"ERROR: Invalid playback log entry type %d\0A\00"
@stdout = global i32 0
@.str.1 = [28 x i8] c"/* Thread Id: %d Rows: %ld \00"
@.str.2 = [34 x i8] c"ERROR: Couldn't read all of user\0A\00"
@.str.3 = [7 x i8] c"User: \00"
@.str.4 = [37 x i8] c"ERROR: Couldn't read all of command\0A\00"
@.str.5 = [11 x i8] c" Command: \00"
@.str.6 = [35 x i8] c"ERROR: Couldn't read all of query\0A\00"
@.str.7 = [5 x i8] c" */ \00"
@.str.8 = [3 x i8] c";\0A\00"
define i32 @parse_playback_log_header(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca [1024 x i8]
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 1
br i1 %19, label %20, label %27
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %25)
store i32 -1, i32* %3
br label %150
27: ; preds = %2
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = getelementptr inbounds i8, i8* %29, i64 24
%31 = getelementptr inbounds i8, i8* %30, i64 8
%32 = bitcast i8* %31 to i32*
%33 = load i32, i32* %32
%34 = call i32 @le64toh(i32 %33)
store i32 %34, i32* %6
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = getelementptr inbounds i8, i8* %36, i64 8
%38 = bitcast i8* %37 to i32*
%39 = load i32, i32* %38
%40 = call i32 @le32toh(i32 %39)
store i32 %40, i32* %7
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = getelementptr inbounds i8, i8* %42, i64 12
%44 = bitcast i8* %43 to i32*
%45 = load i32, i32* %44
%46 = call i32 @le32toh(i32 %45)
%47 = sext i32 %46 to i64
store i64 %47, i64* %8
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = getelementptr inbounds i8, i8* %49, i64 16
%51 = bitcast i8* %50 to i32*
%52 = load i32, i32* %51
%53 = call i32 @le32toh(i32 %52)
%54 = sext i32 %53 to i64
store i64 %54, i64* %9
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = getelementptr inbounds i8, i8* %56, i64 20
%58 = bitcast i8* %57 to i32*
%59 = load i32, i32* %58
%60 = call i32 @le32toh(i32 %59)
%61 = sext i32 %60 to i64
store i64 %61, i64* %10
%62 = load i32, i32* @stdout
%63 = load i32, i32* %7
%64 = load i32, i32* %6
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %63, i32 %64)
%66 = load i64, i64* %8
%67 = load i64, i64* %9
%68 = icmp sgt i64 %66, %67
br i1 %68, label %69, label %71
69: ; preds = %27
%70 = load i64, i64* %8
br label %73
71: ; preds = %27
%72 = load i64, i64* %9
br label %73
73: ; preds = %71, %69
%74 = phi i64 [ %70, %69 ], [ %72, %71 ]
store i64 %74, i64* %13
%75 = load i64, i64* %10
%76 = load i64, i64* %13
%77 = icmp sgt i64 %75, %76
br i1 %77, label %78, label %80
78: ; preds = %73
%79 = load i64, i64* %10
store i64 %79, i64* %13
br label %80
80: ; preds = %78, %73
%81 = load i64, i64* %13
%82 = icmp slt i64 %81, 1024
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
store i8* %84, i8** %12
br label %89
85: ; preds = %80
%86 = load i64, i64* %10
%87 = call i64 @malloc(i64 %86)
%88 = inttoptr i64 %87 to i8*
store i8* %88, i8** %12
br label %89
89: ; preds = %85, %83
%90 = load i32, i32* %4
%91 = load i8*, i8** %12
%92 = load i64, i64* %8
%93 = call i64 @read(i32 %90, i8* %91, i64 %92)
store i64 %93, i64* %14
%94 = load i64, i64* %14
%95 = load i64, i64* %8
%96 = icmp ne i64 %94, %95
br i1 %96, label %97, label %100
97: ; preds = %89
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
store i32 -2, i32* %3
br label %150
100: ; preds = %89
%101 = load i32, i32* @stdout
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%103 = load i8*, i8** %12
%104 = load i64, i64* %8
%105 = load i32, i32* @stdout
%106 = call i32 @fwrite(i8* %103, i64 %104, i32 1, i32 %105)
%107 = load i32, i32* %4
%108 = load i8*, i8** %12
%109 = load i64, i64* %9
%110 = call i64 @read(i32 %107, i8* %108, i64 %109)
store i64 %110, i64* %14
%111 = load i64, i64* %14
%112 = load i64, i64* %9
%113 = icmp ne i64 %111, %112
br i1 %113, label %114, label %117
114: ; preds = %100
%115 = load i32, i32* @stderr
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 -2, i32* %3
br label %150
117: ; preds = %100
%118 = load i32, i32* @stdout
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%120 = load i8*, i8** %12
%121 = load i64, i64* %9
%122 = load i32, i32* @stdout
%123 = call i32 @fwrite(i8* %120, i64 %121, i32 1, i32 %122)
%124 = load i32, i32* %4
%125 = load i8*, i8** %12
%126 = load i64, i64* %10
%127 = call i64 @read(i32 %124, i8* %125, i64 %126)
store i64 %127, i64* %14
%128 = load i64, i64* %14
%129 = load i64, i64* %10
%130 = icmp ne i64 %128, %129
br i1 %130, label %131, label %134
131: ; preds = %117
%132 = load i32, i32* @stderr
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
store i32 -2, i32* %3
br label %150
134: ; preds = %117
%135 = load i32, i32* @stdout
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%137 = load i8*, i8** %12
%138 = load i64, i64* %10
%139 = load i32, i32* @stdout
%140 = call i32 @fwrite(i8* %137, i64 %138, i32 1, i32 %139)
%141 = load i32, i32* @stdout
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%143 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%144 = load i8*, i8** %12
%145 = icmp ne i8* %143, %144
br i1 %145, label %146, label %149
146: ; preds = %134
%147 = load i8*, i8** %12
%148 = call i32 @free(i8* %147)
br label %149
149: ; preds = %146, %134
store i32 0, i32* %3
br label %150
150: ; preds = %149, %131, %114, %97, %20
%151 = load i32, i32* %3
ret i32 %151
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"ERROR: Invalid playback log entry type %d\0A\00"
@stdout = global i32 0
@.str.1 = [28 x i8] c"/* Thread Id: %d Rows: %ld \00"
@.str.2 = [34 x i8] c"ERROR: Couldn't read all of user\0A\00"
@.str.3 = [7 x i8] c"User: \00"
@.str.4 = [37 x i8] c"ERROR: Couldn't read all of command\0A\00"
@.str.5 = [11 x i8] c" Command: \00"
@.str.6 = [35 x i8] c"ERROR: Couldn't read all of query\0A\00"
@.str.7 = [5 x i8] c" */ \00"
@.str.8 = [3 x i8] c";\0A\00"
define i32 @parse_playback_log_header(i32 %0, i8* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 1
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = sext i8 %4 to i32
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %84
10: ; preds = %2
%11 = getelementptr inbounds i8, i8* %1, i64 33
%12 = bitcast i8* %11 to i32*
%13 = load i32, i32* %12
%14 = tail call i32 @le64toh(i32 %13)
%15 = getelementptr inbounds i8, i8* %1, i64 9
%16 = bitcast i8* %15 to i32*
%17 = load i32, i32* %16
%18 = tail call i32 @le32toh(i32 %17)
%19 = getelementptr inbounds i8, i8* %1, i64 13
%20 = bitcast i8* %19 to i32*
%21 = load i32, i32* %20
%22 = tail call i32 @le32toh(i32 %21)
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %1, i64 17
%25 = bitcast i8* %24 to i32*
%26 = load i32, i32* %25
%27 = tail call i32 @le32toh(i32 %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %1, i64 21
%30 = bitcast i8* %29 to i32*
%31 = load i32, i32* %30
%32 = tail call i32 @le32toh(i32 %31)
%33 = sext i32 %32 to i64
%34 = load i32, i32* @stdout
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %14)
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%37 = icmp sgt i64 %23, %28
%38 = select i1 %37, i64 %23, i64 %28
%39 = icmp slt i64 %38, %33
%40 = select i1 %39, i64 %33, i64 %38
%41 = icmp slt i64 %40, 1024
br i1 %41, label %45, label %42
42: ; preds = %10
%43 = tail call i64 @malloc(i64 %33)
%44 = inttoptr i64 %43 to i8*
br label %45
45: ; preds = %10, %42
%46 = phi i8* [ %44, %42 ], [ %36, %10 ]
%47 = call i64 @read(i32 %0, i8* %46, i64 %23)
%48 = icmp eq i64 %47, %23
br i1 %48, label %52, label %49
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %82
52: ; preds = %45
%53 = load i32, i32* @stdout
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%55 = load i32, i32* @stdout
%56 = call i32 @fwrite(i8* %46, i64 %23, i32 1, i32 %55)
%57 = call i64 @read(i32 %0, i8* %46, i64 %28)
%58 = icmp eq i64 %57, %28
br i1 %58, label %62, label %59
59: ; preds = %52
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %82
62: ; preds = %52
%63 = load i32, i32* @stdout
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%65 = load i32, i32* @stdout
%66 = call i32 @fwrite(i8* %46, i64 %28, i32 1, i32 %65)
%67 = call i64 @read(i32 %0, i8* %46, i64 %33)
%68 = icmp eq i64 %67, %33
br i1 %68, label %72, label %69
69: ; preds = %62
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %82
72: ; preds = %62
%73 = load i32, i32* @stdout
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%75 = load i32, i32* @stdout
%76 = call i32 @fwrite(i8* %46, i64 %33, i32 1, i32 %75)
%77 = load i32, i32* @stdout
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%79 = icmp eq i8* %36, %46
br i1 %79, label %82, label %80
80: ; preds = %72
%81 = call i32 @free(i8* %46)
br label %82
82: ; preds = %72, %80, %69, %59, %49
%83 = phi i32 [ -2, %49 ], [ -2, %59 ], [ -2, %69 ], [ 0, %80 ], [ 0, %72 ]
br label %84
84: ; preds = %82, %6
%85 = phi i32 [ -1, %6 ], [ %83, %82 ]
ret i32 %85
}