#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 scalar_t__ uint8_t;
typedef int uint64_t;

/* Variables and functions */
int /*<<< orphan*/ is_big_endian();
const uint8_t *read_fixed64(uint64_t *v, const uint8_t *buffer,
                            const uint8_t *buffer_end) {
  if (buffer + 8 > buffer_end)
    return NULL;
  if (!is_big_endian()) {
    *v = *(uint64_t *)buffer;
  } else {
    *v = ((uint64_t)buffer[0]) | (((uint64_t)buffer[1]) << 8) |
         (((uint64_t)buffer[2]) << 16) | (((uint64_t)buffer[3]) << 24) |
         (((uint64_t)buffer[4]) << 32) | (((uint64_t)buffer[5]) << 40) |
         (((uint64_t)buffer[6]) << 48) | (((uint64_t)buffer[7]) << 56);
  }
  return buffer + 8;
}


x86 assembly (clang, -O0):
<read_fixed64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x40,%rax
cmp    -0x20(%rbp),%rax
jbe    1143 <read_fixed64+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11fa <read_fixed64+0xea>
mov    $0x0,%al
call   1030 <is_big_endian@plt>
cmp    $0x0,%eax
jne    1164 <read_fixed64+0x54>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ee <read_fixed64+0xde>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    0x8(%rcx),%rcx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    0x10(%rcx),%rcx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    0x18(%rcx),%rcx
shl    $0x18,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    0x20(%rcx),%rcx
mov    %ecx,%edx
mov    $0x20,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    0x28(%rcx),%rcx
mov    %ecx,%edx
mov    $0x28,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%rcx
mov    0x30(%rcx),%rcx
mov    %ecx,%edx
mov    $0x30,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x38(%rax),%rax
mov    $0x38,%ecx
shl    %cl,%eax
mov    -0x24(%rbp),%ecx
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_fixed64>:
push   %r15
push   %r14
push   %rbx
lea    0x40(%rsi),%rbx
cmp    %rdx,%rbx
jbe    1122 <read_fixed64+0x12>
xor    %ebx,%ebx
jmp    1139 <read_fixed64+0x29>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <is_big_endian@plt>
test   %eax,%eax
jne    1136 <read_fixed64+0x26>
mov    (%r15),%ecx
mov    %ecx,(%r14)
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64* @read_fixed64(i32* %0, i64* %1, i64* %2) {
%4 = alloca i64*
%5 = alloca i32*
%6 = alloca i64*
%7 = alloca i64*
store i32* %0, i32** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
%8 = load i64*, i64** %6
%9 = getelementptr inbounds i64, i64* %8, i64 8
%10 = load i64*, i64** %7
%11 = icmp ugt i64* %9, %10
br i1 %11, label %12, label %13
12: ; preds = %3
store i64* null, i64** %4
br label %72
13: ; preds = %3
%14 = call i32 (...) @is_big_endian()
%15 = icmp ne i32 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = load i64*, i64** %6
%18 = bitcast i64* %17 to i32*
%19 = load i32, i32* %18
%20 = load i32*, i32** %5
store i32 %19, i32* %20
br label %69
21: ; preds = %13
%22 = load i64*, i64** %6
%23 = getelementptr inbounds i64, i64* %22, i64 0
%24 = load i64, i64* %23
%25 = trunc i64 %24 to i32
%26 = load i64*, i64** %6
%27 = getelementptr inbounds i64, i64* %26, i64 1
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i32
%30 = shl i32 %29, 8
%31 = or i32 %25, %30
%32 = load i64*, i64** %6
%33 = getelementptr inbounds i64, i64* %32, i64 2
%34 = load i64, i64* %33
%35 = trunc i64 %34 to i32
%36 = shl i32 %35, 16
%37 = or i32 %31, %36
%38 = load i64*, i64** %6
%39 = getelementptr inbounds i64, i64* %38, i64 3
%40 = load i64, i64* %39
%41 = trunc i64 %40 to i32
%42 = shl i32 %41, 24
%43 = or i32 %37, %42
%44 = load i64*, i64** %6
%45 = getelementptr inbounds i64, i64* %44, i64 4
%46 = load i64, i64* %45
%47 = trunc i64 %46 to i32
%48 = shl i32 %47, 32
%49 = or i32 %43, %48
%50 = load i64*, i64** %6
%51 = getelementptr inbounds i64, i64* %50, i64 5
%52 = load i64, i64* %51
%53 = trunc i64 %52 to i32
%54 = shl i32 %53, 40
%55 = or i32 %49, %54
%56 = load i64*, i64** %6
%57 = getelementptr inbounds i64, i64* %56, i64 6
%58 = load i64, i64* %57
%59 = trunc i64 %58 to i32
%60 = shl i32 %59, 48
%61 = or i32 %55, %60
%62 = load i64*, i64** %6
%63 = getelementptr inbounds i64, i64* %62, i64 7
%64 = load i64, i64* %63
%65 = trunc i64 %64 to i32
%66 = shl i32 %65, 56
%67 = or i32 %61, %66
%68 = load i32*, i32** %5
store i32 %67, i32* %68
br label %69
69: ; preds = %21, %16
%70 = load i64*, i64** %6
%71 = getelementptr inbounds i64, i64* %70, i64 8
store i64* %71, i64** %4
br label %72
72: ; preds = %69, %12
%73 = load i64*, i64** %4
ret i64* %73
}

LLVM IR (-O2):
define i64* @read_fixed64(i32* nocapture writeonly %0, i64* %1, i64* readnone %2) {
%4 = getelementptr inbounds i64, i64* %1, i64 8
%5 = icmp ugt i64* %4, %2
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = tail call i32 (...) @is_big_endian()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = bitcast i64* %1 to i32*
%11 = load i32, i32* %10
br label %12
12: ; preds = %6, %9
%13 = phi i32 [ %11, %9 ], [ poison, %6 ]
store i32 %13, i32* %0
br label %14
14: ; preds = %3, %12
%15 = phi i64* [ %4, %12 ], [ null, %3 ]
ret i64* %15
}