; 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_l_solve(i32 noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = mul i64 %12, 8
  %14 = call noalias ptr @malloc(i64 noundef %13) #5
  store ptr %14, ptr %10, align 8, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %66, %3
  %16 = load i32, ptr %8, align 4, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %69

19:                                               ; preds = %15
  store double 0.000000e+00, ptr %7, align 8, !tbaa !11
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %41, %19
  %21 = load i32, ptr %9, align 4, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %44

24:                                               ; preds = %20
  %25 = load double, ptr %7, align 8, !tbaa !11
  %26 = load ptr, ptr %5, align 8, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = load i32, ptr %9, align 4, !tbaa !5
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = mul nsw i32 %28, %29
  %31 = add nsw i32 %27, %30
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds double, ptr %26, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = load ptr, ptr %10, align 8, !tbaa !9
  %36 = load i32, ptr %9, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %35, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !11
  %40 = call double @llvm.fmuladd.f64(double %34, double %39, double %25)
  store double %40, ptr %7, align 8, !tbaa !11
  br label %41

41:                                               ; preds = %24
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %9, align 4, !tbaa !5
  br label %20, !llvm.loop !13

44:                                               ; preds = %20
  %45 = load ptr, ptr %6, align 8, !tbaa !9
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %45, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = load double, ptr %7, align 8, !tbaa !11
  %51 = fsub double %49, %50
  %52 = load ptr, ptr %5, align 8, !tbaa !9
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = load i32, ptr %8, align 4, !tbaa !5
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = mul nsw i32 %54, %55
  %57 = add nsw i32 %53, %56
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %52, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = fdiv double %51, %60
  %62 = load ptr, ptr %10, align 8, !tbaa !9
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %62, i64 %64
  store double %61, ptr %65, align 8, !tbaa !11
  br label %66

66:                                               ; preds = %44
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %8, align 4, !tbaa !5
  br label %15, !llvm.loop !15

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

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}


; 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_l_solve(i32 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #2 {
  %4 = sext i32 %0 to i64
  %5 = shl 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.lr.ph, label %._crit_edge29

.preheader.lr.ph:                                 ; preds = %3
  %8 = add nuw i32 %0, 1
  %9 = zext nneg i32 %0 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %indvars.iv31 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next32, %._crit_edge ]
  %.not = icmp eq i64 %indvars.iv31, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %invariant.gep = getelementptr inbounds double, ptr %1, i64 %indvars.iv31
  %xtraiter = and i64 %indvars.iv31, 3
  %10 = icmp ult i64 %indvars.iv31, 4
  br i1 %10, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %indvars.iv31, 9223372036854775804
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %.027 = phi double [ 0.000000e+00, %.lr.ph.preheader.new ], [ %30, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %11 = mul nuw nsw i64 %indvars.iv, %9
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %11
  %12 = load double, ptr %gep, align 8, !tbaa !5
  %13 = getelementptr inbounds double, ptr %6, i64 %indvars.iv
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = tail call double @llvm.fmuladd.f64(double %12, double %14, double %.027)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %16 = mul nuw nsw i64 %indvars.iv.next, %9
  %gep.1 = getelementptr inbounds double, ptr %invariant.gep, i64 %16
  %17 = load double, ptr %gep.1, align 8, !tbaa !5
  %18 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.next
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = tail call double @llvm.fmuladd.f64(double %17, double %19, double %15)
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %21 = mul nuw nsw i64 %indvars.iv.next.1, %9
  %gep.2 = getelementptr inbounds double, ptr %invariant.gep, i64 %21
  %22 = load double, ptr %gep.2, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.next.1
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %20)
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %26 = mul nuw nsw i64 %indvars.iv.next.2, %9
  %gep.3 = getelementptr inbounds double, ptr %invariant.gep, i64 %26
  %27 = load double, ptr %gep.3, align 8, !tbaa !5
  %28 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.next.2
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = tail call double @llvm.fmuladd.f64(double %27, double %29, double %25)
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %30, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %.027.unr = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %30, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.027.epil = phi double [ %35, %.lr.ph.epil ], [ %.027.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %31 = mul nuw nsw i64 %indvars.iv.epil, %9
  %gep.epil = getelementptr inbounds double, ptr %invariant.gep, i64 %31
  %32 = load double, ptr %gep.epil, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %6, i64 %indvars.iv.epil
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = tail call double @llvm.fmuladd.f64(double %32, double %34, double %.027.epil)
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !11

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader
  %.0.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %35, %.lr.ph.epil ]
  %36 = getelementptr inbounds double, ptr %2, i64 %indvars.iv31
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = fsub double %37, %.0.lcssa
  %39 = trunc nuw nsw i64 %indvars.iv31 to i32
  %40 = mul i32 %8, %39
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %1, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !5
  %44 = fdiv double %38, %43
  %45 = getelementptr inbounds double, ptr %6, i64 %indvars.iv31
  store double %44, ptr %45, align 8, !tbaa !5
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %exitcond35.not = icmp eq i64 %indvars.iv.next32, %9
  br i1 %exitcond35.not, label %._crit_edge29, label %.preheader, !llvm.loop !13

._crit_edge29:                                    ; preds = %._crit_edge, %3
  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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !10}


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