; 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
declare double @sqrt(double noundef) #1

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @r8mat_is_symmetric(i32 noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store double 0x7FEFFFFFFFFFFFFF, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = icmp ne i32 %13, %14
  br i1 %15, label %16, label %18

16:                                               ; preds = %3
  store double 0x7FEFFFFFFFFFFFFF, ptr %11, align 8, !tbaa !11
  %17 = load double, ptr %11, align 8, !tbaa !11
  store double %17, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %62

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

19:                                               ; preds = %55, %18
  %20 = load i32, ptr %9, align 4, !tbaa !5
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %58

23:                                               ; preds = %19
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %51, %23
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %28, label %54

28:                                               ; preds = %24
  %29 = load double, ptr %11, align 8, !tbaa !11
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = mul nsw i32 %32, %33
  %35 = add nsw i32 %31, %34
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds double, ptr %30, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !11
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = mul nsw i32 %41, %42
  %44 = add nsw i32 %40, %43
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds double, ptr %39, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !11
  %48 = fsub double %38, %47
  %49 = call double @pow(double noundef %48, double noundef 2.000000e+00) #3
  %50 = fadd double %29, %49
  store double %50, ptr %11, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %28
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %8, align 4, !tbaa !5
  br label %24, !llvm.loop !13

54:                                               ; preds = %24
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %9, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %9, align 4, !tbaa !5
  br label %19, !llvm.loop !15

58:                                               ; preds = %19
  %59 = load double, ptr %11, align 8, !tbaa !11
  %60 = call double @sqrt(double noundef %59) #3
  store double %60, ptr %11, align 8, !tbaa !11
  %61 = load double, ptr %11, align 8, !tbaa !11
  store double %61, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %62

62:                                               ; preds = %58, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %63 = load double, ptr %4, align 8
  ret double %63
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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}


; 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 memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local double @r8mat_is_symmetric(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
  %.not = icmp eq i32 %0, %1
  br i1 %.not, label %.preheader25, label %24

.preheader25:                                     ; preds = %3
  %4 = icmp sgt i32 %0, 0
  br i1 %4, label %.preheader.us.preheader, label %._crit_edge30

.preheader.us.preheader:                          ; preds = %.preheader25
  %5 = zext nneg i32 %0 to i64
  %xtraiter = and i64 %5, 1
  %6 = icmp eq i32 %0, 1
  %unroll_iter = and i64 %5, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv34 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next35, %._crit_edge.us ]
  %.029.us = phi double [ 0.000000e+00, %.preheader.us.preheader ], [ %.lcssa, %._crit_edge.us ]
  %7 = mul nuw nsw i64 %indvars.iv34, %5
  %invariant.gep = getelementptr inbounds double, ptr %2, i64 %7
  %invariant.gep39 = getelementptr inbounds double, ptr %2, i64 %indvars.iv34
  br i1 %6, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %.127.us = phi double [ %17, %.preheader.us.new ], [ %.029.us, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv
  %8 = load double, ptr %gep, align 8, !tbaa !5
  %9 = mul nuw nsw i64 %indvars.iv, %5
  %gep40 = getelementptr inbounds double, ptr %invariant.gep39, i64 %9
  %10 = load double, ptr %gep40, align 8, !tbaa !5
  %11 = fsub double %8, %10
  %square.us = fmul double %11, %11
  %12 = fadd double %.127.us, %square.us
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %gep.1 = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv.next
  %13 = load double, ptr %gep.1, align 8, !tbaa !5
  %14 = mul nuw nsw i64 %indvars.iv.next, %5
  %gep40.1 = getelementptr inbounds double, ptr %invariant.gep39, i64 %14
  %15 = load double, ptr %gep40.1, align 8, !tbaa !5
  %16 = fsub double %13, %15
  %square.us.1 = fmul double %16, %16
  %17 = fadd double %12, %square.us.1
  %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 %._crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !9

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %.lcssa.ph = phi double [ poison, %.preheader.us ], [ %17, %.preheader.us.new ]
  %indvars.iv.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next.1, %.preheader.us.new ]
  %.127.us.unr = phi double [ %.029.us, %.preheader.us ], [ %17, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %gep.epil = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv.unr
  %18 = load double, ptr %gep.epil, align 8, !tbaa !5
  %19 = mul nuw nsw i64 %indvars.iv.unr, %5
  %gep40.epil = getelementptr inbounds double, ptr %invariant.gep39, i64 %19
  %20 = load double, ptr %gep40.epil, align 8, !tbaa !5
  %21 = fsub double %18, %20
  %square.us.epil = fmul double %21, %21
  %22 = fadd double %.127.us.unr, %square.us.epil
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %.lcssa = phi double [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %22, %._crit_edge.us.epilog-lcssa ]
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %exitcond38.not = icmp eq i64 %indvars.iv.next35, %5
  br i1 %exitcond38.not, label %._crit_edge30, label %.preheader.us, !llvm.loop !11

._crit_edge30:                                    ; preds = %._crit_edge.us, %.preheader25
  %.0.lcssa = phi double [ 0.000000e+00, %.preheader25 ], [ %.lcssa, %._crit_edge.us ]
  %23 = tail call double @sqrt(double noundef %.0.lcssa) #2
  br label %24

24:                                               ; preds = %3, %._crit_edge30
  %.020 = phi double [ %23, %._crit_edge30 ], [ 0x7FEFFFFFFFFFFFFF, %3 ]
  ret double %.020
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 = { nofree nounwind memory(write, argmem: readwrite) 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 #2 = { 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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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