#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*/ close_rand();
int next_rand();
int /*<<< orphan*/ open_rand();
void make_perm(unsigned char box[256], unsigned char ibox[256]) {
  int i, j;
  unsigned char t;
  open_rand();
  for (i = 0; i < 256; i++)
    box[i] = i;
  for (i = 0; i < 256; i++) {
    j = next_rand();
    t = box[i];
    box[i] = box[j];
    box[j] = t;
  }
  close_rand();
  for (i = 0; i < 256; i++) {
    ibox[box[i]] = i;
  }
}


x86 assembly (clang, -O0):
<make_perm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <open_rand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1179 <make_perm+0x49>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <make_perm+0x1e>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    11d7 <make_perm+0xa7>
mov    $0x0,%al
call   1040 <next_rand@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x19(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1180 <make_perm+0x50>
mov    $0x0,%al
call   1050 <close_rand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1218 <make_perm+0xe8>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rsi
movzbl (%rcx,%rsi,1),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e5 <make_perm+0xb5>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_perm>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <open_rand@plt>
movaps 0xeb7(%rip),%xmm0
movups %xmm0,(%r15)
movaps 0xebc(%rip),%xmm0
movups %xmm0,0x10(%r15)
movaps 0xec0(%rip),%xmm0
movups %xmm0,0x20(%r15)
movaps 0xec4(%rip),%xmm0
movups %xmm0,0x30(%r15)
movaps 0xec8(%rip),%xmm0
movups %xmm0,0x40(%r15)
movaps 0xecc(%rip),%xmm0
movups %xmm0,0x50(%r15)
movaps 0xed0(%rip),%xmm0
movups %xmm0,0x60(%r15)
movaps 0xed4(%rip),%xmm0
movups %xmm0,0x70(%r15)
movaps 0xed8(%rip),%xmm0
movups %xmm0,0x80(%r15)
movaps 0xed9(%rip),%xmm0
movups %xmm0,0x90(%r15)
movaps 0xeda(%rip),%xmm0
movups %xmm0,0xa0(%r15)
movaps 0xedb(%rip),%xmm0
movups %xmm0,0xb0(%r15)
movaps 0xedc(%rip),%xmm0
movups %xmm0,0xc0(%r15)
movaps 0xedd(%rip),%xmm0
movups %xmm0,0xd0(%r15)
movaps 0xede(%rip),%xmm0
movups %xmm0,0xe0(%r15)
movaps 0xedf(%rip),%xmm0
movups %xmm0,0xf0(%r15)
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <next_rand@plt>
movzbl (%r15,%rbx,1),%ecx
cltq
movzbl (%r15,%rax,1),%edx
mov    %dl,(%r15,%rbx,1)
mov    %cl,(%r15,%rax,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1220 <make_perm+0xf0>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <close_rand@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%eax
mov    %bl,(%r14,%rax,1)
movzbl 0x1(%r15,%rbx,1),%eax
lea    0x1(%rbx),%ecx
mov    %cl,(%r14,%rax,1)
movzbl 0x2(%r15,%rbx,1),%eax
lea    0x2(%rbx),%ecx
mov    %cl,(%r14,%rax,1)
movzbl 0x3(%r15,%rbx,1),%eax
lea    0x3(%rbx),%ecx
mov    %cl,(%r14,%rax,1)
add    $0x4,%rbx
cmp    $0x100,%rbx
jne    1260 <make_perm+0x130>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @make_perm(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 (...) @open_rand()
store i32 0, i32* %5
br label %9
9: ; preds = %19, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 256
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32, i32* %5
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
store i8 %14, i8* %18
br label %19
19: ; preds = %12
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %9
22: ; preds = %9
store i32 0, i32* %5
br label %23
23: ; preds = %47, %22
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 256
br i1 %25, label %26, label %50
26: ; preds = %23
%27 = call i32 (...) @next_rand()
store i32 %27, i32* %6
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
store i8 %32, i8* %7
%33 = load i8*, i8** %3
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = load i8*, i8** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 %37, i8* %41
%42 = load i8, i8* %7
%43 = load i8*, i8** %3
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 %42, i8* %46
br label %47
47: ; preds = %26
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %23
50: ; preds = %23
%51 = call i32 (...) @close_rand()
store i32 0, i32* %5
br label %52
52: ; preds = %66, %50
%53 = load i32, i32* %5
%54 = icmp slt i32 %53, 256
br i1 %54, label %55, label %69
55: ; preds = %52
%56 = load i32, i32* %5
%57 = trunc i32 %56 to i8
%58 = load i8*, i8** %4
%59 = load i8*, i8** %3
%60 = load i32, i32* %5
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i8, i8* %62
%64 = zext i8 %63 to i64
%65 = getelementptr inbounds i8, i8* %58, i64 %64
store i8 %57, i8* %65
br label %66
66: ; preds = %55
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
store i32 %68, i32* %5
br label %52
69: ; preds = %52
ret void
}

LLVM IR (-O2):
define void @make_perm(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = tail call i32 (...) @open_rand()
%4 = bitcast i8* %0 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %4
%5 = getelementptr inbounds i8, i8* %0, i64 16
%6 = bitcast i8* %5 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %6
%7 = getelementptr inbounds i8, i8* %0, i64 32
%8 = bitcast i8* %7 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %8
%9 = getelementptr inbounds i8, i8* %0, i64 48
%10 = bitcast i8* %9 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %10
%11 = getelementptr inbounds i8, i8* %0, i64 64
%12 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %12
%13 = getelementptr inbounds i8, i8* %0, i64 80
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %14
%15 = getelementptr inbounds i8, i8* %0, i64 96
%16 = bitcast i8* %15 to <16 x i8>*
store <16 x i8> <i8 96, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102, i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111>, <16 x i8>* %16
%17 = getelementptr inbounds i8, i8* %0, i64 112
%18 = bitcast i8* %17 to <16 x i8>*
store <16 x i8> <i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118, i8 119, i8 120, i8 121, i8 122, i8 123, i8 124, i8 125, i8 126, i8 127>, <16 x i8>* %18
%19 = getelementptr inbounds i8, i8* %0, i64 128
%20 = bitcast i8* %19 to <16 x i8>*
store <16 x i8> <i8 -128, i8 -127, i8 -126, i8 -125, i8 -124, i8 -123, i8 -122, i8 -121, i8 -120, i8 -119, i8 -118, i8 -117, i8 -116, i8 -115, i8 -114, i8 -113>, <16 x i8>* %20
%21 = getelementptr inbounds i8, i8* %0, i64 144
%22 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> <i8 -112, i8 -111, i8 -110, i8 -109, i8 -108, i8 -107, i8 -106, i8 -105, i8 -104, i8 -103, i8 -102, i8 -101, i8 -100, i8 -99, i8 -98, i8 -97>, <16 x i8>* %22
%23 = getelementptr inbounds i8, i8* %0, i64 160
%24 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> <i8 -96, i8 -95, i8 -94, i8 -93, i8 -92, i8 -91, i8 -90, i8 -89, i8 -88, i8 -87, i8 -86, i8 -85, i8 -84, i8 -83, i8 -82, i8 -81>, <16 x i8>* %24
%25 = getelementptr inbounds i8, i8* %0, i64 176
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> <i8 -80, i8 -79, i8 -78, i8 -77, i8 -76, i8 -75, i8 -74, i8 -73, i8 -72, i8 -71, i8 -70, i8 -69, i8 -68, i8 -67, i8 -66, i8 -65>, <16 x i8>* %26
%27 = getelementptr inbounds i8, i8* %0, i64 192
%28 = bitcast i8* %27 to <16 x i8>*
store <16 x i8> <i8 -64, i8 -63, i8 -62, i8 -61, i8 -60, i8 -59, i8 -58, i8 -57, i8 -56, i8 -55, i8 -54, i8 -53, i8 -52, i8 -51, i8 -50, i8 -49>, <16 x i8>* %28
%29 = getelementptr inbounds i8, i8* %0, i64 208
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> <i8 -48, i8 -47, i8 -46, i8 -45, i8 -44, i8 -43, i8 -42, i8 -41, i8 -40, i8 -39, i8 -38, i8 -37, i8 -36, i8 -35, i8 -34, i8 -33>, <16 x i8>* %30
%31 = getelementptr inbounds i8, i8* %0, i64 224
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> <i8 -32, i8 -31, i8 -30, i8 -29, i8 -28, i8 -27, i8 -26, i8 -25, i8 -24, i8 -23, i8 -22, i8 -21, i8 -20, i8 -19, i8 -18, i8 -17>, <16 x i8>* %32
%33 = getelementptr inbounds i8, i8* %0, i64 240
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> <i8 -16, i8 -15, i8 -14, i8 -13, i8 -12, i8 -11, i8 -10, i8 -9, i8 -8, i8 -7, i8 -6, i8 -5, i8 -4, i8 -3, i8 -2, i8 -1>, <16 x i8>* %34
br label %35
35: ; preds = %2, %35
%36 = phi i64 [ %43, %35 ], [ 0, %2 ]
%37 = tail call i32 (...) @next_rand()
%38 = getelementptr inbounds i8, i8* %0, i64 %36
%39 = load i8, i8* %38
%40 = sext i32 %37 to i64
%41 = getelementptr inbounds i8, i8* %0, i64 %40
%42 = load i8, i8* %41
store i8 %42, i8* %38
store i8 %39, i8* %41
%43 = add nuw nsw i64 %36, 1
%44 = icmp eq i64 %43, 256
br i1 %44, label %45, label %35
45: ; preds = %35
%46 = tail call i32 (...) @close_rand()
br label %47
47: ; preds = %47, %45
%48 = phi i64 [ 0, %45 ], [ %72, %47 ]
%49 = trunc i64 %48 to i8
%50 = getelementptr inbounds i8, i8* %0, i64 %48
%51 = load i8, i8* %50
%52 = zext i8 %51 to i64
%53 = getelementptr inbounds i8, i8* %1, i64 %52
store i8 %49, i8* %53
%54 = or i64 %48, 1
%55 = trunc i64 %54 to i8
%56 = getelementptr inbounds i8, i8* %0, i64 %54
%57 = load i8, i8* %56
%58 = zext i8 %57 to i64
%59 = getelementptr inbounds i8, i8* %1, i64 %58
store i8 %55, i8* %59
%60 = or i64 %48, 2
%61 = trunc i64 %60 to i8
%62 = getelementptr inbounds i8, i8* %0, i64 %60
%63 = load i8, i8* %62
%64 = zext i8 %63 to i64
%65 = getelementptr inbounds i8, i8* %1, i64 %64
store i8 %61, i8* %65
%66 = or i64 %48, 3
%67 = trunc i64 %66 to i8
%68 = getelementptr inbounds i8, i8* %0, i64 %66
%69 = load i8, i8* %68
%70 = zext i8 %69 to i64
%71 = getelementptr inbounds i8, i8* %1, i64 %70
store i8 %67, i8* %71
%72 = add nuw nsw i64 %48, 4
%73 = icmp eq i64 %72, 256
br i1 %73, label %74, label %47
74: ; preds = %47
ret void
}