#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*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_load_si128(void *);
int /*<<< orphan*/ _mm_store_si128(void *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
void xorr_sse2(uint8_t *region1, const uint8_t *region2, size_t length) {
  uint8_t *end;
  register __m128i in, out;
  for (end = region1 + length; region1 < end; region1 += 16, region2 += 16) {
    in = _mm_load_si128((void *)region2);
    out = _mm_load_si128((void *)region1);
    out = _mm_xor_si128(in, out);
    _mm_store_si128((void *)region1, out);
  }
}


x86 assembly (clang, -O0):
<xorr_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11b4 <xorr_sse2+0x84>
mov    -0x10(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <_mm_xor_si128@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1040 <_mm_store_si128@plt>
mov    -0x8(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <xorr_sse2+0x27>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xorr_sse2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdx,%rdx
jle    1182 <xorr_sse2+0x52>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    (%rdi,%rdx,4),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <_mm_load_si128@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <_mm_load_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <_mm_xor_si128@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <_mm_store_si128@plt>
add    $0x40,%rbx
add    $0x40,%r14
cmp    %r15,%rbx
jb     1150 <xorr_sse2+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @xorr_sse2(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%10 = load i32*, i32** %4
%11 = load i64, i64* %6
%12 = getelementptr inbounds i32, i32* %10, i64 %11
store i32* %12, i32** %7
br label %13
13: ; preds = %31, %3
%14 = load i32*, i32** %4
%15 = load i32*, i32** %7
%16 = icmp ult i32* %14, %15
br i1 %16, label %17, label %36
17: ; preds = %13
%18 = load i32*, i32** %5
%19 = bitcast i32* %18 to i8*
%20 = call i32 @_mm_load_si128(i8* %19)
store i32 %20, i32* %8
%21 = load i32*, i32** %4
%22 = bitcast i32* %21 to i8*
%23 = call i32 @_mm_load_si128(i8* %22)
store i32 %23, i32* %9
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = call i32 @_mm_xor_si128(i32 %24, i32 %25)
store i32 %26, i32* %9
%27 = load i32*, i32** %4
%28 = bitcast i32* %27 to i8*
%29 = load i32, i32* %9
%30 = call i32 @_mm_store_si128(i8* %28, i32 %29)
br label %31
31: ; preds = %17
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 16
store i32* %33, i32** %4
%34 = load i32*, i32** %5
%35 = getelementptr inbounds i32, i32* %34, i64 16
store i32* %35, i32** %5
br label %13
36: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @xorr_sse2(i32* %0, i32* %1, i64 %2) {
%4 = getelementptr inbounds i32, i32* %0, i64 %2
%5 = icmp sgt i64 %2, 0
br i1 %5, label %6, label %18
6: ; preds = %3, %6
%7 = phi i32* [ %15, %6 ], [ %0, %3 ]
%8 = phi i32* [ %16, %6 ], [ %1, %3 ]
%9 = bitcast i32* %8 to i8*
%10 = tail call i32 @_mm_load_si128(i8* %9)
%11 = bitcast i32* %7 to i8*
%12 = tail call i32 @_mm_load_si128(i8* %11)
%13 = tail call i32 @_mm_xor_si128(i32 %10, i32 %12)
%14 = tail call i32 @_mm_store_si128(i8* %11, i32 %13)
%15 = getelementptr inbounds i32, i32* %7, i64 16
%16 = getelementptr inbounds i32, i32* %8, i64 16
%17 = icmp ult i32* %15, %4
br i1 %17, label %6, label %18
18: ; preds = %6, %3
ret void
}