#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_add_epi64(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_setr_epi8(int, int /*<<< orphan*/, int, int, int, int,
                                 int, int, int, int, int, int, int, int, int,
                                 int);
int /*<<< orphan*/ _mm_setzero_si128();
int /*<<< orphan*/ _mm_shuffle_epi8(int /*<<< orphan*/, int /*<<< orphan*/);
void prepare_tweak_counters(__m128i *tweak_ctrs) {
  __m128i tmp = _mm_setr_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
  for (size_t round = 0; round < 15; ++round) {
    tweak_ctrs[round * 8] = _mm_setzero_si128();
    tweak_ctrs[round * 8 + 1] = _mm_add_epi64(tweak_ctrs[round * 8 + 0], tmp);
    tweak_ctrs[round * 8 + 2] = _mm_add_epi64(tweak_ctrs[round * 8 + 1], tmp);
    tweak_ctrs[round * 8 + 3] = _mm_add_epi64(tweak_ctrs[round * 8 + 2], tmp);
    tweak_ctrs[round * 8 + 4] = _mm_add_epi64(tweak_ctrs[round * 8 + 3], tmp);
    tweak_ctrs[round * 8 + 5] = _mm_add_epi64(tweak_ctrs[round * 8 + 4], tmp);
    tweak_ctrs[round * 8 + 6] = _mm_add_epi64(tweak_ctrs[round * 8 + 5], tmp);
    tweak_ctrs[round * 8 + 7] = _mm_add_epi64(tweak_ctrs[round * 8 + 6], tmp);
    tmp = _mm_shuffle_epi8(tmp, _mm_setr_epi8(7, 0, 13, 10, 11, 4, 1, 14, 15, 8,
                                              5, 2, 3, 12, 9, 6));
  }
}


