#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ memcpy(int *, int *, int);
void dezigzagBlock(const int index[], int block[]) {
  int *temp_arr = malloc(sizeof(int) * 64);
  int i;
  for (i = 0; i < 64; i++) {
    temp_arr[i] = block[index[i]];
  }
  memcpy(block, temp_arr, sizeof(int) * 64);
  free(temp_arr);
}


x86 assembly (clang, -O0):
<dezigzagBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x40,-0x1c(%rbp)
jge    118b <dezigzagBlock+0x5b>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,4),%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    1155 <dezigzagBlock+0x25>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x100,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dezigzagBlock>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x100,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    $0x3,%eax
nopl   (%rax)
movslq -0xc(%rbx,%rax,4),%rcx
mov    (%r14,%rcx,4),%ecx
mov    %ecx,-0xc(%r15,%rax,4)
movslq -0x8(%rbx,%rax,4),%rcx
mov    (%r14,%rcx,4),%ecx
mov    %ecx,-0x8(%r15,%rax,4)
movslq -0x4(%rbx,%rax,4),%rcx
mov    (%r14,%rcx,4),%ecx
mov    %ecx,-0x4(%r15,%rax,4)
movslq (%rbx,%rax,4),%rcx
mov    (%r14,%rcx,4),%ecx
mov    %ecx,(%r15,%rax,4)
add    $0x4,%rax
cmp    $0x43,%rax
jne    1150 <dezigzagBlock+0x20>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x100,%edx
call   1040 <memcpy@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

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

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