#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 sqrt(double);
double dlevmar_corcoef(double *covar, int m, int i, int j) {
  return (double)(covar[i * m + j] / sqrt(covar[i * m + i] * covar[j * m + j]));
}


x86 assembly (clang, -O0):
<dlevmar_corcoef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
divsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dlevmar_corcoef>:
push   %rax
mov    %edx,%r8d
imul   %esi,%r8d
lea    (%r8,%rcx,1),%eax
cltq
add    %edx,%r8d
movslq %r8d,%rdx
movsd  (%rdi,%rdx,8),%xmm0
imul   %ecx,%esi
add    %ecx,%esi
movslq %esi,%rcx
mulsd  (%rdi,%rcx,8),%xmm0
movsd  (%rdi,%rax,8),%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     114b <dlevmar_corcoef+0x3b>
sqrtsd %xmm0,%xmm0
jmp    115a <dlevmar_corcoef+0x4a>
movsd  %xmm2,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @dlevmar_corcoef(double* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load double*, double** %5
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %8
%14 = add nsw i32 %12, %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %9, i64 %15
%17 = load double, double* %16
%18 = load double*, double** %5
%19 = load i32, i32* %7
%20 = load i32, i32* %6
%21 = mul nsw i32 %19, %20
%22 = load i32, i32* %7
%23 = add nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %18, i64 %24
%26 = load double, double* %25
%27 = load double*, double** %5
%28 = load i32, i32* %8
%29 = load i32, i32* %6
%30 = mul nsw i32 %28, %29
%31 = load i32, i32* %8
%32 = add nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %27, i64 %33
%35 = load double, double* %34
%36 = fmul double %26, %35
%37 = call double @sqrt(double %36)
%38 = fdiv double %17, %37
ret double %38
}

LLVM IR (-O2):
define double @dlevmar_corcoef(double* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = mul nsw i32 %2, %1
%6 = add nsw i32 %5, %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds double, double* %0, i64 %7
%9 = load double, double* %8
%10 = add nsw i32 %5, %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = mul nsw i32 %3, %1
%15 = add nsw i32 %14, %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %0, i64 %16
%18 = load double, double* %17
%19 = fmul double %13, %18
%20 = tail call double @sqrt(double %19)
%21 = fdiv double %9, %20
ret double %21
}