#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 EOF;
int fgetc(int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int initial_read(FILE *f) {
  int c, res;
  char buff[16];
  res = fread(buff, 10, 1, f);
  if (res != 1) {
    return -1;
  }
  if ((buff[0] != 0x17) || (buff[1] != 0x08) || (buff[2] != 0x044) ||
      memcmp(buff + 3, "tracing", 7)) {
    printf("%x %x %x %s\n", buff[0], buff[1], buff[2], buff + 3);
    return -2;
  }
  printf("Version: ");
  c = 1;
  while (c) {
    c = fgetc(f);
    if (c == EOF) {
      return -1;
    }
    printf("%c", (char)c);
  }
  printf("\n");
  res = fread(buff, 6, 1, f);
  if (res != 1) {
    return -1;
  }
  printf("Endianess: %d\tBytes per Long: %d\tPage size: %d\n", buff[0], buff[1],
         (buff[2] << 24) + (buff[3] << 16) + (buff[4] << 8) + buff[5]);
  return 0;
}


x86 assembly (clang, -O0):
<initial_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0xa,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     117c <initial_read+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d0 <initial_read+0x190>
movsbl -0x30(%rbp),%eax
cmp    $0x17,%eax
jne    11c6 <initial_read+0x86>
movsbl -0x2f(%rbp),%eax
cmp    $0x8,%eax
jne    11c6 <initial_read+0x86>
movsbl -0x2e(%rbp),%eax
cmp    $0x44,%eax
jne    11c6 <initial_read+0x86>
lea    -0x30(%rbp),%rdi
add    $0x3,%rdi
lea    0xe4e(%rip),%rsi
mov    $0x7,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     11f4 <initial_read+0xb4>
movsbl -0x30(%rbp),%esi
movsbl -0x2f(%rbp),%edx
movsbl -0x2e(%rbp),%ecx
lea    -0x30(%rbp),%r8
add    $0x3,%r8
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    12d0 <initial_read+0x190>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1256 <initial_read+0x116>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2dbf(%rip),%rcx
cmp    (%rcx),%eax
jne    123d <initial_read+0xfd>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d0 <initial_read+0x190>
mov    -0x14(%rbp),%eax
movsbl %al,%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1209 <initial_read+0xc9>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x6,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     1294 <initial_read+0x154>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d0 <initial_read+0x190>
movsbl -0x30(%rbp),%esi
movsbl -0x2f(%rbp),%edx
movsbl -0x2e(%rbp),%ecx
shl    $0x18,%ecx
movsbl -0x2d(%rbp),%eax
shl    $0x10,%eax
add    %eax,%ecx
movsbl -0x2c(%rbp),%eax
shl    $0x8,%eax
add    %eax,%ecx
movsbl -0x2b(%rbp),%eax
add    %eax,%ecx
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initial_read>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    $0xffffffff,%r14d
cmp    $0x1,%eax
jne    11e2 <initial_read+0x92>
mov    (%rsp),%al
mov    0x1(%rsp),%cl
mov    0x2(%rsp),%dil
cmp    $0x17,%al
jne    11bf <initial_read+0x6f>
cmp    $0x8,%cl
jne    11bf <initial_read+0x6f>
cmp    $0x44,%dil
jne    11bf <initial_read+0x6f>
lea    0x3(%rsp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x7,%edx
call   1070 <memcmp@plt>
test   %rax,%rax
je     11f0 <initial_read+0xa0>
mov    (%rsp),%al
mov    0x1(%rsp),%cl
mov    0x2(%rsp),%dil
movsbl %al,%esi
movsbl %cl,%edx
movsbl %dil,%ecx
lea    0x3(%rsp),%r8
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xfffffffe,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2de3(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    (%r15),%eax
je     11e2 <initial_read+0x92>
mov    %eax,%ebp
movsbl %bpl,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jne    1210 <initial_read+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    11e2 <initial_read+0x92>
movsbl (%rsp),%esi
movsbl 0x1(%rsp),%edx
movzbl 0x2(%rsp),%eax
shl    $0x18,%eax
movsbl 0x3(%rsp),%ecx
shl    $0x10,%ecx
add    %eax,%ecx
movsbl 0x4(%rsp),%eax
shl    $0x8,%eax
add    %ecx,%eax
movsbl 0x5(%rsp),%ecx
add    %eax,%ecx
lea    0xd9c(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e2 <initial_read+0x92>

LLVM IR (-O0):
@.str = [8 x i8] c"tracing\00"
@.str.1 = [13 x i8] c"%x %x %x %s\0A\00"
@.str.2 = [10 x i8] c"Version: \00"
@EOF = global i32 0
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [48 x i8] c"Endianess: %d\09Bytes per Long: %d\09Page size: %d\0A\00"
define i32 @initial_read(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i8]
store i32* %0, i32** %3
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%8 = load i32*, i32** %3
%9 = call i32 @fread(i8* %7, i32 10, i32 1, i32* %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 -1, i32* %2
br label %97
13: ; preds = %1
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 23
br i1 %17, label %33, label %18
18: ; preds = %13
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 8
br i1 %22, label %33, label %23
23: ; preds = %18
%24 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 68
br i1 %27, label %33, label %28
28: ; preds = %23
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%30 = getelementptr inbounds i8, i8* %29, i64 3
%31 = call i64 @memcmp(i8* %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %46
33: ; preds = %28, %23, %18, %13
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 2
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%44 = getelementptr inbounds i8, i8* %43, i64 3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 %39, i32 %42, i8* %44)
store i32 -2, i32* %2
br label %97
46: ; preds = %28
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %4
br label %48
48: ; preds = %58, %46
%49 = load i32, i32* %4
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %63
51: ; preds = %48
%52 = load i32*, i32** %3
%53 = call i32 @fgetc(i32* %52)
store i32 %53, i32* %4
%54 = load i32, i32* %4
%55 = load i32, i32* @EOF
%56 = icmp eq i32 %54, %55
br i1 %56, label %57, label %58
57: ; preds = %51
store i32 -1, i32* %2
br label %97
58: ; preds = %51
%59 = load i32, i32* %4
%60 = trunc i32 %59 to i8
%61 = sext i8 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %61)
br label %48
63: ; preds = %48
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%65 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%66 = load i32*, i32** %3
%67 = call i32 @fread(i8* %65, i32 6, i32 1, i32* %66)
store i32 %67, i32* %5
%68 = load i32, i32* %5
%69 = icmp ne i32 %68, 1
br i1 %69, label %70, label %71
70: ; preds = %63
store i32 -1, i32* %2
br label %97
71: ; preds = %63
%72 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 1
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 2
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = shl i32 %80, 24
%82 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 3
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = shl i32 %84, 16
%86 = add nsw i32 %81, %85
%87 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 4
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = shl i32 %89, 8
%91 = add nsw i32 %86, %90
%92 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 5
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = add nsw i32 %91, %94
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %74, i32 %77, i32 %95)
store i32 0, i32* %2
br label %97
97: ; preds = %71, %70, %57, %33, %12
%98 = load i32, i32* %2
ret i32 %98
}

LLVM IR (-O2):
@.str = [8 x i8] c"tracing\00"
@.str.1 = [13 x i8] c"%x %x %x %s\0A\00"
@.str.2 = [10 x i8] c"Version: \00"
@EOF = global i32 0
@.str.5 = [48 x i8] c"Endianess: %d\09Bytes per Long: %d\09Page size: %d\0A\00"
define i32 @initial_read(i32* nocapture %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = call i32 @fread(i8* %3, i32 10, i32 1, i32* %0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %71
6: ; preds = %1
%7 = load i8, i8* %3
%8 = icmp ne i8 %7, 23
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 1
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 8
%12 = select i1 %8, i1 true, i1 %11
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 2
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 68
%16 = select i1 %12, i1 true, i1 %15
br i1 %16, label %25, label %17
17: ; preds = %6
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 3
%19 = call i64 @memcmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%20 = icmp eq i64 %19, 0
br i1 %20, label %34, label %21
21: ; preds = %17
%22 = load i8, i8* %3
%23 = load i8, i8* %9
%24 = load i8, i8* %13
br label %25
25: ; preds = %21, %6
%26 = phi i8 [ %24, %21 ], [ %14, %6 ]
%27 = phi i8 [ %23, %21 ], [ %10, %6 ]
%28 = phi i8 [ %22, %21 ], [ %7, %6 ]
%29 = sext i8 %28 to i32
%30 = sext i8 %27 to i32
%31 = sext i8 %26 to i32
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 3
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30, i32 %31, i8* %32)
br label %71
34: ; preds = %17
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %40
%37 = call i32 @fgetc(i32* %0)
%38 = load i32, i32* @EOF
%39 = icmp eq i32 %37, %38
br i1 %39, label %71, label %40
40: ; preds = %36
%41 = shl i32 %37, 24
%42 = ashr exact i32 %41, 24
%43 = call i32 @putchar(i32 %42)
%44 = icmp eq i32 %37, 0
br i1 %44, label %45, label %36
45: ; preds = %40
%46 = call i32 @putchar(i32 10)
%47 = call i32 @fread(i8* %3, i32 6, i32 1, i32* %0)
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %71
49: ; preds = %45
%50 = load i8, i8* %3
%51 = sext i8 %50 to i32
%52 = load i8, i8* %9
%53 = sext i8 %52 to i32
%54 = load i8, i8* %13
%55 = zext i8 %54 to i32
%56 = shl nuw i32 %55, 24
%57 = load i8, i8* %18
%58 = sext i8 %57 to i32
%59 = shl nsw i32 %58, 16
%60 = add nsw i32 %59, %56
%61 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 4
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = shl nsw i32 %63, 8
%65 = add nsw i32 %60, %64
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 5
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = add nsw i32 %65, %68
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %51, i32 %53, i32 %69)
br label %71
71: ; preds = %36, %45, %1, %49, %25
%72 = phi i32 [ -2, %25 ], [ 0, %49 ], [ -1, %1 ], [ -1, %45 ], [ -1, %36 ]
ret i32 %72
}