#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double conj(float);
void updateSolutionLocal_FP64(float *mat, double *x, double *r, int n) {
  int i, j;
  double t;
  for (i = 0; i < n; ++i) {
    t = 0.0;
    for (j = 0; j < n; ++j) {
      t += conj(mat[i * n + j]) * r[j];
    }
    x[i] = t;
  }
}


x86 assembly (clang, -O0):
<updateSolutionLocal_FP64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bd <updateSolutionLocal_FP64+0xad>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    119d <updateSolutionLocal_FP64+0x8d>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <conj@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1149 <updateSolutionLocal_FP64+0x39>
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <updateSolutionLocal_FP64+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<updateSolutionLocal_FP64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
test   %ecx,%ecx
jle    119c <updateSolutionLocal_FP64+0x8c>
mov    %rdx,%r15
mov    %rdi,%rbx
mov    %ecx,%r12d
lea    0x0(,%r12,4),%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movss  (%rbx,%r14,4),%xmm0
call   1030 <conj@plt>
mulsd  (%r15,%r14,8),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%r14
cmp    %r14,%r12
jne    1150 <updateSolutionLocal_FP64+0x40>
mov    0x10(%rsp),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%rbp
add    %r13,%rbx
cmp    %r12,%rbp
jne    1140 <updateSolutionLocal_FP64+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @updateSolutionLocal_FP64(float* nocapture %0, double* nocapture writeonly %1, double* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %28
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %24, %6
%10 = phi i64 [ 0, %6 ], [ %26, %24 ]
%11 = mul nsw i64 %10, %7
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ 0, %9 ], [ %22, %12 ]
%14 = phi double [ 0.000000e+00, %9 ], [ %21, %12 ]
%15 = add nuw nsw i64 %13, %11
%16 = getelementptr inbounds float, float* %0, i64 %15
%17 = load float, float* %16
%18 = tail call double @conj(float %17)
%19 = getelementptr inbounds double, double* %2, i64 %13
%20 = load double, double* %19
%21 = tail call double @llvm.fmuladd.f64(double %18, double %20, double %14)
%22 = add nuw nsw i64 %13, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %12
24: ; preds = %12
%25 = getelementptr inbounds double, double* %1, i64 %10
store double %21, double* %25
%26 = add nuw nsw i64 %10, 1
%27 = icmp eq i64 %26, %8
br i1 %27, label %28, label %9
28: ; preds = %24, %4
ret void
}