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

/* Variables and functions */
int /*<<< orphan*/ rfbDes(unsigned char *, unsigned char *);
int /*<<< orphan*/ rfbDesKey(unsigned char *, int /*<<< orphan*/);
unsigned int strlen(char const *);
void rfbEncryptBytes(unsigned char *bytes, const char *passwd) {
  unsigned char key[8];
  unsigned int i;
  for (i = 0; i < 8; i++) {
    if (i < strlen(passwd)) {
      key[i] = passwd[i];
    } else {
      key[i] = 0;
    }
  }
  rfbDesKey(key, 0);
  for (i = 0; i < 16; i += 8) {
    rfbDes(bytes + i, bytes + i);
  }
}


x86 assembly (clang, -O0):
<rfbEncryptBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jae    119e <rfbEncryptBytes+0x6e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jae    1183 <rfbEncryptBytes+0x53>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,1),%cl
mov    -0x1c(%rbp),%eax
mov    %cl,-0x18(%rbp,%rax,1)
jmp    118b <rfbEncryptBytes+0x5b>
mov    -0x1c(%rbp),%eax
movb   $0x0,-0x18(%rbp,%rax,1)
jmp    1190 <rfbEncryptBytes+0x60>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <rfbEncryptBytes+0x17>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <rfbDesKey@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jae    11e1 <rfbEncryptBytes+0xb1>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%eax
add    %rax,%rsi
call   1050 <rfbDes@plt>
mov    -0x1c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b0 <rfbEncryptBytes+0x80>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rfbEncryptBytes>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     114a <rfbEncryptBytes+0x1a>
mov    (%rbx),%al
jmp    114c <rfbEncryptBytes+0x1c>
xor    %eax,%eax
mov    %al,(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jb     1161 <rfbEncryptBytes+0x31>
mov    0x1(%rbx),%al
jmp    1163 <rfbEncryptBytes+0x33>
xor    %eax,%eax
mov    %al,0x1(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jb     1179 <rfbEncryptBytes+0x49>
mov    0x2(%rbx),%al
jmp    117b <rfbEncryptBytes+0x4b>
xor    %eax,%eax
mov    %al,0x2(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x4,%eax
jb     1191 <rfbEncryptBytes+0x61>
mov    0x3(%rbx),%al
jmp    1193 <rfbEncryptBytes+0x63>
xor    %eax,%eax
mov    %al,0x3(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
jb     11a9 <rfbEncryptBytes+0x79>
mov    0x4(%rbx),%al
jmp    11ab <rfbEncryptBytes+0x7b>
xor    %eax,%eax
mov    %al,0x4(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x6,%eax
jb     11c1 <rfbEncryptBytes+0x91>
mov    0x5(%rbx),%al
jmp    11c3 <rfbEncryptBytes+0x93>
xor    %eax,%eax
mov    %al,0x5(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x7,%eax
jb     11d9 <rfbEncryptBytes+0xa9>
mov    0x6(%rbx),%al
jmp    11db <rfbEncryptBytes+0xab>
xor    %eax,%eax
mov    %al,0x6(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x8,%eax
jb     11f1 <rfbEncryptBytes+0xc1>
mov    0x7(%rbx),%al
jmp    11f3 <rfbEncryptBytes+0xc3>
xor    %eax,%eax
mov    %al,0x7(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <rfbDesKey@plt>
mov    %r14,%rdi
mov    %r14,%rsi
call   1050 <rfbDes@plt>
add    $0x8,%r14
mov    %r14,%rdi
mov    %r14,%rsi
call   1050 <rfbDes@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @rfbEncryptBytes(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [8 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
br label %7
7: ; preds = %29, %2
%8 = load i32, i32* %6
%9 = icmp ult i32 %8, 8
br i1 %9, label %10, label %32
10: ; preds = %7
%11 = load i32, i32* %6
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = icmp ult i32 %11, %13
br i1 %14, label %15, label %24
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = load i32, i32* %6
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = load i32, i32* %6
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 %22
store i8 %20, i8* %23
br label %28
24: ; preds = %10
%25 = load i32, i32* %6
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %24, %15
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add i32 %30, 1
store i32 %31, i32* %6
br label %7
32: ; preds = %7
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%34 = call i32 @rfbDesKey(i8* %33, i32 0)
store i32 0, i32* %6
br label %35
35: ; preds = %48, %32
%36 = load i32, i32* %6
%37 = icmp ult i32 %36, 16
br i1 %37, label %38, label %51
38: ; preds = %35
%39 = load i8*, i8** %3
%40 = load i32, i32* %6
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8*, i8** %3
%44 = load i32, i32* %6
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = call i32 @rfbDes(i8* %42, i8* %46)
br label %48
48: ; preds = %38
%49 = load i32, i32* %6
%50 = add i32 %49, 8
store i32 %50, i32* %6
br label %35
51: ; preds = %35
ret void
}

LLVM IR (-O2):
define void @rfbEncryptBytes(i8* %0, i8* %1) {
%3 = alloca [8 x i8]
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = load i8, i8* %1
br label %9
9: ; preds = %2, %7
%10 = phi i8 [ %8, %7 ], [ 0, %2 ]
store i8 %10, i8* %4
%11 = tail call i32 @strlen(i8* %1)
%12 = icmp ugt i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %1, i64 1
%15 = load i8, i8* %14
br label %16
16: ; preds = %9, %13
%17 = phi i8 [ %15, %13 ], [ 0, %9 ]
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 1
store i8 %17, i8* %18
%19 = tail call i32 @strlen(i8* %1)
%20 = icmp ugt i32 %19, 2
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %1, i64 2
%23 = load i8, i8* %22
br label %24
24: ; preds = %16, %21
%25 = phi i8 [ %23, %21 ], [ 0, %16 ]
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 2
store i8 %25, i8* %26
%27 = tail call i32 @strlen(i8* %1)
%28 = icmp ugt i32 %27, 3
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = getelementptr inbounds i8, i8* %1, i64 3
%31 = load i8, i8* %30
br label %32
32: ; preds = %24, %29
%33 = phi i8 [ %31, %29 ], [ 0, %24 ]
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 3
store i8 %33, i8* %34
%35 = tail call i32 @strlen(i8* %1)
%36 = icmp ugt i32 %35, 4
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = getelementptr inbounds i8, i8* %1, i64 4
%39 = load i8, i8* %38
br label %40
40: ; preds = %32, %37
%41 = phi i8 [ %39, %37 ], [ 0, %32 ]
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 4
store i8 %41, i8* %42
%43 = tail call i32 @strlen(i8* %1)
%44 = icmp ugt i32 %43, 5
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = getelementptr inbounds i8, i8* %1, i64 5
%47 = load i8, i8* %46
br label %48
48: ; preds = %40, %45
%49 = phi i8 [ %47, %45 ], [ 0, %40 ]
%50 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 5
store i8 %49, i8* %50
%51 = tail call i32 @strlen(i8* %1)
%52 = icmp ugt i32 %51, 6
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = getelementptr inbounds i8, i8* %1, i64 6
%55 = load i8, i8* %54
br label %56
56: ; preds = %48, %53
%57 = phi i8 [ %55, %53 ], [ 0, %48 ]
%58 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 6
store i8 %57, i8* %58
%59 = tail call i32 @strlen(i8* %1)
%60 = icmp ugt i32 %59, 7
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = getelementptr inbounds i8, i8* %1, i64 7
%63 = load i8, i8* %62
br label %64
64: ; preds = %56, %61
%65 = phi i8 [ %63, %61 ], [ 0, %56 ]
%66 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 7
store i8 %65, i8* %66
%67 = call i32 @rfbDesKey(i8* %4, i32 0)
%68 = call i32 @rfbDes(i8* %0, i8* %0)
%69 = getelementptr inbounds i8, i8* %0, i64 8
%70 = call i32 @rfbDes(i8* %69, i8* %69)
ret void
}