#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*/ DES_key_schedule;
typedef int /*<<< orphan*/ DES_cblock;

/* Variables and functions */
int /*<<< orphan*/ DES_DECRYPT;
int /*<<< orphan*/ DES_cfb64_encrypt(unsigned char *, unsigned char *, int,
                                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                     int *, int /*<<< orphan*/);
int /*<<< orphan*/ DES_set_key_checked(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ DES_set_odd_parity(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, char *, int);
char *_decrypt(char *key, char *msg, int size) {
  static char *shellcode;
  int num = 0;
  DES_cblock keycopy;
  DES_key_schedule schedule;
  shellcode = (char *)malloc(size);
  memcpy(keycopy, key, 8);
  DES_set_odd_parity(&keycopy);
  DES_set_key_checked(&keycopy, &schedule);
  DES_cfb64_encrypt((unsigned char *)msg, (unsigned char *)shellcode, size,
                    &schedule, &keycopy, &num, DES_DECRYPT);
  return (shellcode);
}


x86 assembly (clang, -O0):
<_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,0x2ed7(%rip)
mov    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
lea    -0x1c(%rbp),%rdi
call   1070 <DES_set_odd_parity@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <DES_set_key_checked@plt>
mov    -0x10(%rbp),%rdi
mov    0x2ea5(%rip),%rsi
mov    -0x14(%rbp),%edx
mov    0x2e2b(%rip),%rax
mov    (%rax),%eax
lea    -0x20(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x18(%rbp),%r9
mov    %eax,(%rsp)
call   1030 <DES_cfb64_encrypt@plt>
mov    0x2e7e(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_decrypt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
mov    %edx,%edi
call   1050 <malloc@plt>
mov    %rax,0x2ed8(%rip)
mov    %rbx,%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
lea    0x14(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <DES_set_odd_parity@plt>
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <DES_set_key_checked@plt>
mov    0x2ea7(%rip),%rsi
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
lea    0xc(%rsp),%r9
mov    %r14,%rdi
mov    %ebp,%edx
mov    %r15,%rcx
mov    %rbx,%r8
call   1030 <DES_cfb64_encrypt@plt>
mov    0x2e7f(%rip),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@_decrypt.shellcode = internal global i8* null
@DES_DECRYPT = global i32 0
define i8* @_decrypt(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%10 = load i32, i32* %6
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** @_decrypt.shellcode
%13 = load i32, i32* %8
%14 = load i8*, i8** %4
%15 = call i32 @memcpy(i32 %13, i8* %14, i32 8)
%16 = call i32 @DES_set_odd_parity(i32* %8)
%17 = call i32 @DES_set_key_checked(i32* %8, i32* %9)
%18 = load i8*, i8** %5
%19 = load i8*, i8** @_decrypt.shellcode
%20 = load i32, i32* %6
%21 = load i32, i32* @DES_DECRYPT
%22 = call i32 @DES_cfb64_encrypt(i8* %18, i8* %19, i32 %20, i32* %9, i32* %8, i32* %7, i32 %21)
%23 = load i8*, i8** @_decrypt.shellcode
ret i8* %23
}

LLVM IR (-O2):
@_decrypt.shellcode = internal unnamed_addr global i8* null
@DES_DECRYPT = global i32 0
define i8* @_decrypt(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = tail call i64 @malloc(i32 %2)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** @_decrypt.shellcode
%12 = tail call i32 @memcpy(i32 undef, i8* %0, i32 8)
%13 = call i32 @DES_set_odd_parity(i32* %5)
%14 = call i32 @DES_set_key_checked(i32* %5, i32* %6)
%15 = load i8*, i8** @_decrypt.shellcode
%16 = load i32, i32* @DES_DECRYPT
%17 = call i32 @DES_cfb64_encrypt(i8* %1, i8* %15, i32 %2, i32* %6, i32* %5, i32* %4, i32 %16)
%18 = load i8*, i8** @_decrypt.shellcode
ret i8* %18
}