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

/* Variables and functions */
int64_t unpacki64(uint8_t *buf) {
  uint64_t i2 = ((uint64_t)buf[0] << 56) | ((uint64_t)buf[1] << 48) |
                ((uint64_t)buf[2] << 40) | ((uint64_t)buf[3] << 32) |
                ((uint64_t)buf[4] << 24) | ((uint64_t)buf[5] << 16) |
                ((uint64_t)buf[6] << 8) | buf[7];
  int64_t i;
  if (i2 <= 0x7fffffffffffffffu) {
    i = i2;
  } else {
    i = -1 - (int64_t)(0xffffffffffffffffu - i2);
  }
  return i;
}


x86 assembly (clang, -O0):
<unpacki64>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    $0x38,%ecx
shl    %cl,%eax
mov    -0x8(%rbp),%rcx
mov    0x4(%rcx),%edx
mov    $0x30,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%edx
mov    $0x28,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0xc(%rcx),%edx
mov    $0x20,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x10(%rcx),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x14(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x18(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
or     0x1c(%rcx),%eax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movabs $0x7fffffffffffffff,%rcx
ff ff 7f
cmp    %rcx,%rax
ja     119b <unpacki64+0x9b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11b5 <unpacki64+0xb5>
movslq -0xc(%rbp),%rcx
mov    $0xffffffffffffffff,%rax
sub    %rcx,%rax
mov    %eax,%ecx
mov    $0xffffffff,%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpacki64>:
ret

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

LLVM IR (-O2):
define i32 @unpacki64(i32* nocapture readnone %0) {
ret i32 poison
}