#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);
scalar_t__ 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] = (double)sqrt(A[0]);
  R[3] = A[1] / R[0];
  R[6] = A[2] / R[0];
  R[4] = (double)sqrt(A[4] - R[3] * R[3]);
  R[7] = (A[5] - R[3] * R[6]) / R[4];
  R[8] = (double)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>
cvtsi2sd %rax,%xmm0
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>
cvtsi2sd %rax,%xmm0
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>
cvtsi2sd %rax,%xmm0
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
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
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
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
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
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
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 i64 @sqrt(double %25)
%27 = sitofp i64 %26 to double
%28 = load double*, double** %10
%29 = getelementptr inbounds double, double* %28, i64 0
store double %27, double* %29
%30 = load double*, double** %7
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = load double*, double** %10
%34 = getelementptr inbounds double, double* %33, i64 0
%35 = load double, double* %34
%36 = fdiv double %32, %35
%37 = load double*, double** %10
%38 = getelementptr inbounds double, double* %37, i64 3
store double %36, double* %38
%39 = load double*, double** %7
%40 = getelementptr inbounds double, double* %39, i64 2
%41 = load double, double* %40
%42 = load double*, double** %10
%43 = getelementptr inbounds double, double* %42, i64 0
%44 = load double, double* %43
%45 = fdiv double %41, %44
%46 = load double*, double** %10
%47 = getelementptr inbounds double, double* %46, i64 6
store double %45, double* %47
%48 = load double*, double** %7
%49 = getelementptr inbounds double, double* %48, i64 4
%50 = load double, double* %49
%51 = load double*, double** %10
%52 = getelementptr inbounds double, double* %51, i64 3
%53 = load double, double* %52
%54 = load double*, double** %10
%55 = getelementptr inbounds double, double* %54, i64 3
%56 = load double, double* %55
%57 = fneg double %53
%58 = call double @llvm.fmuladd.f64(double %57, double %56, double %50)
%59 = call i64 @sqrt(double %58)
%60 = sitofp i64 %59 to double
%61 = load double*, double** %10
%62 = getelementptr inbounds double, double* %61, i64 4
store double %60, double* %62
%63 = load double*, double** %7
%64 = getelementptr inbounds double, double* %63, i64 5
%65 = load double, double* %64
%66 = load double*, double** %10
%67 = getelementptr inbounds double, double* %66, i64 3
%68 = load double, double* %67
%69 = load double*, double** %10
%70 = getelementptr inbounds double, double* %69, i64 6
%71 = load double, double* %70
%72 = fneg double %68
%73 = call double @llvm.fmuladd.f64(double %72, double %71, double %65)
%74 = load double*, double** %10
%75 = getelementptr inbounds double, double* %74, i64 4
%76 = load double, double* %75
%77 = fdiv double %73, %76
%78 = load double*, double** %10
%79 = getelementptr inbounds double, double* %78, i64 7
store double %77, double* %79
%80 = load double*, double** %7
%81 = getelementptr inbounds double, double* %80, i64 8
%82 = load double, double* %81
%83 = load double*, double** %10
%84 = getelementptr inbounds double, double* %83, i64 6
%85 = load double, double* %84
%86 = load double*, double** %10
%87 = getelementptr inbounds double, double* %86, i64 6
%88 = load double, double* %87
%89 = fneg double %85
%90 = call double @llvm.fmuladd.f64(double %89, double %88, double %82)
%91 = load double*, double** %10
%92 = getelementptr inbounds double, double* %91, i64 7
%93 = load double, double* %92
%94 = load double*, double** %10
%95 = getelementptr inbounds double, double* %94, i64 7
%96 = load double, double* %95
%97 = fneg double %93
%98 = call double @llvm.fmuladd.f64(double %97, double %96, double %90)
%99 = call i64 @sqrt(double %98)
%100 = sitofp i64 %99 to double
%101 = load double*, double** %10
%102 = getelementptr inbounds double, double* %101, i64 8
store double %100, double* %102
%103 = load double*, double** %10
%104 = getelementptr inbounds double, double* %103, i64 1
store double 0.000000e+00, double* %104
%105 = load double*, double** %10
%106 = getelementptr inbounds double, double* %105, i64 2
store double 0.000000e+00, double* %106
%107 = load double*, double** %10
%108 = getelementptr inbounds double, double* %107, i64 5
store double 0.000000e+00, double* %108
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 i64 @sqrt(double %11)
%13 = sitofp i64 %12 to double
store double %13, double* %3
%14 = getelementptr inbounds double, double* %0, i64 1
%15 = load double, double* %14
%16 = fdiv double %15, %13
%17 = getelementptr inbounds double, double* %3, i64 3
store double %16, double* %17
%18 = getelementptr inbounds double, double* %0, i64 2
%19 = load double, double* %18
%20 = fdiv double %19, %13
%21 = getelementptr inbounds double, double* %3, i64 6
store double %20, double* %21
%22 = getelementptr inbounds double, double* %0, i64 4
%23 = load double, double* %22
%24 = fneg double %16
%25 = tail call double @llvm.fmuladd.f64(double %24, double %16, double %23)
%26 = tail call i64 @sqrt(double %25)
%27 = sitofp i64 %26 to double
%28 = getelementptr inbounds double, double* %3, i64 4
store double %27, double* %28
%29 = getelementptr inbounds double, double* %0, i64 5
%30 = load double, double* %29
%31 = load double, double* %17
%32 = load double, double* %21
%33 = fneg double %31
%34 = tail call double @llvm.fmuladd.f64(double %33, double %32, double %30)
%35 = fdiv double %34, %27
%36 = getelementptr inbounds double, double* %3, i64 7
store double %35, double* %36
%37 = getelementptr inbounds double, double* %0, i64 8
%38 = load double, double* %37
%39 = fneg double %32
%40 = tail call double @llvm.fmuladd.f64(double %39, double %32, double %38)
%41 = fneg double %35
%42 = tail call double @llvm.fmuladd.f64(double %41, double %35, double %40)
%43 = tail call i64 @sqrt(double %42)
%44 = sitofp i64 %43 to double
%45 = getelementptr inbounds double, double* %3, i64 8
store double %44, double* %45
%46 = getelementptr inbounds double, double* %3, i64 1
%47 = getelementptr inbounds double, double* %3, i64 5
store double 0.000000e+00, double* %47
%48 = bitcast double* %46 to i8*
ret void
}