; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (r8lib)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @r8mat_house_form(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @r8mat_house_post(i32 noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = mul i64 %14, 8
  %16 = call noalias ptr @malloc(i64 noundef %15) #5
  store ptr %16, ptr %9, align 8, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %27, %4
  %18 = load i32, ptr %11, align 4, !tbaa !5
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 1
  %21 = icmp slt i32 %18, %20
  br i1 %21, label %22, label %30

22:                                               ; preds = %17
  %23 = load ptr, ptr %9, align 8, !tbaa !9
  %24 = load i32, ptr %11, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds double, ptr %23, i64 %25
  store double 0.000000e+00, ptr %26, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %22
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %11, align 4, !tbaa !5
  br label %17, !llvm.loop !13

30:                                               ; preds = %17
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = sub nsw i32 %31, 1
  store i32 %32, ptr %11, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %51, %30
  %34 = load i32, ptr %11, align 4, !tbaa !5
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %54

37:                                               ; preds = %33
  %38 = load ptr, ptr %6, align 8, !tbaa !9
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = load i32, ptr %11, align 4, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = mul nsw i32 %40, %41
  %43 = add nsw i32 %39, %42
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %38, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = load ptr, ptr %9, align 8, !tbaa !9
  %48 = load i32, ptr %11, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds double, ptr %47, i64 %49
  store double %46, ptr %50, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %37
  %52 = load i32, ptr %11, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %11, align 4, !tbaa !5
  br label %33, !llvm.loop !15

54:                                               ; preds = %33
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = load ptr, ptr %9, align 8, !tbaa !9
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = call ptr @r8vec_house_column(i32 noundef %55, ptr noundef %56, i32 noundef %57)
  store ptr %58, ptr %12, align 8, !tbaa !9
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = load ptr, ptr %12, align 8, !tbaa !9
  %61 = call ptr @r8mat_house_form(i32 noundef %59, ptr noundef %60)
  store ptr %61, ptr %10, align 8, !tbaa !9
  %62 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %62) #4
  %63 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %63) #4
  %64 = load ptr, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret ptr %64
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @r8vec_house_column(i32 noundef, ptr noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @r8mat_house_form(i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @r8mat_house_post(i32 noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = sext i32 %0 to i64
  %6 = shl nsw i64 %5, 3
  %7 = tail call noalias ptr @malloc(i64 noundef %6) #4
  %8 = add i32 %3, -1
  %9 = icmp sgt i32 %3, 1
  br i1 %9, label %.lr.ph.preheader, label %.preheader

.lr.ph.preheader:                                 ; preds = %4
  %10 = zext nneg i32 %8 to i64
  %11 = shl nuw nsw i64 %10, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 %11, i1 false), !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.lr.ph.preheader, %4
  %.not = icmp sgt i32 %3, %0
  br i1 %.not, label %._crit_edge, label %.lr.ph28.preheader

.lr.ph28.preheader:                               ; preds = %.preheader
  %12 = sext i32 %8 to i64
  %13 = sext i32 %2 to i64
  %invariant.gep = getelementptr double, ptr %1, i64 %13
  %14 = sub i32 %0, %3
  %15 = zext i32 %14 to i64
  %16 = add nuw nsw i64 %15, 1
  %min.iters.check = icmp ugt i32 %14, 2
  %ident.check.not = icmp eq i32 %0, 1
  %or.cond = and i1 %min.iters.check, %ident.check.not
  br i1 %or.cond, label %vector.ph, label %.lr.ph28.preheader32

vector.ph:                                        ; preds = %.lr.ph28.preheader
  %n.vec = and i64 %16, 8589934588
  %ind.end = add nsw i64 %n.vec, %12
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %index, %12
  %17 = getelementptr double, ptr %invariant.gep, i64 %offset.idx
  %18 = getelementptr i8, ptr %17, i64 16
  %wide.load = load <2 x double>, ptr %17, align 8, !tbaa !5
  %wide.load31 = load <2 x double>, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds double, ptr %7, i64 %offset.idx
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  store <2 x double> %wide.load, ptr %19, align 8, !tbaa !5
  store <2 x double> %wide.load31, ptr %20, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %21 = icmp eq i64 %index.next, %n.vec
  br i1 %21, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %16, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph28.preheader32

.lr.ph28.preheader32:                             ; preds = %middle.block, %.lr.ph28.preheader
  %indvars.iv.ph = phi i64 [ %12, %.lr.ph28.preheader ], [ %ind.end, %middle.block ]
  %22 = trunc i64 %indvars.iv.ph to i32
  %23 = sub i32 %0, %22
  %xtraiter = and i32 %23, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph28.prol.loopexit, label %.lr.ph28.prol

.lr.ph28.prol:                                    ; preds = %.lr.ph28.preheader32, %.lr.ph28.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %.lr.ph28.prol ], [ %indvars.iv.ph, %.lr.ph28.preheader32 ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph28.prol ], [ 0, %.lr.ph28.preheader32 ]
  %24 = mul nsw i64 %indvars.iv.prol, %5
  %gep.prol = getelementptr double, ptr %invariant.gep, i64 %24
  %25 = load double, ptr %gep.prol, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %7, i64 %indvars.iv.prol
  store double %25, ptr %26, align 8, !tbaa !5
  %indvars.iv.next.prol = add nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph28.prol.loopexit, label %.lr.ph28.prol, !llvm.loop !13

.lr.ph28.prol.loopexit:                           ; preds = %.lr.ph28.prol, %.lr.ph28.preheader32
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph28.preheader32 ], [ %indvars.iv.next.prol, %.lr.ph28.prol ]
  %27 = sub i32 %22, %0
  %28 = icmp ugt i32 %27, -4
  br i1 %28, label %._crit_edge, label %.lr.ph28

