#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 */
int /*<<< orphan*/ assert(int);
double sqrt(double const);
void doubles_mat33_chol(const double *A, int Arows, int Acols, double *R,
                        int Brows, int Bcols) {
  assert(Arows == Brows);
  assert(Bcols == Bcols);
  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):
<doubles_mat33_chol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%eax
cmp    -0x20(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x18(%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   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x18(%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    -0x18(%rbp),%rax
divsd  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x30(%rax),%xmm1
mov    -0x18(%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    -0x18(%rbp),%rax
movsd  0x38(%rax),%xmm0
mov    -0x18(%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   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_mat33_chol>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdi,%r14
xor    %edi,%edi
cmp    %r8d,%esi
sete   %dil
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
movsd  (%r14),%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jb     1157 <doubles_mat33_chol+0x37>
sqrtsd %xmm0,%xmm0
jmp    1160 <doubles_mat33_chol+0x40>
call   1040 <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     119c <doubles_mat33_chol+0x7c>
sqrtsd %xmm0,%xmm0
jmp    11a1 <doubles_mat33_chol+0x81>
call   1040 <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     11ed <doubles_mat33_chol+0xcd>
sqrtsd %xmm0,%xmm0
jmp    11f2 <doubles_mat33_chol+0xd2>
call   1040 <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 @doubles_mat33_chol(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5) {
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double* %3, double** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i32, i32* %8
%14 = load i32, i32* %11
%15 = icmp eq i32 %13, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %12
%19 = load i32, i32* %12
%20 = icmp eq i32 %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load double*, double** %7
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
%26 = call double @sqrt(double %25)
%27 = load double*, double** %10
%28 = getelementptr inbounds double, double* %27, i64 0
store double %26, double* %28
%29 = load double*, double** %7
%30 = getelementptr inbounds double, double* %29, i64 1
%31 = load double, double* %30
%32 = load double*, double** %10
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = load double, double* %33
%35 = fdiv double %31, %34
%36 = load double*, double** %10
%37 = getelementptr inbounds double, double* %36, i64 3
store double %35, double* %37
%38 = load double*, double** %7
%39 = getelementptr inbounds double, double* %38, i64 2
%40 = load double, double* %39
%41 = load double*, double** %10
%42 = getelementptr inbounds double, double* %41, i64 0
%43 = load double, double* %42
%44 = fdiv double %40, %43
%45 = load double*, double** %10
%46 = getelementptr inbounds double, double* %45, i64 6
store double %44, double* %46
%47 = load double*, double** %7
%48 = getelementptr inbounds double, double* %47, i64 4
%49 = load double, double* %48
%50 = load double*, double** %10
%51 = getelementptr inbounds double, double* %50, i64 3
%52 = load double, double* %51
%53 = load double*, double** %10
%54 = getelementptr inbounds double, double* %53, i64 3
%55 = load double, double* %54
%56 = fneg double %52
%57 = call double @llvm.fmuladd.f64(double %56, double %55, double %49)
%58 = call double @sqrt(double %57)
%59 = load double*, double** %10
%60 = getelementptr inbounds double, double* %59, i64 4
store double %58, double* %60
%61 = load double*, double** %7
%62 = getelementptr inbounds double, double* %61, i64 5
%63 = load double, double* %62
%64 = load double*, double** %10
%65 = getelementptr inbounds double, double* %64, i64 3
%66 = load double, double* %65
%67 = load double*, double** %10
%68 = getelementptr inbounds double, double* %67, i64 6
%69 = load double, double* %68
%70 = fneg double %66
%71 = call double @llvm.fmuladd.f64(double %70, double %69, double %63)
%72 = load double*, double** %10
%73 = getelementptr inbounds double, double* %72, i64 4
%74 = load double, double* %73
%75 = fdiv double %71, %74
%76 = load double*, double** %10
%77 = getelementptr inbounds double, double* %76, i64 7
store double %75, double* %77
%78 = load double*, double** %7
%79 = getelementptr inbounds double, double* %78, i64 8
%80 = load double, double* %79
%81 = load double*, double** %10
%82 = getelementptr inbounds double, double* %81, i64 6
%83 = load double, double* %82
%84 = load double*, double** %10
%85 = getelementptr inbounds double, double* %84, i64 6
%86 = load double, double* %85
%87 = fneg double %83
%88 = call double @llvm.fmuladd.f64(double %87, double %86, double %80)
%89 = load double*, double** %10
%90 = getelementptr inbounds double, double* %89, i64 7
%91 = load double, double* %90
%92 = load double*, double** %10
%93 = getelementptr inbounds double, double* %92, i64 7
%94 = load double, double* %93
%95 = fneg double %91
%96 = call double @llvm.fmuladd.f64(double %95, double %94, double %88)
%97 = call double @sqrt(double %96)
%98 = load double*, double** %10
%99 = getelementptr inbounds double, double* %98, i64 8
store double %97, double* %99
%100 = load double*, double** %10
%101 = getelementptr inbounds double, double* %100, i64 1
store double 0.000000e+00, double* %101
%102 = load double*, double** %10
%103 = getelementptr inbounds double, double* %102, i64 2
store double 0.000000e+00, double* %103
%104 = load double*, double** %10
%105 = getelementptr inbounds double, double* %104, i64 5
store double 0.000000e+00, double* %105
ret void
}

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