#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);
float sqrt(float const);
void floats_mat33_chol(const float *A, int Arows, int Acols, float *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):
<floats_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
movss  (%rax),%xmm0
call   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x18(%rbp),%rax
divss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
divss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movss  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
movss  0xc(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  0xc(%rax),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movss  0x14(%rax),%xmm1
mov    -0x18(%rbp),%rax
movss  0xc(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  0x18(%rax),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
divss  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x1c(%rax)
mov    -0x8(%rbp),%rax
movss  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  0x18(%rax),%xmm1
mov    -0x18(%rbp),%rax
movss  0x18(%rax),%xmm2
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movss  0x1c(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  0x1c(%rax),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x20(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x14(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floats_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>
movss  (%r14),%xmm0
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm0
jb     1155 <floats_mat33_chol+0x35>
sqrtss %xmm0,%xmm0
jmp    115d <floats_mat33_chol+0x3d>
call   1040 <sqrt@plt>
xorps  %xmm3,%xmm3
movss  %xmm0,(%rbx)
movss  0x4(%r14),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0xc(%rbx)
movss  0x8(%r14),%xmm2
divss  %xmm0,%xmm2
movss  %xmm2,0x18(%rbx)
movss  0x10(%r14),%xmm0
mulss  %xmm1,%xmm1
subss  %xmm1,%xmm0
ucomiss %xmm3,%xmm0
jb     1198 <floats_mat33_chol+0x78>
sqrtss %xmm0,%xmm0
jmp    119d <floats_mat33_chol+0x7d>
call   1040 <sqrt@plt>
movss  %xmm0,0x10(%rbx)
movss  0x14(%r14),%xmm1
movss  0x18(%rbx),%xmm2
movss  0xc(%rbx),%xmm3
mulss  %xmm2,%xmm3
subss  %xmm3,%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x1c(%rbx)
movss  0x20(%r14),%xmm0
mulss  %xmm2,%xmm2
subss  %xmm2,%xmm0
mulss  %xmm1,%xmm1
subss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11e7 <floats_mat33_chol+0xc7>
sqrtss %xmm0,%xmm0
jmp    11ec <floats_mat33_chol+0xcc>
call   1040 <sqrt@plt>
movss  %xmm0,0x20(%rbx)
movq   $0x0,0x4(%rbx)
movl   $0x0,0x14(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @floats_mat33_chol(float* %0, i32 %1, i32 %2, float* %3, i32 %4, i32 %5) {
%7 = alloca float*
%8 = alloca i32
%9 = alloca i32
%10 = alloca float*
%11 = alloca i32
%12 = alloca i32
store float* %0, float** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store float* %3, float** %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 float*, float** %7
%24 = getelementptr inbounds float, float* %23, i64 0
%25 = load float, float* %24
%26 = call float @sqrt(float %25)
%27 = load float*, float** %10
%28 = getelementptr inbounds float, float* %27, i64 0
store float %26, float* %28
%29 = load float*, float** %7
%30 = getelementptr inbounds float, float* %29, i64 1
%31 = load float, float* %30
%32 = load float*, float** %10
%33 = getelementptr inbounds float, float* %32, i64 0
%34 = load float, float* %33
%35 = fdiv float %31, %34
%36 = load float*, float** %10
%37 = getelementptr inbounds float, float* %36, i64 3
store float %35, float* %37
%38 = load float*, float** %7
%39 = getelementptr inbounds float, float* %38, i64 2
%40 = load float, float* %39
%41 = load float*, float** %10
%42 = getelementptr inbounds float, float* %41, i64 0
%43 = load float, float* %42
%44 = fdiv float %40, %43
%45 = load float*, float** %10
%46 = getelementptr inbounds float, float* %45, i64 6
store float %44, float* %46
%47 = load float*, float** %7
%48 = getelementptr inbounds float, float* %47, i64 4
%49 = load float, float* %48
%50 = load float*, float** %10
%51 = getelementptr inbounds float, float* %50, i64 3
%52 = load float, float* %51
%53 = load float*, float** %10
%54 = getelementptr inbounds float, float* %53, i64 3
%55 = load float, float* %54
%56 = fneg float %52
%57 = call float @llvm.fmuladd.f32(float %56, float %55, float %49)
%58 = call float @sqrt(float %57)
%59 = load float*, float** %10
%60 = getelementptr inbounds float, float* %59, i64 4
store float %58, float* %60
%61 = load float*, float** %7
%62 = getelementptr inbounds float, float* %61, i64 5
%63 = load float, float* %62
%64 = load float*, float** %10
%65 = getelementptr inbounds float, float* %64, i64 3
%66 = load float, float* %65
%67 = load float*, float** %10
%68 = getelementptr inbounds float, float* %67, i64 6
%69 = load float, float* %68
%70 = fneg float %66
%71 = call float @llvm.fmuladd.f32(float %70, float %69, float %63)
%72 = load float*, float** %10
%73 = getelementptr inbounds float, float* %72, i64 4
%74 = load float, float* %73
%75 = fdiv float %71, %74
%76 = load float*, float** %10
%77 = getelementptr inbounds float, float* %76, i64 7
store float %75, float* %77
%78 = load float*, float** %7
%79 = getelementptr inbounds float, float* %78, i64 8
%80 = load float, float* %79
%81 = load float*, float** %10
%82 = getelementptr inbounds float, float* %81, i64 6
%83 = load float, float* %82
%84 = load float*, float** %10
%85 = getelementptr inbounds float, float* %84, i64 6
%86 = load float, float* %85
%87 = fneg float %83
%88 = call float @llvm.fmuladd.f32(float %87, float %86, float %80)
%89 = load float*, float** %10
%90 = getelementptr inbounds float, float* %89, i64 7
%91 = load float, float* %90
%92 = load float*, float** %10
%93 = getelementptr inbounds float, float* %92, i64 7
%94 = load float, float* %93
%95 = fneg float %91
%96 = call float @llvm.fmuladd.f32(float %95, float %94, float %88)
%97 = call float @sqrt(float %96)
%98 = load float*, float** %10
%99 = getelementptr inbounds float, float* %98, i64 8
store float %97, float* %99
%100 = load float*, float** %10
%101 = getelementptr inbounds float, float* %100, i64 1
store float 0.000000e+00, float* %101
%102 = load float*, float** %10
%103 = getelementptr inbounds float, float* %102, i64 2
store float 0.000000e+00, float* %103
%104 = load float*, float** %10
%105 = getelementptr inbounds float, float* %104, i64 5
store float 0.000000e+00, float* %105
ret void
}

LLVM IR (-O2):
define void @floats_mat33_chol(float* nocapture %0, i32 %1, i32 %2, float* 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 float, float* %0
%12 = tail call float @sqrt(float %11)
store float %12, float* %3
%13 = getelementptr inbounds float, float* %0, i64 1
%14 = load float, float* %13
%15 = fdiv float %14, %12
%16 = getelementptr inbounds float, float* %3, i64 3
store float %15, float* %16
%17 = getelementptr inbounds float, float* %0, i64 2
%18 = load float, float* %17
%19 = fdiv float %18, %12
%20 = getelementptr inbounds float, float* %3, i64 6
store float %19, float* %20
%21 = getelementptr inbounds float, float* %0, i64 4
%22 = load float, float* %21
%23 = fneg float %15
%24 = tail call float @llvm.fmuladd.f32(float %23, float %15, float %22)
%25 = tail call float @sqrt(float %24)
%26 = getelementptr inbounds float, float* %3, i64 4
store float %25, float* %26
%27 = getelementptr inbounds float, float* %0, i64 5
%28 = load float, float* %27
%29 = load float, float* %16
%30 = load float, float* %20
%31 = fneg float %29
%32 = tail call float @llvm.fmuladd.f32(float %31, float %30, float %28)
%33 = fdiv float %32, %25
%34 = getelementptr inbounds float, float* %3, i64 7
store float %33, float* %34
%35 = getelementptr inbounds float, float* %0, i64 8
%36 = load float, float* %35
%37 = fneg float %30
%38 = tail call float @llvm.fmuladd.f32(float %37, float %30, float %36)
%39 = fneg float %33
%40 = tail call float @llvm.fmuladd.f32(float %39, float %33, float %38)
%41 = tail call float @sqrt(float %40)
%42 = getelementptr inbounds float, float* %3, i64 8
store float %41, float* %42
%43 = getelementptr inbounds float, float* %3, i64 1
store float 0.000000e+00, float* %43
%44 = getelementptr inbounds float, float* %3, i64 2
store float 0.000000e+00, float* %44
%45 = getelementptr inbounds float, float* %3, i64 5
store float 0.000000e+00, float* %45
ret void
}