x86 assembly (clang, -O0):
<prepare_tweak_counters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
xor    %r9d,%r9d
mov    %r9d,%edi
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
movl   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x28(%rsp)
movl   $0x0,0x30(%rsp)
movl   $0x0,0x38(%rsp)
movl   $0x0,0x40(%rsp)
movl   $0x1,0x48(%rsp)
call   1050 <_mm_setr_epi8@plt>
mov    %eax,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0xf,-0x18(%rbp)
jae    139a <prepare_tweak_counters+0x25a>
mov    $0x0,%al
call   1030 <_mm_setzero_si128@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0xc(%rbp),%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    %edx,0x4(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    0x4(%rax,%rcx,4),%edi
mov    -0xc(%rbp),%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    %edx,0x8(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    0x8(%rax,%rcx,4),%edi
mov    -0xc(%rbp),%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    %edx,0xc(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    0xc(%rax,%rcx,4),%edi
mov    -0xc(%rbp),%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    %edx,0x10(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    0x10(%rax,%rcx,4),%edi
mov    -0xc(%rbp),%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    %edx,0x14(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    0x14(%rax,%rcx,4),%edi
mov    -0xc(%rbp),%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    %edx,0x18(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    0x18(%rax,%rcx,4),%edi
mov    -0xc(%rbp),%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x3,%rcx
mov    %edx,0x1c(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x7,%edi
xor    %esi,%esi
mov    $0xd,%edx
mov    $0xa,%ecx
mov    $0xb,%r8d
mov    $0x4,%r9d
movl   $0x1,(%rsp)
movl   $0xe,0x8(%rsp)
movl   $0xf,0x10(%rsp)
movl   $0x8,0x18(%rsp)
movl   $0x5,0x20(%rsp)
movl   $0x2,0x28(%rsp)
movl   $0x3,0x30(%rsp)
movl   $0xc,0x38(%rsp)
movl   $0x9,0x40(%rsp)
movl   $0x6,0x48(%rsp)
call   1050 <_mm_setr_epi8@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1040 <_mm_shuffle_epi8@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11bd <prepare_tweak_counters+0x7d>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepare_tweak_counters>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x1
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
call   1050 <_mm_setr_epi8@plt>
add    $0x50,%rsp
mov    %eax,%ebp
mov    $0x1c,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <_mm_setzero_si128@plt>
mov    %eax,-0x1c(%r14,%rbx,1)
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,-0x18(%r14,%rbx,1)
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,-0x14(%r14,%rbx,1)
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,-0x10(%r14,%rbx,1)
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,-0xc(%r14,%rbx,1)
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,-0x8(%r14,%rbx,1)
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,-0x4(%r14,%rbx,1)
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,(%r14,%rbx,1)
mov    $0x7,%edi
xor    %esi,%esi
mov    $0xd,%edx
mov    $0xa,%ecx
mov    $0xb,%r8d
mov    $0x4,%r9d
push   $0x6
push   $0x9
push   $0xc
push   $0x3
push   $0x2
push   $0x5
push   $0x8
push   $0xf
push   $0xe
push   $0x1
call   1050 <_mm_setr_epi8@plt>
add    $0x50,%rsp
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <_mm_shuffle_epi8@plt>
mov    %eax,%ebp
add    $0x20,%rbx
cmp    $0x1fc,%rbx
jne    1180 <prepare_tweak_counters+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @prepare_tweak_counters(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i64
store i32* %0, i32** %2
%5 = call i32 @_mm_setr_epi8(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1)
store i32 %5, i32* %3
store i64 0, i64* %4
br label %6
6: ; preds = %109, %1
%7 = load i64, i64* %4
%8 = icmp ult i64 %7, 15
br i1 %8, label %9, label %112
9: ; preds = %6
%10 = call i32 (...) @_mm_setzero_si128()
%11 = load i32*, i32** %2
%12 = load i64, i64* %4
%13 = mul i64 %12, 8
%14 = getelementptr inbounds i32, i32* %11, i64 %13
store i32 %10, i32* %14
%15 = load i32*, i32** %2
%16 = load i64, i64* %4
%17 = mul i64 %16, 8
%18 = add i64 %17, 0
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %3
%22 = call i32 @_mm_add_epi64(i32 %20, i32 %21)
%23 = load i32*, i32** %2
%24 = load i64, i64* %4
%25 = mul i64 %24, 8
%26 = add i64 %25, 1
%27 = getelementptr inbounds i32, i32* %23, i64 %26
store i32 %22, i32* %27
%28 = load i32*, i32** %2
%29 = load i64, i64* %4
%30 = mul i64 %29, 8
%31 = add i64 %30, 1
%32 = getelementptr inbounds i32, i32* %28, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* %3
%35 = call i32 @_mm_add_epi64(i32 %33, i32 %34)
%36 = load i32*, i32** %2
%37 = load i64, i64* %4
%38 = mul i64 %37, 8
%39 = add i64 %38, 2
%40 = getelementptr inbounds i32, i32* %36, i64 %39
store i32 %35, i32* %40
%41 = load i32*, i32** %2
%42 = load i64, i64* %4
%43 = mul i64 %42, 8
%44 = add i64 %43, 2
%45 = getelementptr inbounds i32, i32* %41, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %3
%48 = call i32 @_mm_add_epi64(i32 %46, i32 %47)
%49 = load i32*, i32** %2
%50 = load i64, i64* %4
%51 = mul i64 %50, 8
%52 = add i64 %51, 3
%53 = getelementptr inbounds i32, i32* %49, i64 %52
store i32 %48, i32* %53
%54 = load i32*, i32** %2
%55 = load i64, i64* %4
%56 = mul i64 %55, 8
%57 = add i64 %56, 3
%58 = getelementptr inbounds i32, i32* %54, i64 %57
%59 = load i32, i32* %58
%60 = load i32, i32* %3
%61 = call i32 @_mm_add_epi64(i32 %59, i32 %60)
%62 = load i32*, i32** %2
%63 = load i64, i64* %4
%64 = mul i64 %63, 8
%65 = add i64 %64, 4
%66 = getelementptr inbounds i32, i32* %62, i64 %65
store i32 %61, i32* %66
%67 = load i32*, i32** %2
%68 = load i64, i64* %4
%69 = mul i64 %68, 8
%70 = add i64 %69, 4
%71 = getelementptr inbounds i32, i32* %67, i64 %70
%72 = load i32, i32* %71
%73 = load i32, i32* %3
%74 = call i32 @_mm_add_epi64(i32 %72, i32 %73)
%75 = load i32*, i32** %2
%76 = load i64, i64* %4
%77 = mul i64 %76, 8
%78 = add i64 %77, 5
%79 = getelementptr inbounds i32, i32* %75, i64 %78
store i32 %74, i32* %79
%80 = load i32*, i32** %2
%81 = load i64, i64* %4
%82 = mul i64 %81, 8
%83 = add i64 %82, 5
%84 = getelementptr inbounds i32, i32* %80, i64 %83
%85 = load i32, i32* %84
%86 = load i32, i32* %3
%87 = call i32 @_mm_add_epi64(i32 %85, i32 %86)
%88 = load i32*, i32** %2
%89 = load i64, i64* %4
%90 = mul i64 %89, 8
%91 = add i64 %90, 6
%92 = getelementptr inbounds i32, i32* %88, i64 %91
store i32 %87, i32* %92
%93 = load i32*, i32** %2
%94 = load i64, i64* %4
%95 = mul i64 %94, 8
%96 = add i64 %95, 6
%97 = getelementptr inbounds i32, i32* %93, i64 %96
%98 = load i32, i32* %97
%99 = load i32, i32* %3
%100 = call i32 @_mm_add_epi64(i32 %98, i32 %99)
%101 = load i32*, i32** %2
%102 = load i64, i64* %4
%103 = mul i64 %102, 8
%104 = add i64 %103, 7
%105 = getelementptr inbounds i32, i32* %101, i64 %104
store i32 %100, i32* %105
%106 = load i32, i32* %3
%107 = call i32 @_mm_setr_epi8(i32 7, i32 0, i32 13, i32 10, i32 11, i32 4, i32 1, i32 14, i32 15, i32 8, i32 5, i32 2, i32 3, i32 12, i32 9, i32 6)
%108 = call i32 @_mm_shuffle_epi8(i32 %106, i32 %107)
store i32 %108, i32* %3
br label %109
109: ; preds = %9
%110 = load i64, i64* %4
%111 = add i64 %110, 1
store i64 %111, i64* %4
br label %6
112: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @prepare_tweak_counters(i32* nocapture writeonly %0) {
%2 = tail call i32 @_mm_setr_epi8(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1)
br label %4
3: ; preds = %4
ret void
4: ; preds = %1, %4
%5 = phi i64 [ 0, %1 ], [ %33, %4 ]
%6 = phi i32 [ %2, %1 ], [ %32, %4 ]
%7 = tail call i32 (...) @_mm_setzero_si128()
%8 = shl nuw nsw i64 %5, 3
%9 = getelementptr inbounds i32, i32* %0, i64 %8
store i32 %7, i32* %9
%10 = tail call i32 @_mm_add_epi64(i32 %7, i32 %6)
%11 = or i64 %8, 1
%12 = getelementptr inbounds i32, i32* %0, i64 %11
store i32 %10, i32* %12
%13 = tail call i32 @_mm_add_epi64(i32 %10, i32 %6)
%14 = or i64 %8, 2
%15 = getelementptr inbounds i32, i32* %0, i64 %14
store i32 %13, i32* %15
%16 = tail call i32 @_mm_add_epi64(i32 %13, i32 %6)
%17 = or i64 %8, 3
%18 = getelementptr inbounds i32, i32* %0, i64 %17
store i32 %16, i32* %18
%19 = tail call i32 @_mm_add_epi64(i32 %16, i32 %6)
%20 = or i64 %8, 4
%21 = getelementptr inbounds i32, i32* %0, i64 %20
store i32 %19, i32* %21
%22 = tail call i32 @_mm_add_epi64(i32 %19, i32 %6)
%23 = or i64 %8, 5
%24 = getelementptr inbounds i32, i32* %0, i64 %23
store i32 %22, i32* %24
%25 = tail call i32 @_mm_add_epi64(i32 %22, i32 %6)
%26 = or i64 %8, 6
%27 = getelementptr inbounds i32, i32* %0, i64 %26
store i32 %25, i32* %27
%28 = tail call i32 @_mm_add_epi64(i32 %25, i32 %6)
%29 = or i64 %8, 7
%30 = getelementptr inbounds i32, i32* %0, i64 %29
store i32 %28, i32* %30
%31 = tail call i32 @_mm_setr_epi8(i32 7, i32 0, i32 13, i32 10, i32 11, i32 4, i32 1, i32 14, i32 15, i32 8, i32 5, i32 2, i32 3, i32 12, i32 9, i32 6)
%32 = tail call i32 @_mm_shuffle_epi8(i32 %6, i32 %31)
%33 = add nuw nsw i64 %5, 1
%34 = icmp eq i64 %33, 15
br i1 %34, label %3, label %4
}