void sliceMatrix(double ***threadData, double **data) {
  int k = 0;
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 16 / 8; j++) {
      threadData[i][j] = data[k++];
    }
  }
}


x86 assembly (clang, -O0):
<sliceMatrix>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    1180 <sliceMatrix+0x80>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    116d <sliceMatrix+0x6d>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <sliceMatrix+0x2b>
jmp    1172 <sliceMatrix+0x72>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    111a <sliceMatrix+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<sliceMatrix>:
mov    (%rsi),%rax
mov    (%rdi),%rcx
mov    %rax,(%rcx)
mov    0x8(%rsi),%rax
mov    (%rdi),%rcx
mov    %rax,0x8(%rcx)
mov    0x10(%rsi),%rax
mov    0x8(%rdi),%rcx
mov    %rax,(%rcx)
mov    0x18(%rsi),%rax
mov    0x8(%rdi),%rcx
mov    %rax,0x8(%rcx)
mov    0x20(%rsi),%rax
mov    0x10(%rdi),%rcx
mov    %rax,(%rcx)
mov    0x28(%rsi),%rax
mov    0x10(%rdi),%rcx
mov    %rax,0x8(%rcx)
mov    0x30(%rsi),%rax
mov    0x18(%rdi),%rcx
mov    %rax,(%rcx)
mov    0x38(%rsi),%rax
mov    0x18(%rdi),%rcx
mov    %rax,0x8(%rcx)
mov    0x40(%rsi),%rax
mov    0x20(%rdi),%rcx
mov    %rax,(%rcx)
mov    0x48(%rsi),%rax
mov    0x20(%rdi),%rcx
mov    %rax,0x8(%rcx)
mov    0x50(%rsi),%rax
mov    0x28(%rdi),%rcx
mov    %rax,(%rcx)
mov    0x58(%rsi),%rax
mov    0x28(%rdi),%rcx
mov    %rax,0x8(%rcx)
mov    0x60(%rsi),%rax
mov    0x30(%rdi),%rcx
mov    %rax,(%rcx)
mov    0x68(%rsi),%rax
mov    0x30(%rdi),%rcx
mov    %rax,0x8(%rcx)
mov    0x70(%rsi),%rax
mov    0x38(%rdi),%rcx
mov    %rax,(%rcx)
mov    0x78(%rsi),%rax
mov    0x38(%rdi),%rcx
mov    %rax,0x8(%rcx)
ret

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

LLVM IR (-O2):
define void @sliceMatrix(double*** nocapture %0, double** nocapture %1) {
%3 = load double*, double** %1
%4 = load double**, double*** %0
store double* %3, double** %4
%5 = getelementptr inbounds double*, double** %1, i64 1
%6 = load double*, double** %5
%7 = load double**, double*** %0
%8 = getelementptr inbounds double*, double** %7, i64 1
store double* %6, double** %8
%9 = getelementptr inbounds double**, double*** %0, i64 1
%10 = getelementptr inbounds double*, double** %1, i64 2
%11 = load double*, double** %10
%12 = load double**, double*** %9
store double* %11, double** %12
%13 = getelementptr inbounds double*, double** %1, i64 3
%14 = load double*, double** %13
%15 = load double**, double*** %9
%16 = getelementptr inbounds double*, double** %15, i64 1
store double* %14, double** %16
%17 = getelementptr inbounds double**, double*** %0, i64 2
%18 = getelementptr inbounds double*, double** %1, i64 4
%19 = load double*, double** %18
%20 = load double**, double*** %17
store double* %19, double** %20
%21 = getelementptr inbounds double*, double** %1, i64 5
%22 = load double*, double** %21
%23 = load double**, double*** %17
%24 = getelementptr inbounds double*, double** %23, i64 1
store double* %22, double** %24
%25 = getelementptr inbounds double**, double*** %0, i64 3
%26 = getelementptr inbounds double*, double** %1, i64 6
%27 = load double*, double** %26
%28 = load double**, double*** %25
store double* %27, double** %28
%29 = getelementptr inbounds double*, double** %1, i64 7
%30 = load double*, double** %29
%31 = load double**, double*** %25
%32 = getelementptr inbounds double*, double** %31, i64 1
store double* %30, double** %32
%33 = getelementptr inbounds double**, double*** %0, i64 4
%34 = getelementptr inbounds double*, double** %1, i64 8
%35 = load double*, double** %34
%36 = load double**, double*** %33
store double* %35, double** %36
%37 = getelementptr inbounds double*, double** %1, i64 9
%38 = load double*, double** %37
%39 = load double**, double*** %33
%40 = getelementptr inbounds double*, double** %39, i64 1
store double* %38, double** %40
%41 = getelementptr inbounds double**, double*** %0, i64 5
%42 = getelementptr inbounds double*, double** %1, i64 10
%43 = load double*, double** %42
%44 = load double**, double*** %41
store double* %43, double** %44
%45 = getelementptr inbounds double*, double** %1, i64 11
%46 = load double*, double** %45
%47 = load double**, double*** %41
%48 = getelementptr inbounds double*, double** %47, i64 1
store double* %46, double** %48
%49 = getelementptr inbounds double**, double*** %0, i64 6
%50 = getelementptr inbounds double*, double** %1, i64 12
%51 = load double*, double** %50
%52 = load double**, double*** %49
store double* %51, double** %52
%53 = getelementptr inbounds double*, double** %1, i64 13
%54 = load double*, double** %53
%55 = load double**, double*** %49
%56 = getelementptr inbounds double*, double** %55, i64 1
store double* %54, double** %56
%57 = getelementptr inbounds double**, double*** %0, i64 7
%58 = getelementptr inbounds double*, double** %1, i64 14
%59 = load double*, double** %58
%60 = load double**, double*** %57
store double* %59, double** %60
%61 = getelementptr inbounds double*, double** %1, i64 15
%62 = load double*, double** %61
%63 = load double**, double*** %57
%64 = getelementptr inbounds double*, double** %63, i64 1
store double* %62, double** %64
ret void
}