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

/* Variables and functions */
unsigned char *des_key_spread(unsigned char *, unsigned char *);
int /*<<< orphan*/ doPC1(unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
unsigned char *des_login_key_get(unsigned char *key1, unsigned char *key2,
                                 int len, unsigned char *des16) {
  unsigned char des14[14];
  int i;
  memcpy(des14, key1, sizeof(des14));
  for (i = 0; i < len; i++)
    des14[i % 14] ^= key2[i];
  des16 = des_key_spread(des14, des16);
  doPC1(des16);
  doPC1(des16 + 8);
  return des16;
}


x86 assembly (clang, -O0):
<des_login_key_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x2e(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0xe,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a6 <des_login_key_get+0x76>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    $0xe,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x38(%rbp),%edx
cltq
movzbl -0x2e(%rbp,%rax,1),%ecx
xor    %edx,%ecx
mov    %cl,-0x2e(%rbp,%rax,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1160 <des_login_key_get+0x30>
lea    -0x2e(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <des_key_spread@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <doPC1@plt>
mov    -0x20(%rbp),%rdi
add    $0x8,%rdi
call   1040 <doPC1@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<des_login_key_get>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xa(%rsp),%rdi
mov    $0xe,%edx
call   1030 <memcpy@plt>
test   %ebp,%ebp
jle    121b <des_login_key_get+0xeb>
mov    %ebp,%r8d
xor    %r11d,%r11d
cmp    $0x1,%ebp
je     11ed <des_login_key_get+0xbd>
lea    0x1(%r14),%rdx
mov    %r8d,%r10d
and    $0xfffffffe,%r10d
neg    %r10
mov    $0x1,%edi
mov    $0x92492493,%r9d
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %edi,%ecx
shr    %ecx
imul   %r9,%rcx
shr    $0x22,%rcx
mov    %ecx,%ebp
shl    $0x4,%ebp
mov    %ecx,%esi
sub    %ebp,%esi
add    %ecx,%esi
add    %edi,%esi
mov    %r11d,%ecx
shr    %ecx
imul   %r9,%rcx
shr    $0x22,%rcx
mov    %ecx,%ebp
shl    $0x4,%ebp
mov    %ecx,%ebx
sub    %ebp,%ebx
add    %ecx,%ebx
add    %r11d,%ebx
movzbl -0x1(%rdx),%ecx
xor    %cl,0xa(%rsp,%rbx,1)
movzbl (%rdx),%ecx
xor    %cl,0xa(%rsp,%rsi,1)
add    $0x2,%rdx
add    $0x2,%edi
add    $0xfffffffffffffffe,%rax
add    $0x2,%r11d
cmp    %rax,%r10
jne    1190 <des_login_key_get+0x60>
neg    %rax
mov    %rax,%r11
test   $0x1,%r8b
je     121b <des_login_key_get+0xeb>
mov    (%r14,%r11,1),%al
mov    %r11d,%ecx
shr    %ecx
mov    $0x92492493,%edx
imul   %rcx,%rdx
shr    $0x22,%rdx
mov    %edx,%ecx
shl    $0x4,%ecx
mov    %edx,%esi
sub    %ecx,%esi
add    %edx,%esi
add    %r11d,%esi
xor    %al,0xa(%rsp,%rsi,1)
lea    0xa(%rsp),%rdi
mov    %r15,%rsi
call   1050 <des_key_spread@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <doPC1@plt>
lea    0x8(%rbx),%rdi
call   1040 <doPC1@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @des_login_key_get(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [14 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%12 = load i8*, i8** %5
%13 = call i32 @memcpy(i8* %11, i8* %12, i32 14)
store i32 0, i32* %10
br label %14
14: ; preds = %33, %4
%15 = load i32, i32* %10
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %36
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = load i32, i32* %10
%26 = srem i32 %25, 14
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = xor i32 %30, %24
%32 = trunc i32 %31 to i8
store i8 %32, i8* %28
br label %33
33: ; preds = %18
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %14
36: ; preds = %14
%37 = getelementptr inbounds [14 x i8], [14 x i8]* %9, i64 0, i64 0
%38 = load i8*, i8** %8
%39 = call i8* @des_key_spread(i8* %37, i8* %38)
store i8* %39, i8** %8
%40 = load i8*, i8** %8
%41 = call i32 @doPC1(i8* %40)
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i64 8
%44 = call i32 @doPC1(i8* %43)
%45 = load i8*, i8** %8
ret i8* %45
}

LLVM IR (-O2):
define i8* @des_login_key_get(i8* %0, i8* nocapture %1, i32 %2, i8* %3) {
%5 = alloca [14 x i8]
%6 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 0
%7 = call i32 @memcpy(i8* %6, i8* %0, i32 14)
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %50
9: ; preds = %4
%10 = zext i32 %2 to i64
%11 = and i64 %10, 1
%12 = icmp eq i32 %2, 1
br i1 %12, label %38, label %13
13: ; preds = %9
%14 = and i64 %10, 4294967294
br label %15
15: ; preds = %15, %13
%16 = phi i64 [ 0, %13 ], [ %35, %15 ]
%17 = phi i64 [ 0, %13 ], [ %36, %15 ]
%18 = getelementptr inbounds i8, i8* %1, i64 %16
%19 = load i8, i8* %18
%20 = trunc i64 %16 to i32
%21 = urem i32 %20, 14
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = xor i8 %24, %19
store i8 %25, i8* %23
%26 = or i64 %16, 1
%27 = getelementptr inbounds i8, i8* %1, i64 %26
%28 = load i8, i8* %27
%29 = trunc i64 %26 to i32
%30 = urem i32 %29, 14
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = xor i8 %33, %28
store i8 %34, i8* %32
%35 = add nuw nsw i64 %16, 2
%36 = add i64 %17, 2
%37 = icmp eq i64 %36, %14
br i1 %37, label %38, label %15
38: ; preds = %15, %9
%39 = phi i64 [ 0, %9 ], [ %35, %15 ]
%40 = icmp eq i64 %11, 0
br i1 %40, label %50, label %41
41: ; preds = %38
%42 = getelementptr inbounds i8, i8* %1, i64 %39
%43 = load i8, i8* %42
%44 = trunc i64 %39 to i32
%45 = urem i32 %44, 14
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = xor i8 %48, %43
store i8 %49, i8* %47
br label %50
50: ; preds = %41, %38, %4
%51 = call i8* @des_key_spread(i8* %6, i8* %3)
%52 = call i32 @doPC1(i8* %51)
%53 = getelementptr inbounds i8, i8* %51, i64 8
%54 = call i32 @doPC1(i8* %53)
ret i8* %51
}