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

/* Variables and functions */
int /*<<< orphan*/ _mm_loadu_si128(int /*<<< orphan*/ *);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/ const, int /*<<< orphan*/);
void load_xor_store_n(__m128i *out, const __m128i *in, const __m128i *states,
                      const size_t num_blocks) {
  for (size_t i = 0; i < num_blocks; ++i) {
    out[i] = _mm_xor_si128(states[i], _mm_loadu_si128((__m128i *)in + i));
  }
}


x86 assembly (clang, -O0):
<load_xor_store_n>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1198 <load_xor_store_n+0x78>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1040 <_mm_loadu_si128@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1030 <_mm_xor_si128@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1140 <load_xor_store_n+0x20>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_xor_store_n>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rcx,%rcx
je     1167 <load_xor_store_n+0x47>
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r12
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%r14,%rbp,4),%r13d
mov    %rbx,%rdi
call   1040 <_mm_loadu_si128@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1030 <_mm_xor_si128@plt>
mov    %eax,(%r12,%rbp,4)
add    $0x1,%rbp
add    $0x4,%rbx
cmp    %rbp,%r15
jne    1140 <load_xor_store_n+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @load_xor_store_n(i32* nocapture writeonly %0, i32* %1, i32* nocapture %2, i64 %3) {
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %7
6: ; preds = %7, %4
ret void
7: ; preds = %4, %7
%8 = phi i64 [ %15, %7 ], [ 0, %4 ]
%9 = getelementptr inbounds i32, i32* %2, i64 %8
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %1, i64 %8
%12 = tail call i32 @_mm_loadu_si128(i32* %11)
%13 = tail call i32 @_mm_xor_si128(i32 %10, i32 %12)
%14 = getelementptr inbounds i32, i32* %0, i64 %8
store i32 %13, i32* %14
%15 = add nuw i64 %8, 1
%16 = icmp eq i64 %15, %3
br i1 %16, label %6, label %7
}