#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 uint64_t;

/* Variables and functions */
size_t uint64PackSize(int *);
size_t uint64Unpack(const char *buffer, size_t size, uint64_t *data) {
  size_t req = uint64PackSize(data);
  if (size >= req) {
    *data = ((uint64_t)buffer[0] << 56) | ((uint64_t)buffer[1] << 48) |
            ((uint64_t)buffer[2] << 40) | ((uint64_t)buffer[3] << 32) |
            ((uint64_t)buffer[4] << 24) | ((uint64_t)buffer[5] << 16) |
            ((uint64_t)buffer[6] << 8) | ((uint64_t)buffer[7]);
  }
  return req;
}


x86 assembly (clang, -O0):
<uint64Unpack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <uint64PackSize@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     11c1 <uint64Unpack+0xb1>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    $0x38,%ecx
shl    %cl,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%edx
mov    $0x30,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x2(%rcx),%edx
mov    $0x28,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    -0x24(%rbp),%ecx
or     %eax,%ecx
mov    -0x8(%rbp),%rax
movsbl 0x4(%rax),%eax
shl    $0x18,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
movsbl 0x5(%rax),%eax
shl    $0x10,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
movsbl 0x6(%rax),%eax
shl    $0x8,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
movsbl 0x7(%rax),%eax
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uint64Unpack>:
mov    %rdx,%rdi
jmp    1030 <uint64PackSize@plt>

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

LLVM IR (-O2):
define i64 @uint64Unpack(i8* nocapture readnone %0, i64 %1, i32* %2) {
%4 = tail call i64 @uint64PackSize(i32* %2)
ret i64 %4
}