#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 const);
void mat33_chol(const double *A, double *R) {
  R[0] = sqrt(A[0]);
  R[3] = A[1] / R[0];
  R[6] = A[2] / R[0];
  R[4] = sqrt(A[4] - R[3] * R[3]);
  R[7] = (A[5] - R[3] * R[6]) / R[4];
  R[8] = sqrt(A[8] - R[6] * R[6] - R[7] * R[7]);
  R[1] = 0;
  R[2] = 0;
  R[5] = 0;
}


x86 assembly (clang, -O0):
<mat33_chol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sqrt@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
divsd  0x20(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat33_chol>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  (%rdi),%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jb     112e <mat33_chol+0x1e>
sqrtsd %xmm0,%xmm0
jmp    1137 <mat33_chol+0x27>
call   1030 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  %xmm0,(%rbx)
movsd  0x8(%r14),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rbx)
movsd  0x10(%r14),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x30(%rbx)
movsd  0x20(%r14),%xmm0
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
ucomisd %xmm3,%xmm0
jb     1173 <mat33_chol+0x63>
sqrtsd %xmm0,%xmm0
jmp    1178 <mat33_chol+0x68>
call   1030 <sqrt@plt>
movsd  %xmm0,0x20(%rbx)
movsd  0x28(%r14),%xmm1
movsd  0x30(%rbx),%xmm2
movsd  0x18(%rbx),%xmm3
mulsd  %xmm2,%xmm3
subsd  %xmm3,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x38(%rbx)
movsd  0x40(%r14),%xmm0
mulsd  %xmm2,%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11c4 <mat33_chol+0xb4>
sqrtsd %xmm0,%xmm0
jmp    11c9 <mat33_chol+0xb9>
call   1030 <sqrt@plt>
movsd  %xmm0,0x40(%rbx)
movq   $0x0,0x28(%rbx)
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @mat33_chol(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = tail call double @sqrt(double %3)
store double %4, double* %1
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = fdiv double %6, %4
%8 = getelementptr inbounds double, double* %1, i64 3
store double %7, double* %8
%9 = getelementptr inbounds double, double* %0, i64 2
%10 = load double, double* %9
%11 = fdiv double %10, %4
%12 = getelementptr inbounds double, double* %1, i64 6
store double %11, double* %12
%13 = getelementptr inbounds double, double* %0, i64 4
%14 = load double, double* %13
%15 = fneg double %7
%16 = tail call double @llvm.fmuladd.f64(double %15, double %7, double %14)
%17 = tail call double @sqrt(double %16)
%18 = getelementptr inbounds double, double* %1, i64 4
store double %17, double* %18
%19 = getelementptr inbounds double, double* %0, i64 5
%20 = load double, double* %19
%21 = load double, double* %8
%22 = load double, double* %12
%23 = fneg double %21
%24 = tail call double @llvm.fmuladd.f64(double %23, double %22, double %20)
%25 = fdiv double %24, %17
%26 = getelementptr inbounds double, double* %1, i64 7
store double %25, double* %26
%27 = getelementptr inbounds double, double* %0, i64 8
%28 = load double, double* %27
%29 = fneg double %22
%30 = tail call double @llvm.fmuladd.f64(double %29, double %22, double %28)
%31 = fneg double %25
%32 = tail call double @llvm.fmuladd.f64(double %31, double %25, double %30)
%33 = tail call double @sqrt(double %32)
%34 = getelementptr inbounds double, double* %1, i64 8
store double %33, double* %34
%35 = getelementptr inbounds double, double* %1, i64 1
%36 = getelementptr inbounds double, double* %1, i64 5
store double 0.000000e+00, double* %36
%37 = bitcast double* %35 to i8*
ret void
}