#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_set_epi8(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
             int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
             int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
             int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
             int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_srli_si128(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_store_si128(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ aes_enc_128(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
void jambu_tag_generation(__m128i *key, unsigned long long mlen,
                          unsigned char *c, __m128i *stateS, __m128i *stateR) {
  unsigned char t[16];
  __m128i c3 = _mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3);
  __m128i tmpT;
  aes_enc_128(stateS, key);
  *stateS = _mm_xor_si128(*stateS, _mm_srli_si128(*stateR, 8));
  *stateS = _mm_xor_si128(*stateS, c3);
  *stateR = _mm_xor_si128(*stateR, *stateS);
  aes_enc_128(stateS, key);
  tmpT = _mm_srli_si128(_mm_xor_si128(*stateS, *stateR), 8);
  tmpT = _mm_xor_si128(tmpT, *stateS);
  _mm_store_si128((__m128i *)t, tmpT);
  memcpy(c + mlen, t, 8);
}


x86 assembly (clang, -O0):
<jambu_tag_generation>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%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   $0x3,0x48(%rsp)
call   1060 <_mm_set_epi8@plt>
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <aes_enc_128@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <aes_enc_128@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%esi
call   1050 <_mm_store_si128@plt>
mov    -0x18(%rbp),%rdi
add    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jambu_tag_generation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r12
mov    %rcx,%rbx
mov    %rdx,0x8(%rsp)
mov    %rsi,%r15
mov    %rdi,%r13
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x3
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
call   1060 <_mm_set_epi8@plt>
add    $0x50,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <aes_enc_128@plt>
mov    (%rbx),%r14d
mov    (%r12),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
mov    %eax,%edi
mov    %ebp,%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
mov    (%r12),%edi
mov    %eax,%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,(%r12)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <aes_enc_128@plt>
mov    (%rbx),%edi
mov    (%r12),%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    (%rbx),%esi
mov    %eax,%edi
call   1080 <_mm_xor_si128@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <_mm_store_si128@plt>
add    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1070 <memcpy@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @jambu_tag_generation(i32* %0, i64 %1, i8* %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [16 x i8]
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%14 = call i32 @_mm_set_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 3)
store i32 %14, i32* %12
%15 = load i32*, i32** %9
%16 = load i32*, i32** %6
%17 = call i32 @aes_enc_128(i32* %15, i32* %16)
%18 = load i32*, i32** %9
%19 = load i32, i32* %18
%20 = load i32*, i32** %10
%21 = load i32, i32* %20
%22 = call i32 @_mm_srli_si128(i32 %21, i32 8)
%23 = call i32 @_mm_xor_si128(i32 %19, i32 %22)
%24 = load i32*, i32** %9
store i32 %23, i32* %24
%25 = load i32*, i32** %9
%26 = load i32, i32* %25
%27 = load i32, i32* %12
%28 = call i32 @_mm_xor_si128(i32 %26, i32 %27)
%29 = load i32*, i32** %9
store i32 %28, i32* %29
%30 = load i32*, i32** %10
%31 = load i32, i32* %30
%32 = load i32*, i32** %9
%33 = load i32, i32* %32
%34 = call i32 @_mm_xor_si128(i32 %31, i32 %33)
%35 = load i32*, i32** %10
store i32 %34, i32* %35
%36 = load i32*, i32** %9
%37 = load i32*, i32** %6
%38 = call i32 @aes_enc_128(i32* %36, i32* %37)
%39 = load i32*, i32** %9
%40 = load i32, i32* %39
%41 = load i32*, i32** %10
%42 = load i32, i32* %41
%43 = call i32 @_mm_xor_si128(i32 %40, i32 %42)
%44 = call i32 @_mm_srli_si128(i32 %43, i32 8)
store i32 %44, i32* %13
%45 = load i32, i32* %13
%46 = load i32*, i32** %9
%47 = load i32, i32* %46
%48 = call i32 @_mm_xor_si128(i32 %45, i32 %47)
store i32 %48, i32* %13
%49 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%50 = bitcast i8* %49 to i32*
%51 = load i32, i32* %13
%52 = call i32 @_mm_store_si128(i32* %50, i32 %51)
%53 = load i8*, i8** %8
%54 = load i64, i64* %7
%55 = getelementptr inbounds i8, i8* %53, i64 %54
%56 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%57 = call i32 @memcpy(i8* %55, i8* %56, i32 8)
ret void
}

LLVM IR (-O2):
define void @jambu_tag_generation(i32* %0, i64 %1, i8* %2, i32* %3, i32* nocapture %4) {
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%8 = tail call i32 @_mm_set_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 3)
%9 = tail call i32 @aes_enc_128(i32* %3, i32* %0)
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = tail call i32 @_mm_srli_si128(i32 %11, i32 8)
%13 = tail call i32 @_mm_xor_si128(i32 %10, i32 %12)
store i32 %13, i32* %3
%14 = tail call i32 @_mm_xor_si128(i32 %13, i32 %8)
store i32 %14, i32* %3
%15 = load i32, i32* %4
%16 = tail call i32 @_mm_xor_si128(i32 %15, i32 %14)
store i32 %16, i32* %4
%17 = tail call i32 @aes_enc_128(i32* %3, i32* %0)
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = tail call i32 @_mm_xor_si128(i32 %18, i32 %19)
%21 = tail call i32 @_mm_srli_si128(i32 %20, i32 8)
%22 = load i32, i32* %3
%23 = tail call i32 @_mm_xor_si128(i32 %21, i32 %22)
%24 = bitcast [16 x i8]* %6 to i32*
%25 = call i32 @_mm_store_si128(i32* %24, i32 %23)
%26 = getelementptr inbounds i8, i8* %2, i64 %1
%27 = call i32 @memcpy(i8* %26, i8* %7, i32 8)
ret void
}