#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int *, int *, int);
int rl(int);
void rk(uint8_t *key, uint8_t n, uint8_t *outp_key) {
  memcpy(outp_key, key, 8);
  uint8_t j;
  while (n-- > 0)
    for (j = 0; j < 8; j++)
      outp_key[j] = rl(outp_key[j]);
  return;
}


x86 assembly (clang, -O0):
<rk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    119a <rk+0x7a>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    1195 <rk+0x75>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <rl@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1160 <rk+0x40>
jmp    1145 <rk+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rk>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%rsi
mov    %rdx,%rdi
mov    $0x8,%edx
call   1030 <memcpy@plt>
test   %ebp,%ebp
jle    119e <rk+0x7e>
add    $0x1,%ebp
nop
mov    (%rbx),%edi
call   1040 <rl@plt>
mov    %eax,(%rbx)
mov    0x4(%rbx),%edi
call   1040 <rl@plt>
mov    %eax,0x4(%rbx)
mov    0x8(%rbx),%edi
call   1040 <rl@plt>
mov    %eax,0x8(%rbx)
mov    0xc(%rbx),%edi
call   1040 <rl@plt>
mov    %eax,0xc(%rbx)
mov    0x10(%rbx),%edi
call   1040 <rl@plt>
mov    %eax,0x10(%rbx)
mov    0x14(%rbx),%edi
call   1040 <rl@plt>
mov    %eax,0x14(%rbx)
mov    0x18(%rbx),%edi
call   1040 <rl@plt>
mov    %eax,0x18(%rbx)
mov    0x1c(%rbx),%edi
call   1040 <rl@plt>
mov    %eax,0x1c(%rbx)
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1140 <rk+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @rk(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%8 = load i32*, i32** %6
%9 = load i32*, i32** %4
%10 = call i32 @memcpy(i32* %8, i32* %9, i32 8)
br label %11
11: ; preds = %33, %3
%12 = load i32, i32* %5
%13 = add nsw i32 %12, -1
store i32 %13, i32* %5
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %34
15: ; preds = %11
store i32 0, i32* %7
br label %16
16: ; preds = %30, %15
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 8
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = load i32*, i32** %6
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = call i32 @rl(i32 %24)
%26 = load i32*, i32** %6
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %25, i32* %29
br label %30
30: ; preds = %19
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %16
33: ; preds = %16
br label %11
34: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @rk(i32* %0, i32 %1, i32* %2) {
%4 = tail call i32 @memcpy(i32* %2, i32* %0, i32 8)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %34
6: ; preds = %3
%7 = getelementptr inbounds i32, i32* %2, i64 1
%8 = getelementptr inbounds i32, i32* %2, i64 2
%9 = getelementptr inbounds i32, i32* %2, i64 3
%10 = getelementptr inbounds i32, i32* %2, i64 4
%11 = getelementptr inbounds i32, i32* %2, i64 5
%12 = getelementptr inbounds i32, i32* %2, i64 6
%13 = getelementptr inbounds i32, i32* %2, i64 7
br label %14
14: ; preds = %6, %14
%15 = phi i32 [ %32, %14 ], [ %1, %6 ]
%16 = load i32, i32* %2
%17 = tail call i32 @rl(i32 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %7
%19 = tail call i32 @rl(i32 %18)
store i32 %19, i32* %7
%20 = load i32, i32* %8
%21 = tail call i32 @rl(i32 %20)
store i32 %21, i32* %8
%22 = load i32, i32* %9
%23 = tail call i32 @rl(i32 %22)
store i32 %23, i32* %9
%24 = load i32, i32* %10
%25 = tail call i32 @rl(i32 %24)
store i32 %25, i32* %10
%26 = load i32, i32* %11
%27 = tail call i32 @rl(i32 %26)
store i32 %27, i32* %11
%28 = load i32, i32* %12
%29 = tail call i32 @rl(i32 %28)
store i32 %29, i32* %12
%30 = load i32, i32* %13
%31 = tail call i32 @rl(i32 %30)
store i32 %31, i32* %13
%32 = add nsw i32 %15, -1
%33 = icmp ugt i32 %15, 1
br i1 %33, label %14, label %34
34: ; preds = %14, %3
ret void
}