void slctr_double_tab(double **tab1, int x1, int y1, double **tab2, int x2,
                      int *vec) {
  int i, j;
  for (i = 0; i < x2; i++) {
    for (j = 0; j < y1; j++) {
      tab2[i][j] = tab1[vec[i]][j];
    }
  }
}


x86 assembly (clang, -O0):
<slctr_double_tab>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1193 <slctr_double_tab+0x93>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1180 <slctr_double_tab+0x80>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1134 <slctr_double_tab+0x34>
jmp    1185 <slctr_double_tab+0x85>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1121 <slctr_double_tab+0x21>
pop    %rbp
ret

x86 assembly (clang, -O2):
<slctr_double_tab>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %r8d,%r8d
jle    12ee <slctr_double_tab+0x1ee>
mov    %r8d,%r15d
mov    %edx,%r10d
mov    %r10d,%r11d
and    $0xfffffffc,%r11d
lea    -0x4(%r11),%rax
mov    %rax,-0x8(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %eax,%r13d
and    $0x3,%r13d
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x18(%rsp)
mov    %r10d,%r12d
and    $0x3,%r12d
mov    %r13,-0x10(%rsp)
shl    $0x5,%r13
xor    %r14d,%r14d
jmp    116d <slctr_double_tab+0x6d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r15,%r14
je     12ee <slctr_double_tab+0x1ee>
test   %edx,%edx
jle    1160 <slctr_double_tab+0x60>
movslq (%r9,%r14,4),%rax
mov    (%rdi,%rax,8),%rax
mov    (%rcx,%r14,8),%rbp
cmp    $0x4,%edx
jb     11a3 <slctr_double_tab+0xa3>
lea    (%rax,%r10,8),%rsi
cmp    %rsi,%rbp
jae    1225 <slctr_double_tab+0x125>
lea    0x0(,%r10,8),%rsi
add    %rbp,%rsi
cmp    %rsi,%rax
jae    1225 <slctr_double_tab+0x125>
xor    %r8d,%r8d
mov    %r8,%rsi
not    %rsi
add    %r10,%rsi
test   %r12,%r12
je     11d7 <slctr_double_tab+0xd7>
mov    %r12,%rbx
nopw   0x0(%rax,%rax,1)
movsd  (%rax,%r8,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r8,8)
add    $0x1,%r8
add    $0xffffffffffffffff,%rbx
jne    11c0 <slctr_double_tab+0xc0>
cmp    $0x3,%rsi
jb     1160 <slctr_double_tab+0x60>
nopl   (%rax)
movsd  (%rax,%r8,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r8,8)
movsd  0x8(%rax,%r8,8),%xmm0
movsd  %xmm0,0x8(%rbp,%r8,8)
movsd  0x10(%rax,%r8,8),%xmm0
movsd  %xmm0,0x10(%rbp,%r8,8)
movsd  0x18(%rax,%r8,8),%xmm0
movsd  %xmm0,0x18(%rbp,%r8,8)
add    $0x4,%r8
cmp    %r8,%r10
jne    11e0 <slctr_double_tab+0xe0>
jmp    1160 <slctr_double_tab+0x60>
cmpq   $0xc,-0x8(%rsp)
jae    1231 <slctr_double_tab+0x131>
xor    %ebx,%ebx
jmp    1299 <slctr_double_tab+0x199>
mov    -0x18(%rsp),%rsi
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movups (%rax,%rbx,8),%xmm0
movups 0x10(%rax,%rbx,8),%xmm1
movups %xmm0,0x0(%rbp,%rbx,8)
movups %xmm1,0x10(%rbp,%rbx,8)
movups 0x20(%rax,%rbx,8),%xmm0
movups 0x30(%rax,%rbx,8),%xmm1
movups %xmm0,0x20(%rbp,%rbx,8)
movups %xmm1,0x30(%rbp,%rbx,8)
movups 0x40(%rax,%rbx,8),%xmm0
movups 0x50(%rax,%rbx,8),%xmm1
movups %xmm0,0x40(%rbp,%rbx,8)
movups %xmm1,0x50(%rbp,%rbx,8)
movups 0x60(%rax,%rbx,8),%xmm0
movups 0x70(%rax,%rbx,8),%xmm1
movups %xmm0,0x60(%rbp,%rbx,8)
movups %xmm1,0x70(%rbp,%rbx,8)
add    $0x10,%rbx
add    $0xfffffffffffffffc,%rsi
jne    1240 <slctr_double_tab+0x140>
cmpq   $0x0,-0x10(%rsp)
je     12dd <slctr_double_tab+0x1dd>
lea    0x10(,%rbx,8),%r8
add    %rbp,%r8
lea    (%rax,%rbx,8),%rbx
add    $0x10,%rbx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movups -0x10(%rbx,%rsi,1),%xmm0
movups (%rbx,%rsi,1),%xmm1
movups %xmm0,-0x10(%r8,%rsi,1)
movups %xmm1,(%r8,%rsi,1)
add    $0x20,%rsi
cmp    %rsi,%r13
jne    12c0 <slctr_double_tab+0x1c0>
mov    %r11,%r8
cmp    %r10,%r11
je     1160 <slctr_double_tab+0x60>
jmp    11a6 <slctr_double_tab+0xa6>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @slctr_double_tab(double** nocapture %0, i32 %1, i32 %2, double** nocapture %3, i32 %4, i32* nocapture %5) {
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %148
8: ; preds = %6
%9 = icmp sgt i32 %2, 0
%10 = zext i32 %4 to i64
%11 = zext i32 %2 to i64
%12 = and i64 %11, 4294967292
%13 = add nsw i64 %12, -4
%14 = lshr exact i64 %13, 2
%15 = add nuw nsw i64 %14, 1
%16 = icmp ult i32 %2, 4
%17 = and i64 %11, 4294967292
%18 = and i64 %15, 3
%19 = icmp ult i64 %13, 12
%20 = and i64 %15, 9223372036854775804
%21 = icmp eq i64 %18, 0
%22 = icmp eq i64 %17, %11
%23 = and i64 %11, 3
%24 = icmp eq i64 %23, 0
br label %25
25: ; preds = %8, %145
%26 = phi i64 [ 0, %8 ], [ %146, %145 ]
br i1 %9, label %27, label %145
27: ; preds = %25
%28 = getelementptr inbounds i32, i32* %5, i64 %26
%29 = load i32, i32* %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double*, double** %0, i64 %30
%32 = load double*, double** %31
%33 = getelementptr inbounds double*, double** %3, i64 %26
%34 = load double*, double** %33
br i1 %16, label %110, label %35
35: ; preds = %27
%36 = getelementptr double, double* %34, i64 %11
%37 = getelementptr double, double* %32, i64 %11
%38 = icmp ult double* %34, %37
%39 = icmp ult double* %32, %36
%40 = and i1 %38, %39
br i1 %40, label %110, label %41
41: ; preds = %35
br i1 %19, label %91, label %42
42: ; preds = %41, %42
%43 = phi i64 [ %88, %42 ], [ 0, %41 ]
%44 = phi i64 [ %89, %42 ], [ 0, %41 ]
%45 = getelementptr inbounds double, double* %32, i64 %43
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = getelementptr inbounds double, double* %45, i64 2
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = getelementptr inbounds double, double* %34, i64 %43
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %47, <2 x double>* %52
%53 = getelementptr inbounds double, double* %51, i64 2
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %50, <2 x double>* %54
%55 = or i64 %43, 4
%56 = getelementptr inbounds double, double* %32, i64 %55
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = getelementptr inbounds double, double* %56, i64 2
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = getelementptr inbounds double, double* %34, i64 %55
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> %58, <2 x double>* %63
%64 = getelementptr inbounds double, double* %62, i64 2
%65 = bitcast double* %64 to <2 x double>*
store <2 x double> %61, <2 x double>* %65
%66 = or i64 %43, 8
%67 = getelementptr inbounds double, double* %32, i64 %66
%68 = bitcast double* %67 to <2 x double>*
%69 = load <2 x double>, <2 x double>* %68
%70 = getelementptr inbounds double, double* %67, i64 2
%71 = bitcast double* %70 to <2 x double>*
%72 = load <2 x double>, <2 x double>* %71
%73 = getelementptr inbounds double, double* %34, i64 %66
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %69, <2 x double>* %74
%75 = getelementptr inbounds double, double* %73, i64 2
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %72, <2 x double>* %76
%77 = or i64 %43, 12
%78 = getelementptr inbounds double, double* %32, i64 %77
%79 = bitcast double* %78 to <2 x double>*
%80 = load <2 x double>, <2 x double>* %79
%81 = getelementptr inbounds double, double* %78, i64 2
%82 = bitcast double* %81 to <2 x double>*
%83 = load <2 x double>, <2 x double>* %82
%84 = getelementptr inbounds double, double* %34, i64 %77
%85 = bitcast double* %84 to <2 x double>*
store <2 x double> %80, <2 x double>* %85
%86 = getelementptr inbounds double, double* %84, i64 2
%87 = bitcast double* %86 to <2 x double>*
store <2 x double> %83, <2 x double>* %87
%88 = add nuw i64 %43, 16
%89 = add nuw i64 %44, 4
%90 = icmp eq i64 %89, %20
br i1 %90, label %91, label %42
91: ; preds = %42, %41
%92 = phi i64 [ 0, %41 ], [ %88, %42 ]
br i1 %21, label %109, label %93
93: ; preds = %91, %93
%94 = phi i64 [ %106, %93 ], [ %92, %91 ]
%95 = phi i64 [ %107, %93 ], [ 0, %91 ]
%96 = getelementptr inbounds double, double* %32, i64 %94
%97 = bitcast double* %96 to <2 x double>*
%98 = load <2 x double>, <2 x double>* %97
%99 = getelementptr inbounds double, double* %96, i64 2
%100 = bitcast double* %99 to <2 x double>*
%101 = load <2 x double>, <2 x double>* %100
%102 = getelementptr inbounds double, double* %34, i64 %94
%103 = bitcast double* %102 to <2 x double>*
store <2 x double> %98, <2 x double>* %103
%104 = getelementptr inbounds double, double* %102, i64 2
%105 = bitcast double* %104 to <2 x double>*
store <2 x double> %101, <2 x double>* %105
%106 = add nuw i64 %94, 4
%107 = add i64 %95, 1
%108 = icmp eq i64 %107, %18
br i1 %108, label %109, label %93
109: ; preds = %93, %91
br i1 %22, label %145, label %110
110: ; preds = %35, %27, %109
%111 = phi i64 [ 0, %35 ], [ 0, %27 ], [ %17, %109 ]
%112 = xor i64 %111, -1
%113 = add nsw i64 %112, %11
br i1 %24, label %123, label %114
114: ; preds = %110, %114
%115 = phi i64 [ %120, %114 ], [ %111, %110 ]
%116 = phi i64 [ %121, %114 ], [ 0, %110 ]
%117 = getelementptr inbounds double, double* %32, i64 %115
%118 = load double, double* %117
%119 = getelementptr inbounds double, double* %34, i64 %115
store double %118, double* %119
%120 = add nuw nsw i64 %115, 1
%121 = add i64 %116, 1
%122 = icmp eq i64 %121, %23
br i1 %122, label %123, label %114
123: ; preds = %114, %110
%124 = phi i64 [ %111, %110 ], [ %120, %114 ]
%125 = icmp ult i64 %113, 3
br i1 %125, label %145, label %126
126: ; preds = %123, %126
%127 = phi i64 [ %143, %126 ], [ %124, %123 ]
%128 = getelementptr inbounds double, double* %32, i64 %127
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %34, i64 %127
store double %129, double* %130
%131 = add nuw nsw i64 %127, 1
%132 = getelementptr inbounds double, double* %32, i64 %131
%133 = load double, double* %132
%134 = getelementptr inbounds double, double* %34, i64 %131
store double %133, double* %134
%135 = add nuw nsw i64 %127, 2
%136 = getelementptr inbounds double, double* %32, i64 %135
%137 = load double, double* %136
%138 = getelementptr inbounds double, double* %34, i64 %135
store double %137, double* %138
%139 = add nuw nsw i64 %127, 3
%140 = getelementptr inbounds double, double* %32, i64 %139
%141 = load double, double* %140
%142 = getelementptr inbounds double, double* %34, i64 %139
store double %141, double* %142
%143 = add nuw nsw i64 %127, 4
%144 = icmp eq i64 %143, %11
br i1 %144, label %145, label %126
145: ; preds = %123, %126, %109, %25
%146 = add nuw nsw i64 %26, 1
%147 = icmp eq i64 %146, %10
br i1 %147, label %148, label %25
148: ; preds = %145, %6
ret void
}