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


x86 assembly (clang, -O0):
<jambu_aut_ad_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%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,-0x24(%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_set_epi8@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <aes_enc_128@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jambu_aut_ad_step>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rdi,%r15
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),%r10d
movzbl (%rsi),%ebp
mov    %eax,%esi
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   %rbp
push   %r10
call   1050 <_mm_set_epi8@plt>
add    $0x50,%rsp
mov    %eax,%r12d
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_set_epi8@plt>
add    $0x50,%rsp
mov    %eax,%r13d
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <aes_enc_128@plt>
mov    (%rbx),%ebp
mov    (%r14),%edi
mov    $0x8,%esi
call   1040 <_mm_srli_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
mov    %eax,%edi
mov    %r13d,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
mov    %eax,%edi
mov    %r12d,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,(%rbx)
mov    (%r14),%esi
mov    %eax,%edi
call   1060 <_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_aut_ad_step(i32* %0, i8* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%11 = load i8*, i8** %6
%12 = getelementptr inbounds i8, i8* %11, i64 7
%13 = load i8, i8* %12
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 6
%16 = load i8, i8* %15
%17 = load i8*, i8** %6
%18 = getelementptr inbounds i8, i8* %17, i64 5
%19 = load i8, i8* %18
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 4
%22 = load i8, i8* %21
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i64 3
%25 = load i8, i8* %24
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = load i8, i8* %27
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = call i32 @_mm_set_epi8(i8 zeroext %13, i8 zeroext %16, i8 zeroext %19, i8 zeroext %22, i8 zeroext %25, i8 zeroext %28, i8 zeroext %31, i8 zeroext %34, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
store i32 %35, i32* %9
%36 = call i32 @_mm_set_epi8(i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1)
store i32 %36, i32* %10
%37 = load i32*, i32** %7
%38 = load i32*, i32** %5
%39 = call i32 @aes_enc_128(i32* %37, i32* %38)
%40 = load i32*, i32** %7
%41 = load i32, i32* %40
%42 = load i32*, i32** %8
%43 = load i32, i32* %42
%44 = call i32 @_mm_srli_si128(i32 %43, i32 8)
%45 = call i32 @_mm_xor_si128(i32 %41, i32 %44)
%46 = load i32*, i32** %7
store i32 %45, i32* %46
%47 = load i32*, i32** %7
%48 = load i32, i32* %47
%49 = load i32, i32* %10
%50 = call i32 @_mm_xor_si128(i32 %48, i32 %49)
%51 = load i32*, i32** %7
store i32 %50, i32* %51
%52 = load i32*, i32** %7
%53 = load i32, i32* %52
%54 = load i32, i32* %9
%55 = call i32 @_mm_xor_si128(i32 %53, i32 %54)
%56 = load i32*, i32** %7
store i32 %55, i32* %56
%57 = load i32*, i32** %7
%58 = load i32, i32* %57
%59 = load i32*, i32** %8
%60 = load i32, i32* %59
%61 = call i32 @_mm_xor_si128(i32 %58, i32 %60)
%62 = load i32*, i32** %8
store i32 %61, i32* %62
ret void
}

LLVM IR (-O2):
define void @jambu_aut_ad_step(i32* %0, i8* nocapture %1, i32* %2, i32* nocapture %3) {
%5 = getelementptr inbounds i8, i8* %1, i64 7
%6 = load i8, i8* %5
%7 = getelementptr inbounds i8, i8* %1, i64 6
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %1, i64 5
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %1, i64 4
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %1, i64 3
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %1, i64 2
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %1, i64 1
%18 = load i8, i8* %17
%19 = load i8, i8* %1
%20 = tail call i32 @_mm_set_epi8(i8 zeroext %6, i8 zeroext %8, i8 zeroext %10, i8 zeroext %12, i8 zeroext %14, i8 zeroext %16, i8 zeroext %18, i8 zeroext %19, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0)
%21 = tail call i32 @_mm_set_epi8(i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1)
%22 = tail call i32 @aes_enc_128(i32* %2, i32* %0)
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%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* %2
%27 = tail call i32 @_mm_xor_si128(i32 %26, i32 %21)
store i32 %27, i32* %2
%28 = tail call i32 @_mm_xor_si128(i32 %27, i32 %20)
store i32 %28, i32* %2
%29 = load i32, i32* %3
%30 = tail call i32 @_mm_xor_si128(i32 %28, i32 %29)
store i32 %30, i32* %3
ret void
}