.lr.ph28:                                         ; preds = %.lr.ph28.prol.loopexit, %.lr.ph28
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %.lr.ph28 ], [ %indvars.iv.unr, %.lr.ph28.prol.loopexit ]
  %29 = mul nsw i64 %indvars.iv, %5
  %gep = getelementptr double, ptr %invariant.gep, i64 %29
  %30 = load double, ptr %gep, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %7, i64 %indvars.iv
  store double %30, ptr %31, align 8, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %32 = mul nsw i64 %indvars.iv.next, %5
  %gep.1 = getelementptr double, ptr %invariant.gep, i64 %32
  %33 = load double, ptr %gep.1, align 8, !tbaa !5
  %34 = getelementptr inbounds double, ptr %7, i64 %indvars.iv.next
  store double %33, ptr %34, align 8, !tbaa !5
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %35 = mul nsw i64 %indvars.iv.next.1, %5
  %gep.2 = getelementptr double, ptr %invariant.gep, i64 %35
  %36 = load double, ptr %gep.2, align 8, !tbaa !5
  %37 = getelementptr inbounds double, ptr %7, i64 %indvars.iv.next.1
  store double %36, ptr %37, align 8, !tbaa !5
  %indvars.iv.next.2 = add nsw i64 %indvars.iv, 3
  %38 = mul nsw i64 %indvars.iv.next.2, %5
  %gep.3 = getelementptr double, ptr %invariant.gep, i64 %38
  %39 = load double, ptr %gep.3, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %7, i64 %indvars.iv.next.2
  store double %39, ptr %40, align 8, !tbaa !5
  %indvars.iv.next.3 = add nsw i64 %indvars.iv, 4
  %lftr.wideiv.3 = trunc i64 %indvars.iv.next.3 to i32
  %exitcond.not.3 = icmp eq i32 %lftr.wideiv.3, %0
  br i1 %exitcond.not.3, label %._crit_edge, label %.lr.ph28, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph28.prol.loopexit, %.lr.ph28, %middle.block, %.preheader
  %41 = tail call ptr @r8vec_house_column(i32 noundef %0, ptr noundef %7, i32 noundef %3)
  %42 = tail call ptr @r8mat_house_form(i32 noundef %0, ptr noundef %41)
  tail call void @free(ptr noundef %7) #5
  tail call void @free(ptr noundef %41) #5
  ret ptr %42
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @r8vec_house_column(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind allocsize(0) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !10, !11}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass