#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_setzero_si128();
int /*<<< orphan*/ xor_and_multiply_word(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *);
void clnh_full_block(__m128i *k, __m128i *m, __m128i *sum1, __m128i *sum2) {
  *sum1 = _mm_setzero_si128();
  *sum2 = _mm_setzero_si128();
  size_t len = 1024;
  while (len >= 32) {
    xor_and_multiply_word(m, k, sum1);
    xor_and_multiply_word(m, k + 1, sum2);
    xor_and_multiply_word(m + 1, k + 1, sum1);
    xor_and_multiply_word(m + 1, k + 2, sum2);
    len -= 32;
    m += 2;
    k += 2;
  };
}


x86 assembly (clang, -O0):
<clnh_full_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x0,%al
call   1030 <_mm_setzero_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <_mm_setzero_si128@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movq   $0x400,-0x28(%rbp)
cmpq   $0x20,-0x28(%rbp)
jb     11ea <clnh_full_block+0xca>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <xor_and_multiply_word@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
mov    -0x20(%rbp),%rdx
call   1040 <xor_and_multiply_word@plt>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
mov    -0x18(%rbp),%rdx
call   1040 <xor_and_multiply_word@plt>
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
mov    -0x8(%rbp),%rsi
add    $0x8,%rsi
mov    -0x20(%rbp),%rdx
call   1040 <xor_and_multiply_word@plt>
mov    -0x28(%rbp),%rax
sub    $0x20,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    115e <clnh_full_block+0x3e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clnh_full_block>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <_mm_setzero_si128@plt>
mov    %rbp,0x10(%rsp)
mov    %eax,0x0(%rbp)
xor    %eax,%eax
call   1030 <_mm_setzero_si128@plt>
mov    %r14,0x8(%rsp)
mov    %eax,(%r14)
mov    $0xfffffffffffffc00,%r14
mov    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <xor_and_multiply_word@plt>
lea    0x4(%rbx),%r13
mov    %r12,%rdi
mov    %r13,%rsi
mov    0x8(%rsp),%rdx
call   1040 <xor_and_multiply_word@plt>
lea    0x4(%r12),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1040 <xor_and_multiply_word@plt>
add    $0x8,%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    0x8(%rsp),%rdx
call   1040 <xor_and_multiply_word@plt>
add    $0x8,%r12
add    $0x20,%r14
jne    1170 <clnh_full_block+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @clnh_full_block(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i64
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = call i32 (...) @_mm_setzero_si128()
%11 = load i32*, i32** %7
store i32 %10, i32* %11
%12 = call i32 (...) @_mm_setzero_si128()
%13 = load i32*, i32** %8
store i32 %12, i32* %13
store i64 1024, i64* %9
br label %14
14: ; preds = %17, %4
%15 = load i64, i64* %9
%16 = icmp uge i64 %15, 32
br i1 %16, label %17, label %45
17: ; preds = %14
%18 = load i32*, i32** %6
%19 = load i32*, i32** %5
%20 = load i32*, i32** %7
%21 = call i32 @xor_and_multiply_word(i32* %18, i32* %19, i32* %20)
%22 = load i32*, i32** %6
%23 = load i32*, i32** %5
%24 = getelementptr inbounds i32, i32* %23, i64 1
%25 = load i32*, i32** %8
%26 = call i32 @xor_and_multiply_word(i32* %22, i32* %24, i32* %25)
%27 = load i32*, i32** %6
%28 = getelementptr inbounds i32, i32* %27, i64 1
%29 = load i32*, i32** %5
%30 = getelementptr inbounds i32, i32* %29, i64 1
%31 = load i32*, i32** %7
%32 = call i32 @xor_and_multiply_word(i32* %28, i32* %30, i32* %31)
%33 = load i32*, i32** %6
%34 = getelementptr inbounds i32, i32* %33, i64 1
%35 = load i32*, i32** %5
%36 = getelementptr inbounds i32, i32* %35, i64 2
%37 = load i32*, i32** %8
%38 = call i32 @xor_and_multiply_word(i32* %34, i32* %36, i32* %37)
%39 = load i64, i64* %9
%40 = sub i64 %39, 32
store i64 %40, i64* %9
%41 = load i32*, i32** %6
%42 = getelementptr inbounds i32, i32* %41, i64 2
store i32* %42, i32** %6
%43 = load i32*, i32** %5
%44 = getelementptr inbounds i32, i32* %43, i64 2
store i32* %44, i32** %5
br label %14
45: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @clnh_full_block(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = tail call i32 (...) @_mm_setzero_si128()
store i32 %5, i32* %2
%6 = tail call i32 (...) @_mm_setzero_si128()
store i32 %6, i32* %3
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 1024, %4 ], [ %18, %7 ]
%9 = phi i32* [ %0, %4 ], [ %16, %7 ]
%10 = phi i32* [ %1, %4 ], [ %19, %7 ]
%11 = tail call i32 @xor_and_multiply_word(i32* %10, i32* %9, i32* %2)
%12 = getelementptr inbounds i32, i32* %9, i64 1
%13 = tail call i32 @xor_and_multiply_word(i32* %10, i32* %12, i32* %3)
%14 = getelementptr inbounds i32, i32* %10, i64 1
%15 = tail call i32 @xor_and_multiply_word(i32* %14, i32* %12, i32* %2)
%16 = getelementptr inbounds i32, i32* %9, i64 2
%17 = tail call i32 @xor_and_multiply_word(i32* %14, i32* %16, i32* %3)
%18 = add nsw i64 %8, -32
%19 = getelementptr inbounds i32, i32* %10, i64 2
%20 = icmp eq i64 %18, 0
br i1 %20, label %21, label %7
21: ; preds = %7
ret void
}