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

/* Variables and functions */
int DES_ENCRYPT;
int /*<<< orphan*/ DES_ecb_encrypt(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int);
int /*<<< orphan*/ DES_set_key_unchecked(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
void xvp_password_crypt_vnc(char *src, char *dst, int direction) {
  static char key[] = {0xc1, 0x24, 0x08, 0x99, 0xc2, 0x26, 0x07, 0x05};
  static char tmp[8];
  DES_key_schedule schedule;
  if (direction == DES_ENCRYPT)
    strncpy(tmp, src, sizeof(tmp));
  else
    memcpy(tmp, src, sizeof(tmp));
  DES_set_key_unchecked((DES_cblock *)key, &schedule);
  DES_ecb_encrypt((DES_cblock *)tmp, (DES_cblock *)dst, &schedule, direction);
}


x86 assembly (clang, -O0):
<xvp_password_crypt_vnc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%eax
jne    117f <xvp_password_crypt_vnc+0x3f>
mov    -0x8(%rbp),%rsi
lea    0x2edc(%rip),%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
jmp    1194 <xvp_password_crypt_vnc+0x54>
mov    -0x8(%rbp),%rsi
lea    0x2ec2(%rip),%rdi
mov    $0x8,%edx
call   1050 <memcpy@plt>
lea    0x2ea5(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <DES_set_key_unchecked@plt>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%ecx
lea    0x2e9a(%rip),%rdi
lea    -0x18(%rbp),%rdx
call   1040 <DES_ecb_encrypt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xvp_password_crypt_vnc>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%rsi
mov    0x2e88(%rip),%rax
cmp    %edx,(%rax)
jne    116f <xvp_password_crypt_vnc+0x2f>
lea    0x2ee9(%rip),%rdi
mov    $0x8,%edx
call   1030 <strncpy@plt>
jmp    1180 <xvp_password_crypt_vnc+0x40>
lea    0x2ed6(%rip),%rdi
mov    $0x8,%edx
call   1050 <memcpy@plt>
lea    0x2eb9(%rip),%rdi
lea    0xc(%rsp),%r15
mov    %r15,%rsi
call   1060 <DES_set_key_unchecked@plt>
lea    0x2eb1(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1040 <DES_ecb_encrypt@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@xvp_password_crypt_vnc.key = internal global [8 x i8] c"\C1$\08\99\C2&\07\05"
@xvp_password_crypt_vnc.tmp = internal global [8 x i8] zeroinitializer
@DES_ENCRYPT = global i32 0
define void @xvp_password_crypt_vnc(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i32, i32* @DES_ENCRYPT
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = call i32 @strncpy(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @xvp_password_crypt_vnc.tmp, i64 0, i64 0), i8* %12, i32 8)
br label %17
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i32 @memcpy(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @xvp_password_crypt_vnc.tmp, i64 0, i64 0), i8* %15, i32 8)
br label %17
17: ; preds = %14, %11
%18 = call i32 @DES_set_key_unchecked(i32* bitcast ([8 x i8]* @xvp_password_crypt_vnc.key to i32*), i32* %7)
%19 = load i8*, i8** %5
%20 = bitcast i8* %19 to i32*
%21 = load i32, i32* %6
%22 = call i32 @DES_ecb_encrypt(i32* bitcast ([8 x i8]* @xvp_password_crypt_vnc.tmp to i32*), i32* %20, i32* %7, i32 %21)
ret void
}

LLVM IR (-O2):
@xvp_password_crypt_vnc.key = internal global [8 x i8] c"\C1$\08\99\C2&\07\05"
@xvp_password_crypt_vnc.tmp = internal global [8 x i8] zeroinitializer
@DES_ENCRYPT = global i32 0
define void @xvp_password_crypt_vnc(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = load i32, i32* @DES_ENCRYPT
%7 = icmp eq i32 %6, %2
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @strncpy(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @xvp_password_crypt_vnc.tmp, i64 0, i64 0), i8* %0, i32 8)
br label %12
10: ; preds = %3
%11 = tail call i32 @memcpy(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @xvp_password_crypt_vnc.tmp, i64 0, i64 0), i8* %0, i32 8)
br label %12
12: ; preds = %10, %8
%13 = call i32 @DES_set_key_unchecked(i32* bitcast ([8 x i8]* @xvp_password_crypt_vnc.key to i32*), i32* %4)
%14 = bitcast i8* %1 to i32*
%15 = call i32 @DES_ecb_encrypt(i32* bitcast ([8 x i8]* @xvp_password_crypt_vnc.tmp to i32*), i32* %14, i32* %4, i32 %2)
ret void
}