#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 /*<<< orphan*/ be32enc(int *, int);
int test_be32enc() {
  uint8_t buf[4];
  be32enc(buf, 0x01020304U);
  if (buf[0] != 1 || buf[1] != 2 || buf[2] != 3 || buf[3] != 4)
    return -1;
  be32enc(buf, 0xffefdfcfU);
  if (buf[0] != 0xff || buf[1] != 0xef || buf[2] != 0xdf || buf[3] != 0xcf)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<test_be32enc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x20(%rbp),%rdi
mov    $0x1020304,%esi
call   1030 <be32enc@plt>
cmpl   $0x1,-0x20(%rbp)
jne    114e <test_be32enc+0x3e>
cmpl   $0x2,-0x1c(%rbp)
jne    114e <test_be32enc+0x3e>
cmpl   $0x3,-0x18(%rbp)
jne    114e <test_be32enc+0x3e>
cmpl   $0x4,-0x14(%rbp)
je     115a <test_be32enc+0x4a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11af <test_be32enc+0x9f>
lea    -0x20(%rbp),%rdi
mov    $0xffefdfcf,%esi
call   1030 <be32enc@plt>
cmpl   $0xff,-0x20(%rbp)
jne    119c <test_be32enc+0x8c>
cmpl   $0xef,-0x1c(%rbp)
jne    119c <test_be32enc+0x8c>
cmpl   $0xdf,-0x18(%rbp)
jne    119c <test_be32enc+0x8c>
cmpl   $0xcf,-0x14(%rbp)
je     11a8 <test_be32enc+0x98>
movl   $0xffffffff,-0x4(%rbp)
jmp    11af <test_be32enc+0x9f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_be32enc>:
sub    $0x18,%rsp
mov    %rsp,%rdi
mov    $0x1020304,%esi
call   1030 <be32enc@plt>
movdqa (%rsp),%xmm0
pcmpeqd 0xed2(%rip),%xmm0
movmskps %xmm0,%ecx
mov    $0xffffffff,%eax
cmp    $0xf,%ecx
je     1140 <test_be32enc+0x30>
add    $0x18,%rsp
ret
mov    %rsp,%rdi
mov    $0xffefdfcf,%esi
call   1030 <be32enc@plt>
movdqa (%rsp),%xmm0
pcmpeqd 0xeb6(%rip),%xmm0
movmskps %xmm0,%ecx
xor    %eax,%eax
cmp    $0xf,%ecx
setne  %al
neg    %eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @test_be32enc() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%4 = call i32 @be32enc(i32* %3, i32 16909060)
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%6 = load i32, i32* %5
%7 = icmp ne i32 %6, 1
br i1 %7, label %20, label %8
8: ; preds = %0
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%10 = load i32, i32* %9
%11 = icmp ne i32 %10, 2
br i1 %11, label %20, label %12
12: ; preds = %8
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%14 = load i32, i32* %13
%15 = icmp ne i32 %14, 3
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%18 = load i32, i32* %17
%19 = icmp ne i32 %18, 4
br i1 %19, label %20, label %21
20: ; preds = %16, %12, %8, %0
store i32 -1, i32* %1
br label %41
21: ; preds = %16
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%23 = call i32 @be32enc(i32* %22, i32 -1056817)
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%25 = load i32, i32* %24
%26 = icmp ne i32 %25, 255
br i1 %26, label %39, label %27
27: ; preds = %21
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%29 = load i32, i32* %28
%30 = icmp ne i32 %29, 239
br i1 %30, label %39, label %31
31: ; preds = %27
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%33 = load i32, i32* %32
%34 = icmp ne i32 %33, 223
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%37 = load i32, i32* %36
%38 = icmp ne i32 %37, 207
br i1 %38, label %39, label %40
39: ; preds = %35, %31, %27, %21
store i32 -1, i32* %1
br label %41
40: ; preds = %35
store i32 0, i32* %1
br label %41
41: ; preds = %40, %39, %20
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
define i32 @test_be32enc() {
%1 = alloca <4 x i32>
%2 = bitcast <4 x i32>* %1 to i8*
%3 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 0
%4 = call i32 @be32enc(i32* %3, i32 16909060)
%5 = load <4 x i32>, <4 x i32>* %1
%6 = freeze <4 x i32> %5
%7 = icmp ne <4 x i32> %6, <i32 1, i32 2, i32 3, i32 4>
%8 = bitcast <4 x i1> %7 to i4
%9 = icmp eq i4 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %0
%11 = call i32 @be32enc(i32* %3, i32 -1056817)
%12 = load <4 x i32>, <4 x i32>* %1
%13 = freeze <4 x i32> %12
%14 = icmp ne <4 x i32> %13, <i32 255, i32 239, i32 223, i32 207>
%15 = bitcast <4 x i1> %14 to i4
%16 = icmp ne i4 %15, 0
%17 = sext i1 %16 to i32
br label %18
18: ; preds = %10, %0
%19 = phi i32 [ -1, %0 ], [ %17, %10 ]
ret i32 %19
}