void makexreg(double **xreg, double **x, int n, int d, int q) {
  int i, j;
  for (i = 0; i < n; i++) {
    xreg[i][d] = -1.0;
    for (j = 0; j < d; j++)
      xreg[i][j] = x[i][j];
  }
}


x86 assembly (clang, -O0):
<makexreg>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a4 <makexreg+0xa4>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1191 <makexreg+0x91>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114d <makexreg+0x4d>
jmp    1196 <makexreg+0x96>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111d <makexreg+0x1d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<makexreg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    130b <makexreg+0x20b>
movslq %ecx,%r12
mov    %edx,%r8d
mov    %r12d,%r15d
mov    %r15d,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x8(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %eax,%r11d
and    $0x3,%r11d
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rsp)
mov    %r15d,%r13d
and    $0x3,%r13d
mov    %r11,-0x18(%rsp)
shl    $0x5,%r11
xor    %r14d,%r14d
movabs $0xbff0000000000000,%rdx
jmp    117d <makexreg+0x7d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r8,%r14
je     130b <makexreg+0x20b>
mov    (%rdi,%r14,8),%rbp
mov    %rdx,0x0(%rbp,%r12,8)
test   %r12d,%r12d
jle    1170 <makexreg+0x70>
mov    (%rsi,%r14,8),%r10
cmp    $0x4,%ecx
jb     11b5 <makexreg+0xb5>
lea    (%r10,%r15,8),%rax
cmp    %rax,%rbp
jae    1235 <makexreg+0x135>
lea    0x0(,%r15,8),%rax
add    %rbp,%rax
cmp    %rax,%r10
jae    1235 <makexreg+0x135>
xor    %r9d,%r9d
mov    %r9,%rax
not    %rax
add    %r15,%rax
test   %r13,%r13
je     11e7 <makexreg+0xe7>
mov    %r13,%rbx
nopl   0x0(%rax)
movsd  (%r10,%r9,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r9,8)
add    $0x1,%r9
add    $0xffffffffffffffff,%rbx
jne    11d0 <makexreg+0xd0>
cmp    $0x3,%rax
jb     1170 <makexreg+0x70>
nopl   (%rax)
movsd  (%r10,%r9,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r9,8)
movsd  0x8(%r10,%r9,8),%xmm0
movsd  %xmm0,0x8(%rbp,%r9,8)
movsd  0x10(%r10,%r9,8),%xmm0
movsd  %xmm0,0x10(%rbp,%r9,8)
movsd  0x18(%r10,%r9,8),%xmm0
movsd  %xmm0,0x18(%rbp,%r9,8)
add    $0x4,%r9
cmp    %r9,%r15
jne    11f0 <makexreg+0xf0>
jmp    1170 <makexreg+0x70>
cmpq   $0xc,-0x10(%rsp)
jae    1241 <makexreg+0x141>
xor    %ebx,%ebx
jmp    12b1 <makexreg+0x1b1>
mov    -0x20(%rsp),%rax
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movups (%r10,%rbx,8),%xmm0
movups 0x10(%r10,%rbx,8),%xmm1
movups %xmm0,0x0(%rbp,%rbx,8)
movups %xmm1,0x10(%rbp,%rbx,8)
movups 0x20(%r10,%rbx,8),%xmm0
movups 0x30(%r10,%rbx,8),%xmm1
movups %xmm0,0x20(%rbp,%rbx,8)
movups %xmm1,0x30(%rbp,%rbx,8)
movups 0x40(%r10,%rbx,8),%xmm0
movups 0x50(%r10,%rbx,8),%xmm1
movups %xmm0,0x40(%rbp,%rbx,8)
movups %xmm1,0x50(%rbp,%rbx,8)
movups 0x60(%r10,%rbx,8),%xmm0
movups 0x70(%r10,%rbx,8),%xmm1
movups %xmm0,0x60(%rbp,%rbx,8)
movups %xmm1,0x70(%rbp,%rbx,8)
add    $0x10,%rbx
add    $0xfffffffffffffffc,%rax
jne    1250 <makexreg+0x150>
cmpq   $0x0,-0x18(%rsp)
je     12eb <makexreg+0x1eb>
lea    0x10(,%rbx,8),%rax
add    %rbp,%rax
lea    (%r10,%rbx,8),%rbx
add    $0x10,%rbx
xor    %edx,%edx
xchg   %ax,%ax
movups -0x10(%rbx,%rdx,1),%xmm0
movups (%rbx,%rdx,1),%xmm1
movups %xmm0,-0x10(%rax,%rdx,1)
movups %xmm1,(%rax,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%r11
jne    12d0 <makexreg+0x1d0>
mov    -0x8(%rsp),%rax
mov    %rax,%r9
cmp    %r15,%rax
movabs $0xbff0000000000000,%rdx
je     1170 <makexreg+0x70>
jmp    11b8 <makexreg+0xb8>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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