#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_ede3_cbc_encrypt(unsigned char const *, unsigned char *,
                                        int, int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ DES_set_odd_parity(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int decrypt_des(char *cipher, char *text, DES_key_schedule *ks1,
                DES_key_schedule *ks2, DES_key_schedule *ks3,
                DES_cblock *cblock, int cipherLen) {
  memset(cblock, 0, sizeof(DES_cblock));
  DES_set_odd_parity(cblock);
  DES_ede3_cbc_encrypt((const unsigned char *)cipher, (unsigned char *)text,
                       cipherLen, ks1, ks2, ks3, cblock, DES_DECRYPT);
  printf("Decrypted : %s\n", text);
  return 0;
}


x86 assembly (clang, -O0):
<decrypt_des>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x30(%rbp),%rdi
call   1060 <DES_set_odd_parity@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%r10
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <DES_ede3_cbc_encrypt@plt>
mov    -0x10(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt_des>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%rbp
mov    %r9,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1060 <DES_set_odd_parity@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %rbp,%rdi
mov    %r14,%rsi
mov    0x40(%rsp),%edx
mov    %r13,%rcx
mov    %r12,%r8
mov    %r15,%r9
push   %rax
push   %rbx
call   1030 <DES_ede3_cbc_encrypt@plt>
add    $0x10,%rsp
lea    0xe5e(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DES_DECRYPT = global i32 0
@.str = [16 x i8] c"Decrypted : %s\0A\00"
define i32 @decrypt_des(i8* %0, i8* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32 %6, i32* %14
%15 = load i32*, i32** %13
%16 = call i32 @memset(i32* %15, i32 0, i32 4)
%17 = load i32*, i32** %13
%18 = call i32 @DES_set_odd_parity(i32* %17)
%19 = load i8*, i8** %8
%20 = load i8*, i8** %9
%21 = load i32, i32* %14
%22 = load i32*, i32** %10
%23 = load i32*, i32** %11
%24 = load i32*, i32** %12
%25 = load i32*, i32** %13
%26 = load i32, i32* @DES_DECRYPT
%27 = call i32 @DES_ede3_cbc_encrypt(i8* %19, i8* %20, i32 %21, i32* %22, i32* %23, i32* %24, i32* %25, i32 %26)
%28 = load i8*, i8** %9
%29 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %28)
ret i32 0
}

LLVM IR (-O2):
@DES_DECRYPT = global i32 0
@.str = [16 x i8] c"Decrypted : %s\0A\00"
define i32 @decrypt_des(i8* %0, i8* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32 %6) {
%8 = tail call i32 @memset(i32* %5, i32 0, i32 4)
%9 = tail call i32 @DES_set_odd_parity(i32* %5)
%10 = load i32, i32* @DES_DECRYPT
%11 = tail call i32 @DES_ede3_cbc_encrypt(i8* %0, i8* %1, i32 %6, i32* %2, i32* %3, i32* %4, i32* %5, i32 %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %1)
ret i32 0
}