; 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 uwtable
declare dso_local ptr @r8mat_identity_new(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @r8mat_house_form(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %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) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store double 0.000000e+00, ptr %5, align 8, !tbaa !11
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %26, %2
  %10 = load i32, ptr %7, align 4, !tbaa !5
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %13, label %29

13:                                               ; preds = %9
  %14 = load double, ptr %5, align 8, !tbaa !11
  %15 = load ptr, ptr %4, align 8, !tbaa !9
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds double, ptr %15, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = load ptr, ptr %4, align 8, !tbaa !9
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds double, ptr %20, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = call double @llvm.fmuladd.f64(double %19, double %24, double %14)
  store double %25, ptr %5, align 8, !tbaa !11
  br label %26

26:                                               ; preds = %13
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %7, align 4, !tbaa !5
  br label %9, !llvm.loop !13

29:                                               ; preds = %9
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = call ptr @r8mat_identity_new(i32 noundef %30)
  store ptr %31, ptr %6, align 8, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %78, %29
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %36, label %81

36:                                               ; preds = %32
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %74, %36
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %77

41:                                               ; preds = %37
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = load i32, ptr %8, 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
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = load ptr, ptr %4, align 8, !tbaa !9
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %51, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !11
  %56 = fmul double 2.000000e+00, %55
  %57 = load ptr, ptr %4, align 8, !tbaa !9
  %58 = load i32, ptr %8, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !11
  %62 = fmul double %56, %61
  %63 = load double, ptr %5, align 8, !tbaa !11
  %64 = fdiv double %62, %63
  %65 = fsub double %50, %64
  %66 = load ptr, ptr %6, align 8, !tbaa !9
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = load i32, ptr %8, align 4, !tbaa !5
  %69 = load i32, ptr %3, align 4, !tbaa !5
  %70 = mul nsw i32 %68, %69
  %71 = add nsw i32 %67, %70
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds double, ptr %66, i64 %72
  store double %65, ptr %73, align 8, !tbaa !11
  br label %74

74:                                               ; preds = %41
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %8, align 4, !tbaa !5
  br label %37, !llvm.loop !15

77:                                               ; preds = %37
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %7, align 4, !tbaa !5
  br label %32, !llvm.loop !16

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = !{!"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: nounwind uwtable
declare dso_local ptr @r8mat_identity_new(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @r8mat_house_form(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = icmp sgt i32 %0, 0
  br i1 %3, label %.lr.ph.preheader, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %2
  %4 = tail call ptr @r8mat_identity_new(i32 noundef %0)
  br label %._crit_edge37

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %0 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %5 = icmp ult i32 %0, 4
  br i1 %5, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  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 ]
  %.02931 = phi double [ 0.000000e+00, %.lr.ph.preheader.new ], [ %17, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %6 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %.02931)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %8)
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %12 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.1
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %11)
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %15 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next.2
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double %14)
  %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.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %17, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %.02931.unr = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %17, %.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.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.unr-lcssa ]
  %.02931.epil = phi double [ %20, %.lr.ph.epil ], [ %.02931.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %18 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.epil
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = tail call double @llvm.fmuladd.f64(double %19, double %19, double %.02931.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 = %.lr.ph.epil, %._crit_edge.unr-lcssa
  %.lcssa = phi double [ %.lcssa.ph, %._crit_edge.unr-lcssa ], [ %20, %.lr.ph.epil ]
  %21 = tail call ptr @r8mat_identity_new(i32 noundef %0)
  br i1 %3, label %.preheader.us.preheader, label %._crit_edge37

.preheader.us.preheader:                          ; preds = %._crit_edge
  %22 = zext nneg i32 %0 to i64
  %xtraiter51 = and i64 %wide.trip.count, 1
  %23 = icmp eq i32 %0, 1
  %unroll_iter54 = and i64 %wide.trip.count, 2147483646
  %lcmp.mod53.not = icmp eq i64 %xtraiter51, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge35.us
  %indvars.iv44 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next45, %._crit_edge35.us ]
  %24 = getelementptr inbounds double, ptr %1, i64 %indvars.iv44
  %invariant.gep = getelementptr inbounds double, ptr %21, i64 %indvars.iv44
  br i1 %23, label %._crit_edge35.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %indvars.iv39 = phi i64 [ %indvars.iv.next40.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %niter55 = phi i64 [ %niter55.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %25 = mul nuw nsw i64 %indvars.iv39, %22
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %25
  %26 = load double, ptr %gep, align 8, !tbaa !5
  %27 = load double, ptr %24, align 8, !tbaa !5
  %28 = fmul double %27, 2.000000e+00
  %29 = getelementptr inbounds double, ptr %1, i64 %indvars.iv39
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = fmul double %28, %30
  %32 = fdiv double %31, %.lcssa
  %33 = fsub double %26, %32
  store double %33, ptr %gep, align 8, !tbaa !5
  %indvars.iv.next40 = or disjoint i64 %indvars.iv39, 1
  %34 = mul nuw nsw i64 %indvars.iv.next40, %22
  %gep.1 = getelementptr inbounds double, ptr %invariant.gep, i64 %34
  %35 = load double, ptr %gep.1, align 8, !tbaa !5
  %36 = load double, ptr %24, align 8, !tbaa !5
  %37 = fmul double %36, 2.000000e+00
  %38 = getelementptr inbounds double, ptr %1, i64 %indvars.iv.next40
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = fmul double %37, %39
  %41 = fdiv double %40, %.lcssa
  %42 = fsub double %35, %41
  store double %42, ptr %gep.1, align 8, !tbaa !5
  %indvars.iv.next40.1 = add nuw nsw i64 %indvars.iv39, 2
  %niter55.next.1 = add i64 %niter55, 2
  %niter55.ncmp.1 = icmp eq i64 %niter55.next.1, %unroll_iter54
  br i1 %niter55.ncmp.1, label %._crit_edge35.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !13

._crit_edge35.us.unr-lcssa:                       ; preds = %.preheader.us.new, %.preheader.us
  %indvars.iv39.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next40.1, %.preheader.us.new ]
  br i1 %lcmp.mod53.not, label %._crit_edge35.us, label %._crit_edge35.us.epilog-lcssa

._crit_edge35.us.epilog-lcssa:                    ; preds = %._crit_edge35.us.unr-lcssa
  %43 = mul nuw nsw i64 %indvars.iv39.unr, %22
  %gep.epil = getelementptr inbounds double, ptr %invariant.gep, i64 %43
  %44 = load double, ptr %gep.epil, align 8, !tbaa !5
  %45 = load double, ptr %24, align 8, !tbaa !5
  %46 = fmul double %45, 2.000000e+00
  %47 = getelementptr inbounds double, ptr %1, i64 %indvars.iv39.unr
  %48 = load double, ptr %47, align 8, !tbaa !5
  %49 = fmul double %46, %48
  %50 = fdiv double %49, %.lcssa
  %51 = fsub double %44, %50
  store double %51, ptr %gep.epil, align 8, !tbaa !5
  br label %._crit_edge35.us

._crit_edge35.us:                                 ; preds = %._crit_edge35.us.unr-lcssa, %._crit_edge35.us.epilog-lcssa
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond48.not = icmp eq i64 %indvars.iv.next45, %22
  br i1 %exitcond48.not, label %._crit_edge37, label %.preheader.us, !llvm.loop !14

._crit_edge37:                                    ; preds = %._crit_edge35.us, %._crit_edge.thread, %._crit_edge
  %52 = phi ptr [ %4, %._crit_edge.thread ], [ %21, %._crit_edge ], [ %21, %._crit_edge35.us ]
  ret ptr %52
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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" }

!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}
!14 = distinct !{!14, !10}


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