#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, unsigned char, unsigned char,
                                unsigned char, unsigned char, unsigned char,
                                unsigned char, unsigned char,
                                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_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*/ *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
void jambu_dec_aut_partial(__m128i *key, unsigned char *plaintextblk,
                           const unsigned char *ciphertextblk, __m128i *stateS,
                           __m128i *stateR, unsigned long len) {
  __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);
  plaintextblk[len] = 0x80;
  memset(plaintextblk + (len + 1), 0, 7 - len);
  tmp = _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);
  *stateS = _mm_xor_si128(*stateS, tmp);
  *stateR = _mm_xor_si128(*stateS, *stateR);
}


x86 assembly (clang, -O0):
<jambu_dec_aut_partial>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8,-0x50(%rbp)
mov    %r9,-0x58(%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   1060 <_mm_set_epi8@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <aes_enc_128@plt>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%edi
mov    $0x8,%esi
call   1050 <_mm_srli_si128@plt>
mov    -0x64(%rbp),%edi
mov    %eax,%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x5c(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    (%rax),%esi
call   1080 <_mm_xor_si128@plt>
mov    %eax,-0x60(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%esi
call   1070 <_mm_storel_epi64@plt>
mov    -0x38(%rbp),%rax
mov    -0x58(%rbp),%rcx
movb   $0x80,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%rax
add    $0x1,%rax
add    %rax,%rdi
mov    $0x7,%eax
sub    -0x58(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x38(%rbp),%rax
mov    0x7(%rax),%dil
mov    -0x38(%rbp),%rax
mov    0x6(%rax),%sil
mov    -0x38(%rbp),%rax
mov    0x5(%rax),%dl
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x38(%rbp),%rax
mov    0x3(%rax),%r8b
mov    -0x38(%rbp),%rax
mov    0x2(%rax),%r9b
mov    -0x38(%rbp),%rax
mov    0x1(%rax),%r10b
mov    -0x38(%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   1060 <_mm_set_epi8@plt>
mov    %eax,-0x60(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%edi
mov    -0x60(%rbp),%esi
call   1080 <_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   1080 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
mov    %ecx,(%rax)
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O0):
define void @jambu_dec_aut_partial(i32* %0, i8* %1, i8* %2, i32* %3, i32* %4, i64 %5) {
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i64 %5, i64* %12
%15 = load i8*, i8** %9
%16 = getelementptr inbounds i8, i8* %15, i64 7
%17 = load i8, i8* %16
%18 = load i8*, i8** %9
%19 = getelementptr inbounds i8, i8* %18, i64 6
%20 = load i8, i8* %19
%21 = load i8*, i8** %9
%22 = getelementptr inbounds i8, i8* %21, i64 5
%23 = load i8, i8* %22
%24 = load i8*, i8** %9
%25 = getelementptr inbounds i8, i8* %24, i64 4
%26 = load i8, i8* %25
%27 = load i8*, i8** %9
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = load i8*, i8** %9
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = load i8*, i8** %9
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = load i8*, i8** %9
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = 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, i8 zeroext %17, i8 zeroext %20, i8 zeroext %23, i8 zeroext %26, i8 zeroext %29, i8 zeroext %32, i8 zeroext %35, i8 zeroext %38)
store i32 %39, i32* %13
%40 = load i32*, i32** %10
%41 = load i32*, i32** %7
%42 = call i32 @aes_enc_128(i32* %40, i32* %41)
%43 = load i32*, i32** %10
%44 = load i32, i32* %43
%45 = load i32*, i32** %11
%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** %10
store i32 %48, i32* %49
%50 = load i32, i32* %13
%51 = load i32*, i32** %10
%52 = load i32, i32* %51
%53 = call i32 @_mm_xor_si128(i32 %50, i32 %52)
store i32 %53, i32* %14
%54 = load i8*, i8** %8
%55 = bitcast i8* %54 to i32*
%56 = load i32, i32* %14
%57 = call i32 @_mm_storel_epi64(i32* %55, i32 %56)
%58 = load i8*, i8** %8
%59 = load i64, i64* %12
%60 = getelementptr inbounds i8, i8* %58, i64 %59
store i8 -128, i8* %60
%61 = load i8*, i8** %8
%62 = load i64, i64* %12
%63 = add i64 %62, 1
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = load i64, i64* %12
%66 = sub i64 7, %65
%67 = trunc i64 %66 to i32
%68 = call i32 @memset(i8* %64, i32 0, i32 %67)
%69 = load i8*, i8** %8
%70 = getelementptr inbounds i8, i8* %69, i64 7
%71 = load i8, i8* %70
%72 = load i8*, i8** %8
%73 = getelementptr inbounds i8, i8* %72, i64 6
%74 = load i8, i8* %73
%75 = load i8*, i8** %8
%76 = getelementptr inbounds i8, i8* %75, i64 5
%77 = load i8, i8* %76
%78 = load i8*, i8** %8
%79 = getelementptr inbounds i8, i8* %78, i64 4
%80 = load i8, i8* %79
%81 = load i8*, i8** %8
%82 = getelementptr inbounds i8, i8* %81, i64 3
%83 = load i8, i8* %82
%84 = load i8*, i8** %8
%85 = getelementptr inbounds i8, i8* %84, i64 2
%86 = load i8, i8* %85
%87 = load i8*, i8** %8
%88 = getelementptr inbounds i8, i8* %87, i64 1
%89 = load i8, i8* %88
%90 = load i8*, i8** %8
%91 = getelementptr inbounds i8, i8* %90, i64 0
%92 = load i8, i8* %91
%93 = call i32 @_mm_set_epi8(i8 zeroext %71, i8 zeroext %74, i8 zeroext %77, i8 zeroext %80, i8 zeroext %83, i8 zeroext %86, i8 zeroext %89, i8 zeroext %92, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0)
store i32 %93, i32* %14
%94 = load i32*, i32** %10
%95 = load i32, i32* %94
%96 = load i32, i32* %14
%97 = call i32 @_mm_xor_si128(i32 %95, i32 %96)
%98 = load i32*, i32** %10
store i32 %97, i32* %98
%99 = load i32*, i32** %10
%100 = load i32, i32* %99
%101 = load i32*, i32** %11
%102 = load i32, i32* %101
%103 = call i32 @_mm_xor_si128(i32 %100, i32 %102)
%104 = load i32*, i32** %11
store i32 %103, i32* %104
ret void
}

LLVM IR (-O2):
define void @jambu_dec_aut_partial(i32* %0, i8* %1, i8* nocapture %2, i32* %3, i32* nocapture %4, i64 %5) {
%7 = getelementptr inbounds i8, i8* %2, i64 7
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %2, i64 6
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %2, i64 5
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %2, i64 4
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %2, i64 3
%16 = load i8, i8* %15
%17 = getelementptr inbounds i8, i8* %2, i64 2
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %2, i64 1
%20 = load i8, i8* %19
%21 = load i8, i8* %2
%22 = 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, i8 zeroext %8, i8 zeroext %10, i8 zeroext %12, i8 zeroext %14, i8 zeroext %16, i8 zeroext %18, i8 zeroext %20, i8 zeroext %21)
%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 %22, i32 %27)
%29 = bitcast i8* %1 to i32*
%30 = tail call i32 @_mm_storel_epi64(i32* %29, i32 %28)
%31 = getelementptr inbounds i8, i8* %1, i64 %5
store i8 -128, i8* %31
%32 = add i64 %5, 1
%33 = getelementptr inbounds i8, i8* %1, i64 %32
%34 = trunc i64 %5 to i32
%35 = sub i32 7, %34
%36 = tail call i32 @memset(i8* %33, i32 0, i32 %35)
%37 = getelementptr inbounds i8, i8* %1, i64 7
%38 = load i8, i8* %37
%39 = getelementptr inbounds i8, i8* %1, i64 6
%40 = load i8, i8* %39
%41 = getelementptr inbounds i8, i8* %1, i64 5
%42 = load i8, i8* %41
%43 = getelementptr inbounds i8, i8* %1, i64 4
%44 = load i8, i8* %43
%45 = getelementptr inbounds i8, i8* %1, i64 3
%46 = load i8, i8* %45
%47 = getelementptr inbounds i8, i8* %1, i64 2
%48 = load i8, i8* %47
%49 = getelementptr inbounds i8, i8* %1, i64 1
%50 = load i8, i8* %49
%51 = load i8, i8* %1
%52 = tail call i32 @_mm_set_epi8(i8 zeroext %38, i8 zeroext %40, i8 zeroext %42, i8 zeroext %44, i8 zeroext %46, i8 zeroext %48, i8 zeroext %50, i8 zeroext %51, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0, i8 zeroext 0)
%53 = load i32, i32* %3
%54 = tail call i32 @_mm_xor_si128(i32 %53, i32 %52)
store i32 %54, i32* %3
%55 = load i32, i32* %4
%56 = tail call i32 @_mm_xor_si128(i32 %54, i32 %55)
store i32 %56, i32* %4
ret void
}