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

/* Variables and functions */
int /*<<< orphan*/ endianessConversion(char *, char *, int);
int fread(char *, int, int, int /*<<< orphan*/ *);
int htons(int);
int /*<<< orphan*/ terror(char *);
void readSequenceLength(uint64_t *length, FILE *f) {
  char tmpArray[8];
  if (htons(1) == 1) {
    if (fread(length, sizeof(uint64_t), 1, f) != 1) {
      terror("Error reading sequence length");
    }
  } else {
    if (fread(tmpArray, sizeof(uint64_t), 1, f) != 1) {
      terror("Error reading sequence length");
    }
    endianessConversion(tmpArray, (char *)length, sizeof(uint64_t));
  }
}


x86 assembly (clang, -O0):
<readSequenceLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1050 <htons@plt>
cmp    $0x1,%eax
jne    1191 <readSequenceLength+0x51>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
cmp    $0x1,%eax
je     118c <readSequenceLength+0x4c>
lea    0xe79(%rip),%rdi
call   1060 <terror@plt>
jmp    11cc <readSequenceLength+0x8c>
lea    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
cmp    $0x1,%eax
je     11ba <readSequenceLength+0x7a>
lea    0xe4b(%rip),%rdi
call   1060 <terror@plt>
lea    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x1,%edx
call   1030 <endianessConversion@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readSequenceLength>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x1,%edi
call   1050 <htons@plt>
cmp    $0x1,%eax
jne    1186 <readSequenceLength+0x46>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     11bc <readSequenceLength+0x7c>
lea    0xe86(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <terror@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     11ac <readSequenceLength+0x6c>
lea    0xe59(%rip),%rdi
call   1060 <terror@plt>
mov    %rsp,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <endianessConversion@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Error reading sequence length\00"
define void @readSequenceLength(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [8 x i8]
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = call i32 @htons(i32 1)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i32*, i32** %4
%11 = call i32 @fread(i8* %9, i32 1, i32 1, i32* %10)
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @terror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %8
br label %27
16: ; preds = %2
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%18 = load i32*, i32** %4
%19 = call i32 @fread(i8* %17, i32 1, i32 1, i32* %18)
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @terror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %16
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%25 = load i8*, i8** %3
%26 = call i32 @endianessConversion(i8* %24, i8* %25, i32 1)
br label %27
27: ; preds = %23, %15
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Error reading sequence length\00"
define void @readSequenceLength(i8* %0, i32* nocapture %1) {
%3 = alloca [8 x i8]
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @htons(i32 1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = tail call i32 @fread(i8* %0, i32 1, i32 1, i32* %1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i32 @terror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %19
12: ; preds = %2
%13 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %1)
%14 = icmp eq i32 %13, 1
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @terror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = call i32 @endianessConversion(i8* %4, i8* %0, i32 1)
br label %19
19: ; preds = %7, %10, %17
ret void
}