#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*/ uint8_t;
typedef size_t uint64_t;

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ decrypt(void *, size_t, void *, void *, void *);
int /*<<< orphan*/ printf(char *);
__attribute__((visibility("default"))) size_t
cryptoshit_decrypt(void *key, void *in, size_t inSz, void *out, size_t outSz) {
  if (outSz > inSz) {
    printf("no the output buffer is larger !!!\n");
    abort();
  }
  void *iv = in;
  uint64_t *plainSzPtr = (uint64_t *)(((uint8_t *)iv) + 16);
  uint64_t *cryptoSzPtr = (uint64_t *)(((uint8_t *)plainSzPtr) + 8);
  void *cryptoText = ((uint8_t *)cryptoSzPtr) + 8;
  size_t bytesOfCryptoText = *cryptoSzPtr;
  decrypt(cryptoText, bytesOfCryptoText, key, iv, out);
  return *plainSzPtr;
}


x86 assembly (clang, -O0):
<cryptoshit_decrypt>:
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    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    116d <cryptoshit_decrypt+0x3d>
lea    0xe9f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1030 <decrypt@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cryptoshit_decrypt>:
push   %rbx
cmp    %rdx,%r8
ja     115e <cryptoshit_decrypt+0x2e>
mov    %rcx,%rax
mov    %rsi,%rbx
mov    %rdi,%rcx
lea    0x80(%rsi),%rdi
mov    0x60(%rsi),%rsi
mov    %rcx,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
call   1030 <decrypt@plt>
mov    0x40(%rbx),%rax
pop    %rbx
ret
lea    0xe9b(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"no the output buffer is larger !!!\0A\00"
define i64 @cryptoshit_decrypt(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64*
%13 = alloca i64*
%14 = alloca i8*
%15 = alloca i64
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i64 %4, i64* %10
%16 = load i64, i64* %10
%17 = load i64, i64* %8
%18 = icmp ugt i64 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %5
%20 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %5
%23 = load i8*, i8** %7
store i8* %23, i8** %11
%24 = load i8*, i8** %11
%25 = bitcast i8* %24 to i32*
%26 = getelementptr inbounds i32, i32* %25, i64 16
%27 = bitcast i32* %26 to i64*
store i64* %27, i64** %12
%28 = load i64*, i64** %12
%29 = bitcast i64* %28 to i32*
%30 = getelementptr inbounds i32, i32* %29, i64 8
%31 = bitcast i32* %30 to i64*
store i64* %31, i64** %13
%32 = load i64*, i64** %13
%33 = bitcast i64* %32 to i32*
%34 = getelementptr inbounds i32, i32* %33, i64 8
%35 = bitcast i32* %34 to i8*
store i8* %35, i8** %14
%36 = load i64*, i64** %13
%37 = load i64, i64* %36
store i64 %37, i64* %15
%38 = load i8*, i8** %14
%39 = load i64, i64* %15
%40 = load i8*, i8** %6
%41 = load i8*, i8** %11
%42 = load i8*, i8** %9
%43 = call i32 @decrypt(i8* %38, i64 %39, i8* %40, i8* %41, i8* %42)
%44 = load i64*, i64** %12
%45 = load i64, i64* %44
ret i64 %45
}

LLVM IR (-O2):
@str = [35 x i8] c"no the output buffer is larger !!!\00"
define i64 @cryptoshit_decrypt(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = icmp ugt i64 %4, %2
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %1, i64 64
%12 = bitcast i8* %11 to i64*
%13 = getelementptr inbounds i8, i8* %1, i64 96
%14 = bitcast i8* %13 to i64*
%15 = getelementptr inbounds i8, i8* %1, i64 128
%16 = load i64, i64* %14
%17 = tail call i32 @decrypt(i8* %15, i64 %16, i8* %0, i8* %1, i8* %3)
%18 = load i64, i64* %12
ret i64 %18
}