; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

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

15:                                               ; preds = %111, %2
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %114

19:                                               ; preds = %15
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %107, %19
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %110

24:                                               ; preds = %20
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %28, label %37

28:                                               ; preds = %24
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = mul nsw i32 %31, %32
  %34 = add nsw i32 %30, %33
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %29, i64 %35
  store double 0.000000e+00, ptr %36, align 8, !tbaa !11
  br label %106

37:                                               ; preds = %24
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = icmp eq i32 %38, %39
  br i1 %40, label %41, label %50

41:                                               ; preds = %37
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = mul nsw i32 %44, %45
  %47 = add nsw i32 %43, %46
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds double, ptr %42, i64 %48
  store double 1.000000e+00, ptr %49, align 8, !tbaa !11
  br label %105

50:                                               ; preds = %37
  %51 = load ptr, ptr %5, align 8, !tbaa !9
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = mul nsw i32 %53, %54
  %56 = add nsw i32 %52, %55
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %51, i64 %57
  store double 0.000000e+00, ptr %58, align 8, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %101, %50
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %63, label %104

63:                                               ; preds = %59
  %64 = load ptr, ptr %5, align 8, !tbaa !9
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = mul nsw i32 %66, %67
  %69 = add nsw i32 %65, %68
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %64, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !11
  %73 = load ptr, ptr %4, align 8, !tbaa !9
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = mul nsw i32 %75, %76
  %78 = add nsw i32 %74, %77
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds double, ptr %73, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !11
  %82 = load ptr, ptr %5, align 8, !tbaa !9
  %83 = load i32, ptr %8, align 4, !tbaa !5
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = load i32, ptr %3, align 4, !tbaa !5
  %86 = mul nsw i32 %84, %85
  %87 = add nsw i32 %83, %86
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds double, ptr %82, i64 %88
  %90 = load double, ptr %89, align 8, !tbaa !11
  %91 = fneg double %81
  %92 = call double @llvm.fmuladd.f64(double %91, double %90, double %72)
  %93 = load ptr, ptr %5, align 8, !tbaa !9
  %94 = load i32, ptr %6, align 4, !tbaa !5
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = load i32, ptr %3, align 4, !tbaa !5
  %97 = mul nsw i32 %95, %96
  %98 = add nsw i32 %94, %97
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds double, ptr %93, i64 %99
  store double %92, ptr %100, align 8, !tbaa !11
  br label %101

101:                                              ; preds = %63
  %102 = load i32, ptr %8, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %8, align 4, !tbaa !5
  br label %59, !llvm.loop !13

104:                                              ; preds = %59
  br label %105

105:                                              ; preds = %104, %41
  br label %106

106:                                              ; preds = %105, %28
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %7, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %7, align 4, !tbaa !5
  br label %20, !llvm.loop !15

110:                                              ; preds = %20
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %6, align 4, !tbaa !5
  br label %15, !llvm.loop !16

114:                                              ; preds = %15
  %115 = load ptr, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret ptr %115
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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}
!16 = distinct !{!16, !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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

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

; Function Attrs: nofree nounwind memory(readwrite, argmem: read) uwtable
define dso_local noalias noundef ptr @r8mat_l1_inverse(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = mul nsw i32 %0, %0
  %4 = zext nneg i32 %3 to i64
  %5 = shl nuw nsw i64 %4, 3
  %6 = tail call noalias ptr @malloc(i64 noundef %5) #3
  %7 = icmp sgt i32 %0, 0
  br i1 %7, label %.preheader.us.preheader, label %._crit_edge51

.preheader.us.preheader:                          ; preds = %2
  %8 = zext nneg i32 %0 to i64
  %9 = zext nneg i32 %0 to i64
  %indvars.iv6772 = add nuw nsw i64 %8, 1
  %exitcond66.not.peel = icmp eq i32 %0, 1
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv67 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next68, %._crit_edge.us ]
  %.not = icmp eq i64 %indvars.iv67, 0
  br i1 %.not, label %.lr.ph48.split.us54.peel, label %.lr.ph48.split.us.us.preheader

.lr.ph48.split.us54.peel:                         ; preds = %.preheader.us
  store double 1.000000e+00, ptr %6, align 8, !tbaa !5
  br i1 %exitcond66.not.peel, label %._crit_edge.us, label %.lr.ph48.split.us54

.lr.ph48.split.us.us.preheader:                   ; preds = %.preheader.us
  %invariant.gep77 = getelementptr inbounds double, ptr %6, i64 %indvars.iv67
  %invariant.gep = getelementptr inbounds double, ptr %1, i64 %indvars.iv67
  %10 = mul i64 %indvars.iv67, %indvars.iv6772
  %11 = getelementptr inbounds double, ptr %6, i64 %10
  %invariant.gep79 = getelementptr inbounds double, ptr %6, i64 %indvars.iv67
  %xtraiter = and i64 %indvars.iv67, 1
  %12 = icmp eq i64 %indvars.iv67, 1
  %unroll_iter = and i64 %indvars.iv67, 9223372036854775806
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph48.split.us.us

.lr.ph48.split.us54:                              ; preds = %.lr.ph48.split.us54.peel, %.lr.ph48.split.us54
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %.lr.ph48.split.us54 ], [ 1, %.lr.ph48.split.us54.peel ]
  %13 = mul nuw nsw i64 %indvars.iv62, %9
  %14 = getelementptr inbounds double, ptr %6, i64 %13
  store double 0.000000e+00, ptr %14, align 8, !tbaa !5
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %exitcond66.not = icmp eq i64 %indvars.iv.next63, %9
  br i1 %exitcond66.not, label %._crit_edge.us, label %.lr.ph48.split.us54, !llvm.loop !9

