#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*/ CSStitlekey1(unsigned char *, unsigned char *);
int /*<<< orphan*/ CSStitlekey2(unsigned char *, unsigned char *);
void CSSdecrypttitlekey(unsigned char *tkey, unsigned char *dkey) {
  int i;
  unsigned char im1[6];
  unsigned char im2[6] = {0x51, 0x67, 0x67, 0xc5, 0xe0, 0x00};
  for (i = 0; i < 6; i++)
    im1[i] = dkey[i];
  CSStitlekey1(im1, im2);
  CSStitlekey2(tkey, im1);
}


x86 assembly (clang, -O0):
<CSSdecrypttitlekey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeca(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xec4(%rip),%ax
mov    %ax,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    1176 <CSSdecrypttitlekey+0x56>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x1a(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <CSSdecrypttitlekey+0x2b>
lea    -0x1a(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <CSStitlekey1@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1030 <CSStitlekey2@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CSSdecrypttitlekey>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movw   $0xe0,0xc(%rsp)
movl   $0xc5676751,0x8(%rsp)
c5
mov    (%rsi),%eax
mov    %eax,0x10(%rsp)
movzwl 0x4(%rsi),%eax
mov    %ax,0x14(%rsp)
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <CSStitlekey1@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <CSStitlekey2@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.CSSdecrypttitlekey.im2 = [6 x i8] c"Qgg\C5\E0\00"
define void @CSSdecrypttitlekey(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [6 x i8]
%7 = alloca [6 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = bitcast [6 x i8]* %7 to i8*
store i32 0, i32* %5
br label %9
9: ; preds = %21, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 6
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %19
store i8 %17, i8* %20
br label %21
21: ; preds = %12
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %9
24: ; preds = %9
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%26 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%27 = call i32 @CSStitlekey1(i8* %25, i8* %26)
%28 = load i8*, i8** %3
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%30 = call i32 @CSStitlekey2(i8* %28, i8* %29)
ret void
}

LLVM IR (-O2):
@__const.CSSdecrypttitlekey.im2 = [6 x i8] c"Qgg\C5\E0\00"
define void @CSSdecrypttitlekey(i8* %0, i8* nocapture %1) {
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%5 = alloca [6 x i8]
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%8 = call i32 @CSStitlekey1(i8* %6, i8* %7)
%9 = call i32 @CSStitlekey2(i8* %0, i8* %6)
ret void
}