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


x86 assembly (clang, -O0):
<jambu_dec_aut_msg_step>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    0x7(%rax),%r13b
mov    -0x40(%rbp),%rax
mov    0x6(%rax),%r12b
mov    -0x40(%rbp),%rax
mov    0x5(%rax),%r15b
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%r14b
mov    -0x40(%rbp),%rax
mov    0x3(%rax),%bl
mov    -0x40(%rbp),%rax
mov    0x2(%rax),%r11b
mov    -0x40(%rbp),%rax
mov    0x1(%rax),%r10b
mov    -0x40(%rbp),%rax
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)
movzbl %r13b,%r13d
mov    %r13d,0x10(%rsp)
movzbl %r12b,%r12d
mov    %r12d,0x18(%rsp)
movzbl %r15b,%r15d
mov    %r15d,0x20(%rsp)
movzbl %r14b,%r14d
mov    %r14d,0x28(%rsp)
movzbl %bl,%ebx
mov    %ebx,0x30(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x38(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x40(%rsp)
movzbl (%rax),%eax
mov    %eax,0x48(%rsp)
call   1050 <_mm_set_epi8@plt>
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <aes_enc_128@plt>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x5c(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x54(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    (%rax),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,-0x58(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%esi
call   1060 <_mm_storel_epi64@plt>
mov    -0x58(%rbp),%edi
mov    $0x8,%esi
call   1080 <_mm_slli_si128@plt>
mov    %eax,-0x58(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rax
mov    (%rax),%esi
call   1070 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
mov    %ecx,(%rax)
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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