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

/* Variables and functions */
int be64dec(int *);
int test_be64dec() {
  uint8_t buf1[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
  uint8_t buf2[] = {0xff, 0xef, 0xdf, 0xcf, 0xbf, 0xaf, 0x9f, 0xaf};
  if (be64dec(buf1) != 0x0102030405060708ULL)
    return -1;
  if (be64dec(buf2) != 0xffefdfcfbfaf9fafULL)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<test_be64dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed5(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xecf(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xecc(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <be64dec@plt>
cltq
movabs $0x102030405060708,%rcx
03 02 01
cmp    %rcx,%rax
je     119a <test_be64dec+0x8a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cb <test_be64dec+0xbb>
lea    -0x50(%rbp),%rdi
call   1030 <be64dec@plt>
cltq
movabs $0xffefdfcfbfaf9faf,%rcx
df ef ff
cmp    %rcx,%rax
je     11c4 <test_be64dec+0xb4>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cb <test_be64dec+0xbb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_be64dec>:
sub    $0x28,%rsp
movaps 0xef5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1030 <be64dec@plt>
mov    $0xffffffff,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.test_be64dec.buf1 = [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8]
@__const.test_be64dec.buf2 = [8 x i32] [i32 255, i32 239, i32 223, i32 207, i32 191, i32 175, i32 159, i32 175]
define i32 @test_be64dec() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca [8 x i32]
%4 = bitcast [8 x i32]* %2 to i8*
%5 = bitcast [8 x i32]* %3 to i8*
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%7 = call i32 @be64dec(i32* %6)
%8 = sext i32 %7 to i64
%9 = icmp ne i64 %8, 72623859790382856
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 -1, i32* %1
br label %18
11: ; preds = %0
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%13 = call i32 @be64dec(i32* %12)
%14 = sext i32 %13 to i64
%15 = icmp ne i64 %14, -4538991236898897
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 -1, i32* %1
br label %18
17: ; preds = %11
store i32 0, i32* %1
br label %18
18: ; preds = %17, %16, %10
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@__const.test_be64dec.buf1 = [8 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8]
define i32 @test_be64dec() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%4 = call i32 @be64dec(i32* %3)
ret i32 -1
}