#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 /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ libcperciva_be32enc(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ const);
void be32enc_vect(uint8_t *dst, const uint32_t *src, size_t len) {
  size_t i;
  assert(len % 4 == 0);
  for (i = 0; i < len / 4; i++)
    libcperciva_be32enc(dst + i * 4, src[i]);
}


x86 assembly (clang, -O0):
<be32enc_vect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
shr    $0x2,%rcx
cmp    %rcx,%rax
jae    119e <be32enc_vect+0x7e>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
shl    $0x2,%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <libcperciva_be32enc@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1155 <be32enc_vect+0x35>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<be32enc_vect>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
xor    %edi,%edi
test   $0x3,%r15b
sete   %dil
call   1030 <assert@plt>
cmp    $0x4,%r15
jb     1169 <be32enc_vect+0x49>
shr    $0x2,%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,4),%esi
mov    %r12,%rdi
call   1040 <libcperciva_be32enc@plt>
add    $0x1,%rbx
add    $0x10,%r12
cmp    %rbx,%r15
jne    1150 <be32enc_vect+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @be32enc_vect(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
store i32* %0, i32** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = urem i64 %8, 4
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
store i64 0, i64* %7
br label %13
13: ; preds = %28, %3
%14 = load i64, i64* %7
%15 = load i64, i64* %6
%16 = udiv i64 %15, 4
%17 = icmp ult i64 %14, %16
br i1 %17, label %18, label %31
18: ; preds = %13
%19 = load i32*, i32** %4
%20 = load i64, i64* %7
%21 = mul i64 %20, 4
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32*, i32** %5
%24 = load i64, i64* %7
%25 = getelementptr inbounds i32, i32* %23, i64 %24
%26 = load i32, i32* %25
%27 = call i32 @libcperciva_be32enc(i32* %22, i32 %26)
br label %28
28: ; preds = %18
%29 = load i64, i64* %7
%30 = add i64 %29, 1
store i64 %30, i64* %7
br label %13
31: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @be32enc_vect(i32* %0, i32* nocapture %1, i64 %2) {
%4 = and i64 %2, 3
%5 = icmp eq i64 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = icmp ult i64 %2, 4
br i1 %8, label %20, label %9
9: ; preds = %3
%10 = lshr i64 %2, 2
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ %18, %11 ], [ 0, %9 ]
%13 = shl i64 %12, 2
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = getelementptr inbounds i32, i32* %1, i64 %12
%16 = load i32, i32* %15
%17 = tail call i32 @libcperciva_be32enc(i32* %14, i32 %16)
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %20, label %11
20: ; preds = %11, %3
ret void
}