#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*/ plaintext_7;
typedef int /*<<< orphan*/ plaintext_20;
typedef int /*<<< orphan*/ key;
typedef int /*<<< orphan*/ ciphertext_7;
typedef int /*<<< orphan*/ ciphertext_20;

/* Variables and functions */
scalar_t__ aeskw_with_padding_test(unsigned char *, int, unsigned char *, int,
                                   unsigned char *, int);
scalar_t__ aeskw_with_padding_test_openssl(unsigned char *, int,
                                           unsigned char *, int,
                                           unsigned char *, int);
int /*<<< orphan*/ printf(char *);
int rfc5649_test() {
  unsigned char key[] = {0x58, 0x40, 0xDF, 0x6E, 0x29, 0xB0, 0x2A, 0XF1,
                         0xAB, 0x49, 0x3B, 0x70, 0x5B, 0xF1, 0x6E, 0XA1,
                         0xAE, 0x83, 0x38, 0xF4, 0xDC, 0xC1, 0x76, 0XA8};
  unsigned char plaintext_20[] = {0xC3, 0x7B, 0x7E, 0x64, 0x92, 0x58, 0x43,
                                  0x40, 0xBE, 0xD1, 0x22, 0x07, 0x80, 0x89,
                                  0x41, 0x15, 0x50, 0x68, 0xF7, 0x38};
  unsigned char ciphertext_20[] = {
      0x13, 0x8B, 0xDE, 0xAA, 0x9B, 0x8F, 0xA7, 0xFC, 0x61, 0xF9, 0x77,
      0x42, 0xE7, 0x22, 0x48, 0xEE, 0x5A, 0xE6, 0xAE, 0x53, 0x60, 0xD1,
      0xAE, 0x6A, 0x5F, 0x54, 0xF3, 0x73, 0xFA, 0x54, 0x3B, 0x6A};
  unsigned char plaintext_7[] = {0x46, 0x6F, 0x72, 0x50, 0x61, 0x73, 0x69};
  unsigned char ciphertext_7[] = {0xAF, 0xBE, 0xB0, 0xF0, 0x7D, 0xFB,
                                  0xF5, 0x41, 0x92, 0x00, 0xF2, 0xCC,
                                  0xB5, 0x0B, 0xB2, 0x4F};
  printf("Entering rfc5649_test()\n");
  if (aeskw_with_padding_test(key, sizeof(key) * 8, plaintext_20,
                              sizeof(plaintext_20), ciphertext_20,
                              sizeof(ciphertext_20))) {
    printf("Exiting rfc5649_test()\n");
    return (-1);
  }
  if (aeskw_with_padding_test(key, sizeof(key) * 8, plaintext_7,
                              sizeof(plaintext_7), ciphertext_7,
                              sizeof(ciphertext_7))) {
    printf("Exiting rfc5649_test()\n");
    return (-1);
  }
  if (aeskw_with_padding_test_openssl(key, sizeof(key) * 8, plaintext_20,
                                      sizeof(plaintext_20), ciphertext_20,
                                      sizeof(ciphertext_20))) {
    printf("Exiting rfc5649_test()\n");
    return (-1);
  }
  if (aeskw_with_padding_test_openssl(key, sizeof(key) * 8, plaintext_7,
                                      sizeof(plaintext_7), ciphertext_7,
                                      sizeof(ciphertext_7))) {
    printf("Exiting rfc5649_test()\n");
    return (-1);
  }
  printf("Exiting rfc5649_test()\n");
  return 0;
}


x86 assembly (clang, -O0):
<rfc5649_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0xebe(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0x30(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe87(%rip),%eax
mov    %eax,-0x67(%rbp)
mov    0xe81(%rip),%ax
mov    %ax,-0x63(%rbp)
mov    0xe79(%rip),%al
mov    %al,-0x61(%rbp)
mov    0xe95(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe92(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x60(%rbp),%r8
mov    $0xc0,%esi
mov    $0x14,%ecx
mov    $0x20,%r9d
call   1030 <aeskw_with_padding_test@plt>
cmp    $0x0,%rax
je     1229 <rfc5649_test+0xf9>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1305 <rfc5649_test+0x1d5>
lea    -0x20(%rbp),%rdi
lea    -0x67(%rbp),%rdx
lea    -0x80(%rbp),%r8
mov    $0xc0,%esi
mov    $0x7,%ecx
mov    $0x10,%r9d
call   1030 <aeskw_with_padding_test@plt>
cmp    $0x0,%rax
je     126c <rfc5649_test+0x13c>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1305 <rfc5649_test+0x1d5>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x60(%rbp),%r8
mov    $0xc0,%esi
mov    $0x14,%ecx
mov    $0x20,%r9d
call   1050 <aeskw_with_padding_test_openssl@plt>
cmp    $0x0,%rax
je     12af <rfc5649_test+0x17f>
lea    0xdeb(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1305 <rfc5649_test+0x1d5>
lea    -0x20(%rbp),%rdi
lea    -0x67(%rbp),%rdx
lea    -0x80(%rbp),%r8
mov    $0xc0,%esi
mov    $0x7,%ecx
mov    $0x10,%r9d
call   1050 <aeskw_with_padding_test_openssl@plt>
cmp    $0x0,%rax
je     12f2 <rfc5649_test+0x1c2>
lea    0xda8(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1305 <rfc5649_test+0x1d5>
lea    0xd90(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rfc5649_test>:
push   %rbp
push   %rbx
sub    $0x88,%rsp
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0xa876c1dcf43883ae,%rax
c1 76 a8
mov    %rax,0x20(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x38f76850,0x40(%rsp)
38
movaps 0xee1(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movl   $0x69736150,0xb(%rsp)
69
movl   $0x50726f46,0x8(%rsp)
50
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
lea    0xecd(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rdx
lea    0x60(%rsp),%r8
mov    $0xc0,%esi
mov    $0x14,%ecx
mov    $0x20,%r9d
call   1030 <aeskw_with_padding_test@plt>
mov    $0xffffffff,%ebp
lea    0xeb0(%rip),%rbx
test   %rax,%rax
jne    1258 <rfc5649_test+0x128>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0x50(%rsp),%r8
mov    $0xc0,%esi
mov    $0x7,%ecx
mov    $0x10,%r9d
call   1030 <aeskw_with_padding_test@plt>
test   %rax,%rax
jne    1258 <rfc5649_test+0x128>
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rdx
lea    0x60(%rsp),%r8
mov    $0xc0,%esi
mov    $0x14,%ecx
mov    $0x20,%r9d
call   1050 <aeskw_with_padding_test_openssl@plt>
test   %rax,%rax
jne    1258 <rfc5649_test+0x128>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0x50(%rsp),%r8
mov    $0xc0,%esi
mov    $0x7,%ecx
mov    $0x10,%r9d
call   1050 <aeskw_with_padding_test_openssl@plt>
neg    %rax
sbb    %ebp,%ebp
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %ebp,%eax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.rfc5649_test.key = [24 x i8] c"X@\DFn)\B0*\F1\ABI;p[\F1n\A1\AE\838\F4\DC\C1v\A8"
@__const.rfc5649_test.plaintext_20 = [20 x i8] c"\C3{~d\92XC@\BE\D1\22\07\80\89A\15Ph\F78"
@__const.rfc5649_test.ciphertext_20 = [32 x i8] c"\13\8B\DE\AA\9B\8F\A7\FCa\F9wB\E7\22H\EEZ\E6\AES`\D1\AEj_T\F3s\FAT;j"
@__const.rfc5649_test.plaintext_7 = [7 x i8] c"ForPasi"
@__const.rfc5649_test.ciphertext_7 = [16 x i8] c"\AF\BE\B0\F0}\FB\F5A\92\00\F2\CC\B5\0B\B2O"
@.str = [25 x i8] c"Entering rfc5649_test()\0A\00"
@.str.1 = [24 x i8] c"Exiting rfc5649_test()\0A\00"
define i32 @rfc5649_test() {
%1 = alloca i32
%2 = alloca [24 x i8]
%3 = alloca [20 x i8]
%4 = alloca [32 x i8]
%5 = alloca [7 x i8]
%6 = alloca [16 x i8]
%7 = bitcast [24 x i8]* %2 to i8*
%8 = bitcast [20 x i8]* %3 to i8*
%9 = bitcast [32 x i8]* %4 to i8*
%10 = bitcast [7 x i8]* %5 to i8*
%11 = bitcast [16 x i8]* %6 to i8*
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%16 = call i64 @aeskw_with_padding_test(i8* %13, i32 192, i8* %14, i32 20, i8* %15, i32 32)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %46
20: ; preds = %0
%21 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%24 = call i64 @aeskw_with_padding_test(i8* %21, i32 192, i8* %22, i32 7, i8* %23, i32 16)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %46
28: ; preds = %20
%29 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%32 = call i64 @aeskw_with_padding_test_openssl(i8* %29, i32 192, i8* %30, i32 20, i8* %31, i32 32)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %46
36: ; preds = %28
%37 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%38 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%40 = call i64 @aeskw_with_padding_test_openssl(i8* %37, i32 192, i8* %38, i32 7, i8* %39, i32 16)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %46
44: ; preds = %36
%45 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %46
46: ; preds = %44, %42, %34, %26, %18
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@__const.rfc5649_test.key = [24 x i8] c"X@\DFn)\B0*\F1\ABI;p[\F1n\A1\AE\838\F4\DC\C1v\A8"
@__const.rfc5649_test.plaintext_20 = [20 x i8] c"\C3{~d\92XC@\BE\D1\22\07\80\89A\15Ph\F78"
@__const.rfc5649_test.ciphertext_20 = [32 x i8] c"\13\8B\DE\AA\9B\8F\A7\FCa\F9wB\E7\22H\EEZ\E6\AES`\D1\AEj_T\F3s\FAT;j"
@__const.rfc5649_test.plaintext_7 = [7 x i8] c"ForPasi"
@__const.rfc5649_test.ciphertext_7 = [16 x i8] c"\AF\BE\B0\F0}\FB\F5A\92\00\F2\CC\B5\0B\B2O"
@str = [24 x i8] c"Entering rfc5649_test()\00"
@str.6 = [23 x i8] c"Exiting rfc5649_test()\00"
define i32 @rfc5649_test() {
%1 = alloca [24 x i8]
%2 = alloca [20 x i8]
%3 = alloca [32 x i8]
%4 = alloca [7 x i8]
%5 = alloca [16 x i8]
%6 = getelementptr inbounds [24 x i8], [24 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%12 = call i64 @aeskw_with_padding_test(i8* %6, i32 192, i8* %7, i32 20, i8* %8, i32 32)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %0
%15 = call i64 @aeskw_with_padding_test(i8* %6, i32 192, i8* %9, i32 7, i8* %10, i32 16)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = call i64 @aeskw_with_padding_test_openssl(i8* %6, i32 192, i8* %7, i32 20, i8* %8, i32 32)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = call i64 @aeskw_with_padding_test_openssl(i8* %6, i32 192, i8* %9, i32 7, i8* %10, i32 16)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0)
%24 = xor i1 %22, true
%25 = sext i1 %24 to i32
br label %26
26: ; preds = %20, %17, %14, %0
%27 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0), %0 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0), %14 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0), %17 ], [ %23, %20 ]
%28 = phi i32 [ -1, %0 ], [ -1, %14 ], [ -1, %17 ], [ %25, %20 ]
%29 = call i32 @puts(i8* dereferenceable(1) %27)
ret i32 %28
}