#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 updateSolution_FP64(float *mat, double *x, double *r, int n,
                         long long *Idxs) {
  int i, j, offset;
  double t;
  for (i = 0; i < n; ++i) {
    t = 0.0;
    offset = i * n;
    for (j = 0; j < n; ++j) {
      t += conj(mat[offset + j]) * r[j];
    }
    x[Idxs[i] - 1] += t;
  }
}


x86 assembly (clang, -O0):
<updateSolution_FP64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d8 <updateSolution_FP64+0xc8>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a7 <updateSolution_FP64+0x97>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <conj@plt>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1157 <updateSolution_FP64+0x47>
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
sub    $0x1,%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1132 <updateSolution_FP64+0x22>
add    $0x40,%rsp
pop    %rbp
ret

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

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

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