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

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rotate(int, int, int);
void concatenate(uint8_t arr[], uint32_t size) {
  if (size % 4 != 0) {
    printf("Size must be a multiple of 4\n");
    return;
  }
  uint32_t i, value = 0;
  for (i = 0; i < size; i++) {
    value = value ^ arr[i];
    if (i % 4 == 3) {
      rotate(value, 16, 0x00);
      value = 0;
    } else
      value = value << 8;
  }
}


x86 assembly (clang, -O0):
<concatenate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1154 <concatenate+0x34>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
jmp    11ca <concatenate+0xaa>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ca <concatenate+0xaa>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
xor    (%rcx,%rdx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    11ae <concatenate+0x8e>
mov    -0x14(%rbp),%edi
mov    $0x10,%esi
xor    %edx,%edx
call   1040 <rotate@plt>
movl   $0x0,-0x14(%rbp)
jmp    11b7 <concatenate+0x97>
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <concatenate+0x9c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1162 <concatenate+0x42>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concatenate>:
test   $0x3,%sil
je     1132 <concatenate+0x12>
lea    0xed3(%rip),%rdi
jmp    1030 <puts@plt>
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    1178 <concatenate+0x58>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
xor    %edi,%edi
jmp    115c <concatenate+0x3c>
nopw   0x0(%rax,%rax,1)
shl    $0x8,%edi
add    $0x1,%rbx
cmp    %rbx,%r15
je     1178 <concatenate+0x58>
xor    (%r14,%rbx,4),%edi
mov    %ebx,%eax
not    %eax
test   $0x3,%al
jne    1150 <concatenate+0x30>
mov    $0x10,%esi
xor    %edx,%edx
call   1040 <rotate@plt>
xor    %edi,%edi
jmp    1153 <concatenate+0x33>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Size must be a multiple of 4\0A\00"
define void @concatenate(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = srem i32 %7, 4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %38
12: ; preds = %2
store i32 0, i32* %6
store i32 0, i32* %5
br label %13
13: ; preds = %35, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %38
17: ; preds = %13
%18 = load i32, i32* %6
%19 = load i32*, i32** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = xor i32 %18, %23
store i32 %24, i32* %6
%25 = load i32, i32* %5
%26 = srem i32 %25, 4
%27 = icmp eq i32 %26, 3
br i1 %27, label %28, label %31
28: ; preds = %17
%29 = load i32, i32* %6
%30 = call i32 @rotate(i32 %29, i32 16, i32 0)
store i32 0, i32* %6
br label %34
31: ; preds = %17
%32 = load i32, i32* %6
%33 = shl i32 %32, 8
store i32 %33, i32* %6
br label %34
34: ; preds = %31, %28
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %13
38: ; preds = %10, %13
ret void
}

LLVM IR (-O2):
@str = [29 x i8] c"Size must be a multiple of 4\00"
define void @concatenate(i32* nocapture %0, i32 %1) {
%3 = and i32 %1, 3
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %27
7: ; preds = %5
%8 = zext i32 %1 to i64
br label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %27
11: ; preds = %7, %23
%12 = phi i64 [ 0, %7 ], [ %25, %23 ]
%13 = phi i32 [ 0, %7 ], [ %24, %23 ]
%14 = getelementptr inbounds i32, i32* %0, i64 %12
%15 = load i32, i32* %14
%16 = xor i32 %15, %13
%17 = and i64 %12, 3
%18 = icmp eq i64 %17, 3
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = tail call i32 @rotate(i32 %16, i32 16, i32 0)
br label %23
21: ; preds = %11
%22 = shl i32 %16, 8
br label %23
23: ; preds = %19, %21
%24 = phi i32 [ 0, %19 ], [ %22, %21 ]
%25 = add nuw nsw i64 %12, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %11
27: ; preds = %23, %5, %9
ret void
}