void sliceMatrix(double ***threadData, double **data) {
  int k = 0;
  for (int i = 0; i < 1; i++) {
    for (int j = 0; j < 1024 / 1; 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   $0x1,-0x18(%rbp)
jge    1183 <sliceMatrix+0x83>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x400,-0x1c(%rbp)
jge    1170 <sliceMatrix+0x70>
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    1175 <sliceMatrix+0x75>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    111a <sliceMatrix+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<sliceMatrix>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsi,%rax,1),%rcx
mov    (%rdi),%rdx
mov    %rcx,(%rdx,%rax,1)
mov    0x8(%rsi,%rax,1),%rcx
mov    (%rdi),%rdx
mov    %rcx,0x8(%rdx,%rax,1)
mov    0x10(%rsi,%rax,1),%rcx
mov    (%rdi),%rdx
mov    %rcx,0x10(%rdx,%rax,1)
mov    0x18(%rsi,%rax,1),%rcx
mov    (%rdi),%rdx
mov    %rcx,0x18(%rdx,%rax,1)
add    $0x20,%rax
cmp    $0x2000,%rax
jne    1110 <sliceMatrix+0x10>
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, 1
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, 1024
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) {
br label %4
3: ; preds = %4
ret void
4: ; preds = %4, %2
%5 = phi i64 [ 0, %2 ], [ %21, %4 ]
%6 = or i64 %5, 1
%7 = getelementptr inbounds double*, double** %1, i64 %5
%8 = load double*, double** %7
%9 = load double**, double*** %0
%10 = getelementptr inbounds double*, double** %9, i64 %5
store double* %8, double** %10
%11 = or i64 %5, 2
%12 = getelementptr inbounds double*, double** %1, i64 %6
%13 = load double*, double** %12
%14 = load double**, double*** %0
%15 = getelementptr inbounds double*, double** %14, i64 %6
store double* %13, double** %15
%16 = or i64 %5, 3
%17 = getelementptr inbounds double*, double** %1, i64 %11
%18 = load double*, double** %17
%19 = load double**, double*** %0
%20 = getelementptr inbounds double*, double** %19, i64 %11
store double* %18, double** %20
%21 = add nuw nsw i64 %5, 4
%22 = getelementptr inbounds double*, double** %1, i64 %16
%23 = load double*, double** %22
%24 = load double**, double*** %0
%25 = getelementptr inbounds double*, double** %24, i64 %16
store double* %23, double** %25
%26 = icmp eq i64 %21, 1024
br i1 %26, label %3, label %4
}