#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*/ memcpy(unsigned char *, unsigned char *, int);
void permutation(unsigned char *org, const unsigned char *tab) {
  unsigned char tmp[64];
  int i;
  memcpy(tmp, org, 64);
  for (i = 0; i < 64; i++) {
    org[i] = tmp[tab[i]];
  }
}


x86 assembly (clang, -O0):
<permutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x40,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x40,-0x54(%rbp)
jge    116c <permutation+0x5c>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x50(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1139 <permutation+0x29>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permutation>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
nop
movzbl (%r14,%rax,1),%ecx
movzbl (%rsp,%rcx,1),%ecx
mov    %cl,(%rbx,%rax,1)
movzbl 0x1(%r14,%rax,1),%ecx
movzbl (%rsp,%rcx,1),%ecx
mov    %cl,0x1(%rbx,%rax,1)
movzbl 0x2(%r14,%rax,1),%ecx
movzbl (%rsp,%rcx,1),%ecx
mov    %cl,0x2(%rbx,%rax,1)
movzbl 0x3(%r14,%rax,1),%ecx
movzbl (%rsp,%rcx,1),%ecx
mov    %cl,0x3(%rbx,%rax,1)
add    $0x4,%rax
cmp    $0x40,%rax
jne    1130 <permutation+0x20>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @permutation(i8* %0, i8* nocapture %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = call i32 @memcpy(i8* %4, i8* %0, i32 64)
br label %6
6: ; preds = %6, %2
%7 = phi i64 [ 0, %2 ], [ %35, %6 ]
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
%10 = zext i8 %9 to i64
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 %7
store i8 %12, i8* %13
%14 = or i64 %7, 1
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
%17 = zext i8 %16 to i64
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 %19, i8* %20
%21 = or i64 %7, 2
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i64
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %0, i64 %21
store i8 %26, i8* %27
%28 = or i64 %7, 3
%29 = getelementptr inbounds i8, i8* %1, i64 %28
%30 = load i8, i8* %29
%31 = zext i8 %30 to i64
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = getelementptr inbounds i8, i8* %0, i64 %28
store i8 %33, i8* %34
%35 = add nuw nsw i64 %7, 4
%36 = icmp eq i64 %35, 64
br i1 %36, label %37, label %6
37: ; preds = %6
ret void
}