#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 be32dec(int *);
int test_be32dec() {
  uint8_t buf1[] = {0x01, 0x02, 0x03, 0x04};
  uint8_t buf2[] = {0xff, 0xef, 0xdf, 0xcf};
  if (be32dec(buf1) != 0x01020304U)
    return -1;
  if (be32dec(buf2) != 0xffefdfcfU)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<test_be32dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <be32dec@plt>
cmp    $0x1020304,%eax
je     1164 <test_be32dec+0x54>
movl   $0xffffffff,-0x4(%rbp)
jmp    118b <test_be32dec+0x7b>
lea    -0x30(%rbp),%rdi
call   1030 <be32dec@plt>
cmp    $0xffefdfcf,%eax
je     1184 <test_be32dec+0x74>
movl   $0xffffffff,-0x4(%rbp)
jmp    118b <test_be32dec+0x7b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_be32dec>:
sub    $0x28,%rsp
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <be32dec@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x1020304,%ecx
jne    115b <test_be32dec+0x4b>
mov    %rsp,%rdi
call   1030 <be32dec@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffefdfcf,%ecx
setne  %al
neg    %eax
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
@__const.test_be32dec.buf1 = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@__const.test_be32dec.buf2 = [4 x i32] [i32 255, i32 239, i32 223, i32 207]
define i32 @test_be32dec() {
%1 = alloca [4 x i32]
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast [4 x i32]* %2 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = call i32 @be32dec(i32* %5)
%7 = icmp eq i32 %6, 16909060
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%10 = call i32 @be32dec(i32* %9)
%11 = icmp ne i32 %10, -1056817
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %8, %0
%14 = phi i32 [ -1, %0 ], [ %12, %8 ]
ret i32 %14
}