#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(unsigned char const, unsigned char const,
                                unsigned char const, unsigned char const,
                                unsigned char const, unsigned char const,
                                unsigned char const, unsigned char const,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_srli_si128(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_storel_epi64(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ aes_enc_128(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
void jambu_enc_aut_msg_step(__m128i *key, const unsigned char *plaintextblk,
                            unsigned char *ciphertextblk, __m128i *stateS,
                            __m128i *stateR) {
  __m128i msgtmp =
      _mm_set_epi8(plaintextblk[7], plaintextblk[6], plaintextblk[5],
                   plaintextblk[4], plaintextblk[3], plaintextblk[2],
                   plaintextblk[1], plaintextblk[0], 0, 0, 0, 0, 0, 0, 0, 0);
  __m128i tmp = _mm_srli_si128(msgtmp, 8);
  aes_enc_128(stateS, key);
  *stateS = _mm_xor_si128(*stateS, _mm_srli_si128(*stateR, 8));
  *stateS = _mm_xor_si128(*stateS, msgtmp);
  tmp = _mm_xor_si128(tmp, *stateS);
  _mm_storel_epi64((__m128i *)ciphertextblk, tmp);
  *stateR = _mm_xor_si128(*stateS, *stateR);
}


x86 assembly (clang, -O0):
<jambu_enc_aut_msg_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x7(%rax),%dil
mov    -0x10(%rbp),%rax
mov    0x6(%rax),%sil
mov    -0x10(%rbp),%rax
mov    0x5(%rax),%dl
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x10(%rbp),%rax
mov    0x3(%rax),%r8b
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%r9b
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%r10b
mov    -0x10(%rbp),%rax
xor    %r11d,%r11d
movzbl %dil,%edi
movzbl %sil,%esi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %r10b,%r10d
mov    %r10d,(%rsp)
movzbl (%rax),%eax
mov    %eax,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   $0x0,0x48(%rsp)
call   1050 <_mm_set_epi8@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <aes_enc_128@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1060 <_mm_storel_epi64@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jambu_enc_aut_msg_step>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,(%rsp)
mov    %rdi,%r12
movzbl 0x7(%rsi),%edi
movzbl 0x6(%rsi),%eax
movzbl 0x5(%rsi),%edx
movzbl 0x4(%rsi),%ecx
movzbl 0x3(%rsi),%r8d
movzbl 0x2(%rsi),%r9d
movzbl 0x1(%rsi),%ebp
movzbl (%rsi),%ebx
mov    %eax,%esi
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   %rbx
push   %rbp
call   1050 <_mm_set_epi8@plt>
add    $0x50,%rsp
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %eax,%r13d
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <aes_enc_128@plt>
mov    (%r15),%ebx
mov    (%r14),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,(%r15)
mov    %eax,%edi
mov    %ebp,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,(%r15)
mov    %r13d,%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    (%rsp),%rdi
mov    %eax,%esi
call   1060 <_mm_storel_epi64@plt>
mov    (%r15),%edi
mov    (%r14),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @jambu_enc_aut_msg_step(i32* %0, i8* %1, i8* %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%13 = load i8*, i8** %7
%14 = getelementptr inbounds i8, i8* %13, i64 7
%15 = load i8, i8* %14
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i64 6
%18 = load i8, i8* %17
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 5
%21 = load i8, i8* %20
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i64 4
%24 = load i8, i8* %23
%25 = load i8*, i8** %7
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = load i8, i8* %26
%28 = load i8*, i8** %7
%29 = getelementptr inbounds i8, i8* %28, i64 2
%30 = load i8, i8* %29
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = call i32 @_mm_set_epi8(i8 zeroext %15, i8 zeroext %18, i8 zeroext %21, i8 zeroext %24, i8 zeroext %27, i8 zeroext %30, i8 zeroext %33, i8 zeroext %36, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
store i32 %37, i32* %11
%38 = load i32, i32* %11
%39 = call i32 @_mm_srli_si128(i32 %38, i32 8)
store i32 %39, i32* %12
%40 = load i32*, i32** %9
%41 = load i32*, i32** %6
%42 = call i32 @aes_enc_128(i32* %40, i32* %41)
%43 = load i32*, i32** %9
%44 = load i32, i32* %43
%45 = load i32*, i32** %10
%46 = load i32, i32* %45
%47 = call i32 @_mm_srli_si128(i32 %46, i32 8)
%48 = call i32 @_mm_xor_si128(i32 %44, i32 %47)
%49 = load i32*, i32** %9
store i32 %48, i32* %49
%50 = load i32*, i32** %9
%51 = load i32, i32* %50
%52 = load i32, i32* %11
%53 = call i32 @_mm_xor_si128(i32 %51, i32 %52)
%54 = load i32*, i32** %9
store i32 %53, i32* %54
%55 = load i32, i32* %12
%56 = load i32*, i32** %9
%57 = load i32, i32* %56
%58 = call i32 @_mm_xor_si128(i32 %55, i32 %57)
store i32 %58, i32* %12
%59 = load i8*, i8** %8
%60 = bitcast i8* %59 to i32*
%61 = load i32, i32* %12
%62 = call i32 @_mm_storel_epi64(i32* %60, i32 %61)
%63 = load i32*, i32** %9
%64 = load i32, i32* %63
%65 = load i32*, i32** %10
%66 = load i32, i32* %65
%67 = call i32 @_mm_xor_si128(i32 %64, i32 %66)
%68 = load i32*, i32** %10
store i32 %67, i32* %68
ret void
}

LLVM IR (-O2):
define void @jambu_enc_aut_msg_step(i32* %0, i8* nocapture %1, i8* %2, i32* %3, i32* nocapture %4) {
%6 = getelementptr inbounds i8, i8* %1, i64 7
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %1, i64 6
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %1, i64 5
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %1, i64 4
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %1, i64 3
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %1, i64 2
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %1, i64 1
%19 = load i8, i8* %18
%20 = load i8, i8* %1
%21 = tail call i32 @_mm_set_epi8(i8 zeroext %7, i8 zeroext %9, i8 zeroext %11, i8 zeroext %13, i8 zeroext %15, i8 zeroext %17, i8 zeroext %19, i8 zeroext %20, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
%22 = tail call i32 @_mm_srli_si128(i32 %21, i32 8)
%23 = tail call i32 @aes_enc_128(i32* %3, i32* %0)
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = tail call i32 @_mm_srli_si128(i32 %25, i32 8)
%27 = tail call i32 @_mm_xor_si128(i32 %24, i32 %26)
store i32 %27, i32* %3
%28 = tail call i32 @_mm_xor_si128(i32 %27, i32 %21)
store i32 %28, i32* %3
%29 = tail call i32 @_mm_xor_si128(i32 %22, i32 %28)
%30 = bitcast i8* %2 to i32*
%31 = tail call i32 @_mm_storel_epi64(i32* %30, i32 %29)
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = tail call i32 @_mm_xor_si128(i32 %32, i32 %33)
store i32 %34, i32* %4
ret void
}