void nextstep(double invhk[4][4], double gk[4], double xk[4]) {
  int i, j;
  double di = 0;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      di += -invhk[i][j] * gk[j];
    }
    xk[i] += di;
    di = 0;
  }
}


x86 assembly (clang, -O0):
<nextstep>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11c3 <nextstep+0xc3>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    1196 <nextstep+0x96>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1130 <nextstep+0x30>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    111f <nextstep+0x1f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextstep>:
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm2
mulsd  (%rsi),%xmm1
xorpd  %xmm0,%xmm0
xorpd  %xmm3,%xmm3
mulsd  0x8(%rsi),%xmm2
subsd  %xmm1,%xmm3
movsd  0x10(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
subsd  %xmm2,%xmm3
movsd  0x18(%rdi),%xmm2
mulsd  0x18(%rsi),%xmm2
subsd  %xmm1,%xmm3
subsd  %xmm2,%xmm3
addsd  (%rdx),%xmm3
movsd  %xmm3,(%rdx)
movsd  0x20(%rdi),%xmm1
mulsd  (%rsi),%xmm1
movsd  0x28(%rdi),%xmm2
xorpd  %xmm3,%xmm3
mulsd  0x8(%rsi),%xmm2
subsd  %xmm1,%xmm3
movsd  0x30(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
subsd  %xmm2,%xmm3
movsd  0x38(%rdi),%xmm2
mulsd  0x18(%rsi),%xmm2
subsd  %xmm1,%xmm3
subsd  %xmm2,%xmm3
addsd  0x8(%rdx),%xmm3
movsd  %xmm3,0x8(%rdx)
movsd  0x40(%rdi),%xmm1
mulsd  (%rsi),%xmm1
movsd  0x48(%rdi),%xmm2
xorpd  %xmm3,%xmm3
mulsd  0x8(%rsi),%xmm2
subsd  %xmm1,%xmm3
movsd  0x50(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
subsd  %xmm2,%xmm3
movsd  0x58(%rdi),%xmm2
mulsd  0x18(%rsi),%xmm2
subsd  %xmm1,%xmm3
subsd  %xmm2,%xmm3
addsd  0x10(%rdx),%xmm3
movsd  %xmm3,0x10(%rdx)
movsd  0x60(%rdi),%xmm1
mulsd  (%rsi),%xmm1
movsd  0x68(%rdi),%xmm2
subsd  %xmm1,%xmm0
mulsd  0x8(%rsi),%xmm2
subsd  %xmm2,%xmm0
movsd  0x70(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
subsd  %xmm1,%xmm0
movsd  0x78(%rdi),%xmm1
mulsd  0x18(%rsi),%xmm1
subsd  %xmm1,%xmm0
addsd  0x18(%rdx),%xmm0
movsd  %xmm0,0x18(%rdx)
ret

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

LLVM IR (-O2):
define void @nextstep([4 x double]* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 0
%5 = load double, double* %4
%6 = fneg double %5
%7 = load double, double* %1
%8 = tail call double @llvm.fmuladd.f64(double %6, double %7, double 0.000000e+00)
%9 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 1
%10 = load double, double* %9
%11 = fneg double %10
%12 = getelementptr inbounds double, double* %1, i64 1
%13 = load double, double* %12
%14 = tail call double @llvm.fmuladd.f64(double %11, double %13, double %8)
%15 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 2
%16 = load double, double* %15
%17 = fneg double %16
%18 = getelementptr inbounds double, double* %1, i64 2
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %17, double %19, double %14)
%21 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 0, i64 3
%22 = load double, double* %21
%23 = fneg double %22
%24 = getelementptr inbounds double, double* %1, i64 3
%25 = load double, double* %24
%26 = tail call double @llvm.fmuladd.f64(double %23, double %25, double %20)
%27 = load double, double* %2
%28 = fadd double %26, %27
store double %28, double* %2
%29 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 0
%30 = load double, double* %29
%31 = fneg double %30
%32 = load double, double* %1
%33 = tail call double @llvm.fmuladd.f64(double %31, double %32, double 0.000000e+00)
%34 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 1
%35 = load double, double* %34
%36 = fneg double %35
%37 = load double, double* %12
%38 = tail call double @llvm.fmuladd.f64(double %36, double %37, double %33)
%39 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 2
%40 = load double, double* %39
%41 = fneg double %40
%42 = load double, double* %18
%43 = tail call double @llvm.fmuladd.f64(double %41, double %42, double %38)
%44 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 1, i64 3
%45 = load double, double* %44
%46 = fneg double %45
%47 = load double, double* %24
%48 = tail call double @llvm.fmuladd.f64(double %46, double %47, double %43)
%49 = getelementptr inbounds double, double* %2, i64 1
%50 = load double, double* %49
%51 = fadd double %48, %50
store double %51, double* %49
%52 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 0
%53 = load double, double* %52
%54 = fneg double %53
%55 = load double, double* %1
%56 = tail call double @llvm.fmuladd.f64(double %54, double %55, double 0.000000e+00)
%57 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 1
%58 = load double, double* %57
%59 = fneg double %58
%60 = load double, double* %12
%61 = tail call double @llvm.fmuladd.f64(double %59, double %60, double %56)
%62 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 2
%63 = load double, double* %62
%64 = fneg double %63
%65 = load double, double* %18
%66 = tail call double @llvm.fmuladd.f64(double %64, double %65, double %61)
%67 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 2, i64 3
%68 = load double, double* %67
%69 = fneg double %68
%70 = load double, double* %24
%71 = tail call double @llvm.fmuladd.f64(double %69, double %70, double %66)
%72 = getelementptr inbounds double, double* %2, i64 2
%73 = load double, double* %72
%74 = fadd double %71, %73
store double %74, double* %72
%75 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 0
%76 = load double, double* %75
%77 = fneg double %76
%78 = load double, double* %1
%79 = tail call double @llvm.fmuladd.f64(double %77, double %78, double 0.000000e+00)
%80 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 1
%81 = load double, double* %80
%82 = fneg double %81
%83 = load double, double* %12
%84 = tail call double @llvm.fmuladd.f64(double %82, double %83, double %79)
%85 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 2
%86 = load double, double* %85
%87 = fneg double %86
%88 = load double, double* %18
%89 = tail call double @llvm.fmuladd.f64(double %87, double %88, double %84)
%90 = getelementptr inbounds [4 x double], [4 x double]* %0, i64 3, i64 3
%91 = load double, double* %90
%92 = fneg double %91
%93 = load double, double* %24
%94 = tail call double @llvm.fmuladd.f64(double %92, double %93, double %89)
%95 = getelementptr inbounds double, double* %2, i64 3
%96 = load double, double* %95
%97 = fadd double %94, %96
store double %97, double* %95
ret void
}