#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 */

/* Variables and functions */
scalar_t__ AEAD_MGEN(unsigned char const *, unsigned char const *,
                     unsigned char const *, unsigned long long const,
                     unsigned char *, unsigned long long *);
int /*<<< orphan*/ AEAD_TGEN(unsigned char const *, unsigned char const *,
                             unsigned char const *, unsigned long long const,
                             unsigned char const *, unsigned long long const,
                             unsigned char *);
int AEAD_DEC(const unsigned char *_K, const unsigned char *_N,
             const unsigned char *_AD, const unsigned long long _adlen,
             const unsigned char *_C, const unsigned long long _clen,
             const unsigned char *_tag, unsigned char *M_,
             unsigned long long *mlen_) {
  int d, ret = 0;
  unsigned char tagS[16];
  if (_clen < 32)
    return -1;
  AEAD_TGEN(_K, _N, _AD, _adlen, _C, _clen, tagS);
  for (d = 0; d < 16; d++) {
    if (_tag[d] != tagS[d])
      ret |= 1;
  }
  if (ret != 0)
    return -1;
  if (AEAD_MGEN(_K, _N, _C, _clen, M_, mlen_) < 0) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<AEAD_DEC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x0,-0x40(%rbp)
cmpq   $0x20,-0x38(%rbp)
jae    116a <AEAD_DEC+0x4a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <AEAD_DEC+0x109>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    -0x50(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <AEAD_TGEN@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x10,-0x3c(%rbp)
jge    11d9 <AEAD_DEC+0xb9>
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
movslq -0x3c(%rbp),%rcx
movzbl -0x50(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11c6 <AEAD_DEC+0xa6>
mov    -0x40(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11cb <AEAD_DEC+0xab>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1196 <AEAD_DEC+0x76>
cmpl   $0x0,-0x40(%rbp)
je     11ef <AEAD_DEC+0xcf>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <AEAD_DEC+0x109>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    0x18(%rbp),%r8
mov    0x20(%rbp),%r9
call   1030 <AEAD_MGEN@plt>
cmp    $0x0,%rax
jge    1222 <AEAD_DEC+0x102>
movl   $0xffffffff,-0x4(%rbp)
jmp    1229 <AEAD_DEC+0x109>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AEAD_DEC>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0xffffffff,%ebx
cmp    $0x20,%r9
jb     1190 <AEAD_DEC+0x70>
mov    %r9,%r15
mov    %r8,%r14
mov    %rsi,%r12
mov    %rdi,%r13
mov    0x60(%rsp),%rbp
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
call   1040 <AEAD_TGEN@plt>
movdqu 0x0(%rbp),%xmm0
pcmpeqb 0x10(%rsp),%xmm0
pmovmskb %xmm0,%eax
cmp    $0xffff,%eax
jne    1190 <AEAD_DEC+0x70>
mov    0x70(%rsp),%r9
mov    0x68(%rsp),%r8
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <AEAD_MGEN@plt>
mov    %rax,%rbx
sar    $0x3f,%rbx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @AEAD_DEC(i8* %0, i8* %1, i8* %2, i64 %3, i8* %4, i64 %5, i8* %6, i8* %7, i64* %8) {
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i64*
%20 = alloca i32
%21 = alloca i32
%22 = alloca [16 x i8]
store i8* %0, i8** %11
store i8* %1, i8** %12
store i8* %2, i8** %13
store i64 %3, i64* %14
store i8* %4, i8** %15
store i64 %5, i64* %16
store i8* %6, i8** %17
store i8* %7, i8** %18
store i64* %8, i64** %19
store i32 0, i32* %21
%23 = load i64, i64* %16
%24 = icmp ult i64 %23, 32
br i1 %24, label %25, label %26
25: ; preds = %9
store i32 -1, i32* %10
br label %73
26: ; preds = %9
%27 = load i8*, i8** %11
%28 = load i8*, i8** %12
%29 = load i8*, i8** %13
%30 = load i64, i64* %14
%31 = load i8*, i8** %15
%32 = load i64, i64* %16
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %22, i64 0, i64 0
%34 = call i32 @AEAD_TGEN(i8* %27, i8* %28, i8* %29, i64 %30, i8* %31, i64 %32, i8* %33)
store i32 0, i32* %20
br label %35
35: ; preds = %55, %26
%36 = load i32, i32* %20
%37 = icmp slt i32 %36, 16
br i1 %37, label %38, label %58
38: ; preds = %35
%39 = load i8*, i8** %17
%40 = load i32, i32* %20
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = load i32, i32* %20
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %22, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = icmp ne i32 %44, %49
br i1 %50, label %51, label %54
51: ; preds = %38
%52 = load i32, i32* %21
%53 = or i32 %52, 1
store i32 %53, i32* %21
br label %54
54: ; preds = %51, %38
br label %55
55: ; preds = %54
%56 = load i32, i32* %20
%57 = add nsw i32 %56, 1
store i32 %57, i32* %20
br label %35
58: ; preds = %35
%59 = load i32, i32* %21
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %58
store i32 -1, i32* %10
br label %73
62: ; preds = %58
%63 = load i8*, i8** %11
%64 = load i8*, i8** %12
%65 = load i8*, i8** %15
%66 = load i64, i64* %16
%67 = load i8*, i8** %18
%68 = load i64*, i64** %19
%69 = call i64 @AEAD_MGEN(i8* %63, i8* %64, i8* %65, i64 %66, i8* %67, i64* %68)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %62
store i32 -1, i32* %10
br label %73
72: ; preds = %62
store i32 0, i32* %10
br label %73
73: ; preds = %72, %71, %61, %25
%74 = load i32, i32* %10
ret i32 %74
}

LLVM IR (-O2):
define i32 @AEAD_DEC(i8* %0, i8* %1, i8* %2, i64 %3, i8* %4, i64 %5, i8* nocapture %6, i8* %7, i64* %8) {
%10 = alloca <16 x i8>
%11 = getelementptr inbounds <16 x i8>, <16 x i8>* %10, i64 0, i64 0
%12 = icmp ult i64 %5, 32
br i1 %12, label %25, label %13
13: ; preds = %9
%14 = call i32 @AEAD_TGEN(i8* %0, i8* %1, i8* %2, i64 %3, i8* %4, i64 %5, i8* %11)
%15 = bitcast i8* %6 to <16 x i8>*
%16 = load <16 x i8>, <16 x i8>* %15
%17 = load <16 x i8>, <16 x i8>* %10
%18 = icmp ne <16 x i8> %16, %17
%19 = bitcast <16 x i1> %18 to i16
%20 = icmp eq i16 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = call i64 @AEAD_MGEN(i8* %0, i8* %1, i8* %4, i64 %5, i8* %7, i64* %8)
%23 = ashr i64 %22, 63
%24 = trunc i64 %23 to i32
br label %25
25: ; preds = %21, %13, %9
%26 = phi i32 [ -1, %9 ], [ -1, %13 ], [ %24, %21 ]
ret i32 %26
}