void xrtm_to_polrad_coefs(int n_coef, int n_stokes, double **coefs,
                          double ***coefs2) {
  int j;
  int k;
  int l;
  for (j = 0; j < n_coef; ++j) {
    for (k = 0; k < 4; ++k) {
      for (l = 0; l < 4; ++l) {
        coefs2[j][k][l] = 0.;
      }
    }
    coefs2[j][0][0] = coefs[0][j];
    if (n_stokes > 1) {
      coefs2[j][1][1] = coefs[1][j];
      coefs2[j][1][0] = -coefs[4][j];
      coefs2[j][0][1] = -coefs[4][j];
      coefs2[j][2][2] = coefs[2][j];
      coefs2[j][3][3] = coefs[3][j];
      coefs2[j][3][2] = -coefs[5][j];
      coefs2[j][2][3] = -coefs[5][j];
    }
  }
}


x86 assembly (clang, -O0):
<xrtm_to_polrad_coefs>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    132c <xrtm_to_polrad_coefs+0x22c>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    1188 <xrtm_to_polrad_coefs+0x88>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1175 <xrtm_to_polrad_coefs+0x75>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113d <xrtm_to_polrad_coefs+0x3d>
jmp    117a <xrtm_to_polrad_coefs+0x7a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112c <xrtm_to_polrad_coefs+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%rax
movsd  %xmm0,(%rax)
cmpl   $0x1,-0x8(%rbp)
jle    1319 <xrtm_to_polrad_coefs+0x219>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x8(%rax),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x8(%rax),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x10(%rax),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x18(%rax),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x18(%rax),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0x10(%rax),%rax
movsd  %xmm0,0x18(%rax)
jmp    131e <xrtm_to_polrad_coefs+0x21e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1119 <xrtm_to_polrad_coefs+0x19>
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrtm_to_polrad_coefs>:
push   %r14
push   %rbx
test   %edi,%edi
jle    11dd <xrtm_to_polrad_coefs+0xdd>
mov    (%rdx),%r8
mov    %edi,%r9d
xor    %eax,%eax
xorps  %xmm0,%xmm0
movaps 0xee3(%rip),%xmm1
jmp    112d <xrtm_to_polrad_coefs+0x2d>
nop
add    $0x1,%rax
cmp    %rax,%r9
je     11dd <xrtm_to_polrad_coefs+0xdd>
mov    (%rcx,%rax,8),%rdi
mov    (%rdi),%r14
movups %xmm0,0x10(%r14)
movups %xmm0,(%r14)
mov    0x8(%rdi),%rbx
movups %xmm0,0x10(%rbx)
movups %xmm0,(%rbx)
mov    0x10(%rdi),%r10
movups %xmm0,0x10(%r10)
movups %xmm0,(%r10)
mov    0x18(%rdi),%r11
movups %xmm0,0x10(%r11)
movups %xmm0,(%r11)
movsd  (%r8,%rax,8),%xmm2
movsd  %xmm2,(%r14)
cmp    $0x2,%esi
jl     1120 <xrtm_to_polrad_coefs+0x20>
mov    0x8(%rdx),%rdi
movsd  (%rdi,%rax,8),%xmm2
movsd  %xmm2,0x8(%rbx)
mov    0x20(%rdx),%rdi
movsd  (%rdi,%rax,8),%xmm2
xorps  %xmm1,%xmm2
movlps %xmm2,(%rbx)
movsd  (%rdi,%rax,8),%xmm2
xorps  %xmm1,%xmm2
movlps %xmm2,0x8(%r14)
mov    0x10(%rdx),%rdi
movsd  (%rdi,%rax,8),%xmm2
movsd  %xmm2,0x10(%r10)
mov    0x18(%rdx),%rdi
movsd  (%rdi,%rax,8),%xmm2
movsd  %xmm2,0x18(%r11)
mov    0x28(%rdx),%rdi
movsd  (%rdi,%rax,8),%xmm2
xorps  %xmm1,%xmm2
movlps %xmm2,0x10(%r11)
movsd  (%rdi,%rax,8),%xmm2
xorps  %xmm1,%xmm2
movlps %xmm2,0x18(%r10)
jmp    1120 <xrtm_to_polrad_coefs+0x20>
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @xrtm_to_polrad_coefs(i32 %0, i32 %1, double** %2, double*** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
%8 = alloca double***
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double** %2, double*** %7
store double*** %3, double**** %8
store i32 0, i32* %9
br label %12
12: ; preds = %173, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %176
16: ; preds = %12
store i32 0, i32* %10
br label %17
17: ; preds = %41, %16
%18 = load i32, i32* %10
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %44
20: ; preds = %17
store i32 0, i32* %11
br label %21
21: ; preds = %37, %20
%22 = load i32, i32* %11
%23 = icmp slt i32 %22, 4
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = load double***, double**** %8
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double**, double*** %25, i64 %27
%29 = load double**, double*** %28
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double*, double** %29, i64 %31
%33 = load double*, double** %32
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double 0.000000e+00, double* %36
br label %37
37: ; preds = %24
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %21
40: ; preds = %21
br label %41
41: ; preds = %40
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 1
store i32 %43, i32* %10
br label %17
44: ; preds = %17
%45 = load double**, double*** %7
%46 = getelementptr inbounds double*, double** %45, i64 0
%47 = load double*, double** %46
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = load double***, double**** %8
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double**, double*** %52, i64 %54
%56 = load double**, double*** %55
%57 = getelementptr inbounds double*, double** %56, i64 0
%58 = load double*, double** %57
%59 = getelementptr inbounds double, double* %58, i64 0
store double %51, double* %59
%60 = load i32, i32* %6
%61 = icmp sgt i32 %60, 1
br i1 %61, label %62, label %172
62: ; preds = %44
%63 = load double**, double*** %7
%64 = getelementptr inbounds double*, double** %63, i64 1
%65 = load double*, double** %64
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = load double***, double**** %8
%71 = load i32, i32* %9
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double**, double*** %70, i64 %72
%74 = load double**, double*** %73
%75 = getelementptr inbounds double*, double** %74, i64 1
%76 = load double*, double** %75
%77 = getelementptr inbounds double, double* %76, i64 1
store double %69, double* %77
%78 = load double**, double*** %7
%79 = getelementptr inbounds double*, double** %78, i64 4
%80 = load double*, double** %79
%81 = load i32, i32* %9
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = fneg double %84
%86 = load double***, double**** %8
%87 = load i32, i32* %9
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double**, double*** %86, i64 %88
%90 = load double**, double*** %89
%91 = getelementptr inbounds double*, double** %90, i64 1
%92 = load double*, double** %91
%93 = getelementptr inbounds double, double* %92, i64 0
store double %85, double* %93
%94 = load double**, double*** %7
%95 = getelementptr inbounds double*, double** %94, i64 4
%96 = load double*, double** %95
%97 = load i32, i32* %9
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %96, i64 %98
%100 = load double, double* %99
%101 = fneg double %100
%102 = load double***, double**** %8
%103 = load i32, i32* %9
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds double**, double*** %102, i64 %104
%106 = load double**, double*** %105
%107 = getelementptr inbounds double*, double** %106, i64 0
%108 = load double*, double** %107
%109 = getelementptr inbounds double, double* %108, i64 1
store double %101, double* %109
%110 = load double**, double*** %7
%111 = getelementptr inbounds double*, double** %110, i64 2
%112 = load double*, double** %111
%113 = load i32, i32* %9
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %112, i64 %114
%116 = load double, double* %115
%117 = load double***, double**** %8
%118 = load i32, i32* %9
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double**, double*** %117, i64 %119
%121 = load double**, double*** %120
%122 = getelementptr inbounds double*, double** %121, i64 2
%123 = load double*, double** %122
%124 = getelementptr inbounds double, double* %123, i64 2
store double %116, double* %124
%125 = load double**, double*** %7
%126 = getelementptr inbounds double*, double** %125, i64 3
%127 = load double*, double** %126
%128 = load i32, i32* %9
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds double, double* %127, i64 %129
%131 = load double, double* %130
%132 = load double***, double**** %8
%133 = load i32, i32* %9
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double**, double*** %132, i64 %134
%136 = load double**, double*** %135
%137 = getelementptr inbounds double*, double** %136, i64 3
%138 = load double*, double** %137
%139 = getelementptr inbounds double, double* %138, i64 3
store double %131, double* %139
%140 = load double**, double*** %7
%141 = getelementptr inbounds double*, double** %140, i64 5
%142 = load double*, double** %141
%143 = load i32, i32* %9
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %142, i64 %144
%146 = load double, double* %145
%147 = fneg double %146
%148 = load double***, double**** %8
%149 = load i32, i32* %9
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double**, double*** %148, i64 %150
%152 = load double**, double*** %151
%153 = getelementptr inbounds double*, double** %152, i64 3
%154 = load double*, double** %153
%155 = getelementptr inbounds double, double* %154, i64 2
store double %147, double* %155
%156 = load double**, double*** %7
%157 = getelementptr inbounds double*, double** %156, i64 5
%158 = load double*, double** %157
%159 = load i32, i32* %9
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds double, double* %158, i64 %160
%162 = load double, double* %161
%163 = fneg double %162
%164 = load double***, double**** %8
%165 = load i32, i32* %9
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds double**, double*** %164, i64 %166
%168 = load double**, double*** %167
%169 = getelementptr inbounds double*, double** %168, i64 2
%170 = load double*, double** %169
%171 = getelementptr inbounds double, double* %170, i64 3
store double %163, double* %171
br label %172
172: ; preds = %62, %44
br label %173
173: ; preds = %172
%174 = load i32, i32* %9
%175 = add nsw i32 %174, 1
store i32 %175, i32* %9
br label %12
176: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @xrtm_to_polrad_coefs(i32 %0, i32 %1, double** nocapture %2, double*** nocapture %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %63
6: ; preds = %4
%7 = load double*, double** %2
%8 = icmp sgt i32 %1, 1
%9 = getelementptr inbounds double*, double** %2, i64 1
%10 = getelementptr inbounds double*, double** %2, i64 4
%11 = getelementptr inbounds double*, double** %2, i64 2
%12 = getelementptr inbounds double*, double** %2, i64 3
%13 = getelementptr inbounds double*, double** %2, i64 5
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %6, %60
%16 = phi i64 [ 0, %6 ], [ %61, %60 ]
%17 = getelementptr inbounds double**, double*** %3, i64 %16
%18 = load double**, double*** %17
%19 = load double*, double** %18
%20 = bitcast double* %19 to i8*
%21 = getelementptr inbounds double*, double** %18, i64 1
%22 = load double*, double** %21
%23 = bitcast double* %22 to i8*
%24 = getelementptr inbounds double*, double** %18, i64 2
%25 = load double*, double** %24
%26 = bitcast double* %25 to i8*
%27 = getelementptr inbounds double*, double** %18, i64 3
%28 = load double*, double** %27
%29 = bitcast double* %28 to i8*
%30 = getelementptr inbounds double, double* %7, i64 %16
%31 = load double, double* %30
store double %31, double* %19
br i1 %8, label %32, label %60
32: ; preds = %15
%33 = load double*, double** %9
%34 = getelementptr inbounds double, double* %33, i64 %16
%35 = load double, double* %34
%36 = getelementptr inbounds double, double* %22, i64 1
store double %35, double* %36
%37 = load double*, double** %10
%38 = getelementptr inbounds double, double* %37, i64 %16
%39 = load double, double* %38
%40 = fneg double %39
store double %40, double* %22
%41 = load double, double* %38
%42 = fneg double %41
%43 = getelementptr inbounds double, double* %19, i64 1
store double %42, double* %43
%44 = load double*, double** %11
%45 = getelementptr inbounds double, double* %44, i64 %16
%46 = load double, double* %45
%47 = getelementptr inbounds double, double* %25, i64 2
store double %46, double* %47
%48 = load double*, double** %12
%49 = getelementptr inbounds double, double* %48, i64 %16
%50 = load double, double* %49
%51 = getelementptr inbounds double, double* %28, i64 3
store double %50, double* %51
%52 = load double*, double** %13
%53 = getelementptr inbounds double, double* %52, i64 %16
%54 = load double, double* %53
%55 = fneg double %54
%56 = getelementptr inbounds double, double* %28, i64 2
store double %55, double* %56
%57 = load double, double* %53
%58 = fneg double %57
%59 = getelementptr inbounds double, double* %25, i64 3
store double %58, double* %59
br label %60
60: ; preds = %15, %32
%61 = add nuw nsw i64 %16, 1
%62 = icmp eq i64 %61, %14
br i1 %62, label %63, label %15
63: ; preds = %60, %4
ret void
}