._crit_edge.us:                                   ; preds = %..loopexit_crit_edge.us.us, %.lr.ph48.split.us54.peel, %.lr.ph48.split.us54
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond71.not = icmp eq i64 %indvars.iv.next68, %9
  br i1 %exitcond71.not, label %._crit_edge51, label %.preheader.us, !llvm.loop !12

.lr.ph48.split.us.us:                             ; preds = %.lr.ph48.split.us.us.preheader, %..loopexit_crit_edge.us.us
  %indvars.iv57 = phi i64 [ 0, %.lr.ph48.split.us.us.preheader ], [ %indvars.iv.next58, %..loopexit_crit_edge.us.us ]
  %15 = icmp ult i64 %indvars.iv67, %indvars.iv57
  br i1 %15, label %31, label %16

16:                                               ; preds = %.lr.ph48.split.us.us
  %17 = icmp eq i64 %indvars.iv57, %indvars.iv67
  br i1 %17, label %30, label %.lr.ph.us.us

.lr.ph.us.us:                                     ; preds = %16
  %18 = mul nuw nsw i64 %indvars.iv57, %8
  %gep78 = getelementptr inbounds double, ptr %invariant.gep77, i64 %18
  store double 0.000000e+00, ptr %gep78, align 8, !tbaa !5
  %invariant.gep75 = getelementptr inbounds double, ptr %6, i64 %18
  br i1 %12, label %..loopexit_crit_edge.us.us.loopexit.unr-lcssa, label %.lr.ph.us.us.new

.lr.ph.us.us.new:                                 ; preds = %.lr.ph.us.us, %.lr.ph.us.us.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph.us.us.new ], [ 0, %.lr.ph.us.us ]
  %19 = phi double [ %29, %.lr.ph.us.us.new ], [ 0.000000e+00, %.lr.ph.us.us ]
  %niter = phi i64 [ %niter.next.1, %.lr.ph.us.us.new ], [ 0, %.lr.ph.us.us ]
  %20 = mul nuw nsw i64 %indvars.iv, %8
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %20
  %21 = load double, ptr %gep, align 8, !tbaa !5
  %gep76 = getelementptr inbounds double, ptr %invariant.gep75, i64 %indvars.iv
  %22 = load double, ptr %gep76, align 8, !tbaa !5
  %23 = fneg double %21
  %24 = tail call double @llvm.fmuladd.f64(double %23, double %22, double %19)
  store double %24, ptr %gep78, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %25 = mul nuw nsw i64 %indvars.iv.next, %8
  %gep.1 = getelementptr inbounds double, ptr %invariant.gep, i64 %25
  %26 = load double, ptr %gep.1, align 8, !tbaa !5
  %gep76.1 = getelementptr inbounds double, ptr %invariant.gep75, i64 %indvars.iv.next
  %27 = load double, ptr %gep76.1, align 8, !tbaa !5
  %28 = fneg double %26
  %29 = tail call double @llvm.fmuladd.f64(double %28, double %27, double %24)
  store double %29, ptr %gep78, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %..loopexit_crit_edge.us.us.loopexit.unr-lcssa, label %.lr.ph.us.us.new, !llvm.loop !13

30:                                               ; preds = %16
  store double 1.000000e+00, ptr %11, align 8, !tbaa !5
  br label %..loopexit_crit_edge.us.us

31:                                               ; preds = %.lr.ph48.split.us.us
  %32 = mul nuw nsw i64 %indvars.iv57, %8
  %gep80 = getelementptr inbounds double, ptr %invariant.gep79, i64 %32
  store double 0.000000e+00, ptr %gep80, align 8, !tbaa !5
  br label %..loopexit_crit_edge.us.us

..loopexit_crit_edge.us.us.loopexit.unr-lcssa:    ; preds = %.lr.ph.us.us.new, %.lr.ph.us.us
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.us.us ], [ %indvars.iv.next.1, %.lr.ph.us.us.new ]
  %.unr = phi double [ 0.000000e+00, %.lr.ph.us.us ], [ %29, %.lr.ph.us.us.new ]
  br i1 %lcmp.mod.not, label %..loopexit_crit_edge.us.us, label %..loopexit_crit_edge.us.us.loopexit.epilog-lcssa

..loopexit_crit_edge.us.us.loopexit.epilog-lcssa: ; preds = %..loopexit_crit_edge.us.us.loopexit.unr-lcssa
  %33 = mul nuw nsw i64 %indvars.iv.unr, %8
  %gep.epil = getelementptr inbounds double, ptr %invariant.gep, i64 %33
  %34 = load double, ptr %gep.epil, align 8, !tbaa !5
  %gep76.epil = getelementptr inbounds double, ptr %invariant.gep75, i64 %indvars.iv.unr
  %35 = load double, ptr %gep76.epil, align 8, !tbaa !5
  %36 = fneg double %34
  %37 = tail call double @llvm.fmuladd.f64(double %36, double %35, double %.unr)
  store double %37, ptr %gep78, align 8, !tbaa !5
  br label %..loopexit_crit_edge.us.us

..loopexit_crit_edge.us.us:                       ; preds = %..loopexit_crit_edge.us.us.loopexit.epilog-lcssa, %..loopexit_crit_edge.us.us.loopexit.unr-lcssa, %31, %30
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %exitcond61.not = icmp eq i64 %indvars.iv.next58, %9
  br i1 %exitcond61.not, label %._crit_edge.us, label %.lr.ph48.split.us.us, !llvm.loop !14

._crit_edge51:                                    ; preds = %._crit_edge.us, %2
  ret ptr %6
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { nofree nounwind memory(readwrite, argmem: read) 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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass