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

/* Variables and functions */
int /*<<< orphan*/ EVP_EncryptUpdate(int /*<<< orphan*/ *, unsigned char *,
                                     int *, unsigned char *, int);
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, unsigned long);
int /*<<< orphan*/ memxor(unsigned char *, unsigned char *, unsigned long);
int /*<<< orphan*/ mixoaep_pad(int /*<<< orphan*/ *, unsigned char *,
                               unsigned char *, unsigned long);
int /*<<< orphan*/ printf(char *);
void mixoaep_unpad(EVP_CIPHER_CTX *gctx, unsigned char *data,
                   unsigned char *buffer, const unsigned long size) {
  int outl;
  unsigned long partsize = size / 2;
  unsigned char *left = data;
  unsigned char *right = data + partsize;
  unsigned char *gout = buffer;
  if (partsize == 16) {
    EVP_EncryptUpdate(gctx, gout, &outl, left, 16);
    if (0)
      assert(16 == outl);
    memxor(right, gout, 16);
    EVP_EncryptUpdate(gctx, gout, &outl, right, 16);
    if (0)
      assert(16 == outl);
    memxor(left, gout, 16);
    EVP_EncryptUpdate(gctx, gout, &outl, left, 16);
    if (0)
      assert(16 == outl);
    memxor(right, gout, 16);
  } else if (partsize > 16) {
    memcpy(gout, left, partsize);
    mixoaep_pad(gctx, gout, buffer + partsize, partsize);
    memxor(right, gout, partsize);
    memcpy(gout, right, partsize);
    mixoaep_pad(gctx, gout, buffer + partsize, partsize);
    memxor(left, gout, partsize);
    memcpy(gout, left, partsize);
    mixoaep_pad(gctx, gout, buffer + partsize, partsize);
    memxor(right, gout, partsize);
  } else {
    printf("plaintext length must be 2*n*16 Bytes (n>0, int)");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<mixoaep_unpad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x10,-0x30(%rbp)
jne    1237 <mixoaep_unpad+0xd7>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x38(%rbp),%rcx
lea    -0x24(%rbp),%rdx
mov    $0x10,%r8d
call   1050 <EVP_EncryptUpdate@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    $0x10,%edx
call   1030 <memxor@plt>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rcx
lea    -0x24(%rbp),%rdx
mov    $0x10,%r8d
call   1050 <EVP_EncryptUpdate@plt>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    $0x10,%edx
call   1030 <memxor@plt>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x38(%rbp),%rcx
lea    -0x24(%rbp),%rdx
mov    $0x10,%r8d
call   1050 <EVP_EncryptUpdate@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    $0x10,%edx
call   1030 <memxor@plt>
jmp    1317 <mixoaep_unpad+0x1b7>
cmpq   $0x10,-0x30(%rbp)
jbe    12f8 <mixoaep_unpad+0x198>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    -0x30(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1070 <mixoaep_pad@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <memxor@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    -0x30(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1070 <mixoaep_pad@plt>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <memxor@plt>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    -0x30(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1070 <mixoaep_pad@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <memxor@plt>
jmp    1312 <mixoaep_unpad+0x1b2>
lea    0xd01(%rip),%rdi
call   1040 <printf@plt>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1317 <mixoaep_unpad+0x1b7>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mixoaep_unpad>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rcx,%rbx
shr    %rbx
lea    (%rsi,%rbx,1),%r14
cmp    $0x10,%rbx
jne    1211 <mixoaep_unpad+0xb1>
lea    0x4(%rsp),%rbx
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    $0x10,%r8d
call   1050 <EVP_EncryptUpdate@plt>
mov    $0x10,%edx
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <memxor@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
mov    $0x10,%r8d
call   1050 <EVP_EncryptUpdate@plt>
mov    $0x10,%edx
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <memxor@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    $0x10,%r8d
call   1050 <EVP_EncryptUpdate@plt>
mov    $0x10,%edx
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <memxor@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x22,%rcx
jb     12b4 <mixoaep_unpad+0x154>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
lea    (%rbx,%r13,1),%rbp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1070 <mixoaep_pad@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1030 <memxor@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1070 <mixoaep_pad@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1030 <memxor@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <memcpy@plt>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1070 <mixoaep_pad@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <memxor@plt>
lea    0xd45(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"plaintext length must be 2*n*16 Bytes (n>0, int)\00"
@EXIT_FAILURE = global i32 0
define void @mixoaep_unpad(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%14 = load i64, i64* %8
%15 = udiv i64 %14, 2
store i64 %15, i64* %10
%16 = load i8*, i8** %6
store i8* %16, i8** %11
%17 = load i8*, i8** %6
%18 = load i64, i64* %10
%19 = getelementptr inbounds i8, i8* %17, i64 %18
store i8* %19, i8** %12
%20 = load i8*, i8** %7
store i8* %20, i8** %13
%21 = load i64, i64* %10
%22 = icmp eq i64 %21, 16
br i1 %22, label %23, label %45
23: ; preds = %4
%24 = load i32*, i32** %5
%25 = load i8*, i8** %13
%26 = load i8*, i8** %11
%27 = call i32 @EVP_EncryptUpdate(i32* %24, i8* %25, i32* %9, i8* %26, i32 16)
%28 = load i8*, i8** %12
%29 = load i8*, i8** %13
%30 = call i32 @memxor(i8* %28, i8* %29, i64 16)
%31 = load i32*, i32** %5
%32 = load i8*, i8** %13
%33 = load i8*, i8** %12
%34 = call i32 @EVP_EncryptUpdate(i32* %31, i8* %32, i32* %9, i8* %33, i32 16)
%35 = load i8*, i8** %11
%36 = load i8*, i8** %13
%37 = call i32 @memxor(i8* %35, i8* %36, i64 16)
%38 = load i32*, i32** %5
%39 = load i8*, i8** %13
%40 = load i8*, i8** %11
%41 = call i32 @EVP_EncryptUpdate(i32* %38, i8* %39, i32* %9, i8* %40, i32 16)
%42 = load i8*, i8** %12
%43 = load i8*, i8** %13
%44 = call i32 @memxor(i8* %42, i8* %43, i64 16)
br label %99
45: ; preds = %4
%46 = load i64, i64* %10
%47 = icmp ugt i64 %46, 16
br i1 %47, label %48, label %94
48: ; preds = %45
%49 = load i8*, i8** %13
%50 = load i8*, i8** %11
%51 = load i64, i64* %10
%52 = call i32 @memcpy(i8* %49, i8* %50, i64 %51)
%53 = load i32*, i32** %5
%54 = load i8*, i8** %13
%55 = load i8*, i8** %7
%56 = load i64, i64* %10
%57 = getelementptr inbounds i8, i8* %55, i64 %56
%58 = load i64, i64* %10
%59 = call i32 @mixoaep_pad(i32* %53, i8* %54, i8* %57, i64 %58)
%60 = load i8*, i8** %12
%61 = load i8*, i8** %13
%62 = load i64, i64* %10
%63 = call i32 @memxor(i8* %60, i8* %61, i64 %62)
%64 = load i8*, i8** %13
%65 = load i8*, i8** %12
%66 = load i64, i64* %10
%67 = call i32 @memcpy(i8* %64, i8* %65, i64 %66)
%68 = load i32*, i32** %5
%69 = load i8*, i8** %13
%70 = load i8*, i8** %7
%71 = load i64, i64* %10
%72 = getelementptr inbounds i8, i8* %70, i64 %71
%73 = load i64, i64* %10
%74 = call i32 @mixoaep_pad(i32* %68, i8* %69, i8* %72, i64 %73)
%75 = load i8*, i8** %11
%76 = load i8*, i8** %13
%77 = load i64, i64* %10
%78 = call i32 @memxor(i8* %75, i8* %76, i64 %77)
%79 = load i8*, i8** %13
%80 = load i8*, i8** %11
%81 = load i64, i64* %10
%82 = call i32 @memcpy(i8* %79, i8* %80, i64 %81)
%83 = load i32*, i32** %5
%84 = load i8*, i8** %13
%85 = load i8*, i8** %7
%86 = load i64, i64* %10
%87 = getelementptr inbounds i8, i8* %85, i64 %86
%88 = load i64, i64* %10
%89 = call i32 @mixoaep_pad(i32* %83, i8* %84, i8* %87, i64 %88)
%90 = load i8*, i8** %12
%91 = load i8*, i8** %13
%92 = load i64, i64* %10
%93 = call i32 @memxor(i8* %90, i8* %91, i64 %92)
br label %98
94: ; preds = %45
%95 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %48
br label %99
99: ; preds = %98, %23
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"plaintext length must be 2*n*16 Bytes (n>0, int)\00"
@EXIT_FAILURE = global i32 0
define void @mixoaep_unpad(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = lshr i64 %3, 1
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = icmp eq i64 %7, 16
br i1 %9, label %10, label %17
10: ; preds = %4
%11 = call i32 @EVP_EncryptUpdate(i32* %0, i8* %2, i32* %5, i8* %1, i32 16)
%12 = call i32 @memxor(i8* %8, i8* %2, i64 16)
%13 = call i32 @EVP_EncryptUpdate(i32* %0, i8* %2, i32* %5, i8* %8, i32 16)
%14 = call i32 @memxor(i8* %1, i8* %2, i64 16)
%15 = call i32 @EVP_EncryptUpdate(i32* %0, i8* %2, i32* %5, i8* %1, i32 16)
%16 = call i32 @memxor(i8* %8, i8* %2, i64 16)
br label %34
17: ; preds = %4
%18 = icmp ugt i64 %3, 33
br i1 %18, label %19, label %30
19: ; preds = %17
%20 = tail call i32 @memcpy(i8* %2, i8* %1, i64 %7)
%21 = getelementptr inbounds i8, i8* %2, i64 %7
%22 = tail call i32 @mixoaep_pad(i32* %0, i8* %2, i8* %21, i64 %7)
%23 = tail call i32 @memxor(i8* %8, i8* %2, i64 %7)
%24 = tail call i32 @memcpy(i8* %2, i8* %8, i64 %7)
%25 = tail call i32 @mixoaep_pad(i32* %0, i8* %2, i8* %21, i64 %7)
%26 = tail call i32 @memxor(i8* %1, i8* %2, i64 %7)
%27 = tail call i32 @memcpy(i8* %2, i8* %1, i64 %7)
%28 = tail call i32 @mixoaep_pad(i32* %0, i8* %2, i8* %21, i64 %7)
%29 = tail call i32 @memxor(i8* %8, i8* %2, i64 %7)
br label %34
30: ; preds = %17
%31 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %19, %10
ret void
}