; 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 uwtable
declare dso_local double @r8_max(double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local double @r8_min(double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @r8mat_maxcol_minrow(i32 noundef %0, i32 noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store double 0x7FEFFFFFFFFFFFFF, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store double 0xFFEFFFFFFFFFFFFF, ptr %11, align 8, !tbaa !11
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %40, %3
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %43

16:                                               ; preds = %12
  store double 0x7FEFFFFFFFFFFFFF, ptr %9, align 8, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %33, %16
  %18 = load i32, ptr %8, align 4, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %36

21:                                               ; preds = %17
  %22 = load double, ptr %9, align 8, !tbaa !11
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = mul nsw i32 %25, %26
  %28 = add nsw i32 %24, %27
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %23, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = call double @r8_min(double noundef %22, double noundef %31)
  store double %32, ptr %9, align 8, !tbaa !11
  br label %33

33:                                               ; preds = %21
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %8, align 4, !tbaa !5
  br label %17, !llvm.loop !13

36:                                               ; preds = %17
  %37 = load double, ptr %11, align 8, !tbaa !11
  %38 = load double, ptr %9, align 8, !tbaa !11
  %39 = call double @r8_max(double noundef %37, double noundef %38)
  store double %39, ptr %11, align 8, !tbaa !11
  br label %40

40:                                               ; preds = %36
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %7, align 4, !tbaa !5
  br label %12, !llvm.loop !15

43:                                               ; preds = %12
  %44 = load double, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret double %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = !{!"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: nounwind uwtable
declare dso_local double @r8_max(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @r8_min(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @r8mat_maxcol_minrow(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = icmp sgt i32 %0, 0
  br i1 %4, label %.preheader.lr.ph, label %._crit_edge21

.preheader.lr.ph:                                 ; preds = %3
  %5 = icmp sgt i32 %1, 0
  br i1 %5, label %.preheader.us.preheader, label %.preheader

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %6 = zext nneg i32 %0 to i64
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv28 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next29, %._crit_edge.us ]
  %.020.us = phi double [ 0xFFEFFFFFFFFFFFFF, %.preheader.us.preheader ], [ %11, %._crit_edge.us ]
  %invariant.gep = getelementptr inbounds double, ptr %2, i64 %indvars.iv28
  br label %7

7:                                                ; preds = %.preheader.us, %7
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %7 ]
  %.01418.us = phi double [ 0x7FEFFFFFFFFFFFFF, %.preheader.us ], [ %10, %7 ]
  %8 = mul nuw nsw i64 %indvars.iv, %6
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %8
  %9 = load double, ptr %gep, align 8, !tbaa !5
  %10 = tail call double @r8_min(double noundef %.01418.us, double noundef %9)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond27.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond27.not, label %._crit_edge.us, label %7, !llvm.loop !9

._crit_edge.us:                                   ; preds = %7
  %11 = tail call double @r8_max(double noundef %.020.us, double noundef %10)
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %exitcond32.not = icmp eq i64 %indvars.iv.next29, %6
  br i1 %exitcond32.not, label %._crit_edge21, label %.preheader.us, !llvm.loop !11

.preheader:                                       ; preds = %.preheader.lr.ph, %.preheader
  %.020 = phi double [ %12, %.preheader ], [ 0xFFEFFFFFFFFFFFFF, %.preheader.lr.ph ]
  %.01319 = phi i32 [ %13, %.preheader ], [ 0, %.preheader.lr.ph ]
  %12 = tail call double @r8_max(double noundef %.020, double noundef 0x7FEFFFFFFFFFFFFF)
  %13 = add nuw nsw i32 %.01319, 1
  %exitcond.not = icmp eq i32 %13, %0
  br i1 %exitcond.not, label %._crit_edge21, label %.preheader, !llvm.loop !11

._crit_edge21:                                    ; preds = %.preheader, %._crit_edge.us, %3
  %.0.lcssa = phi double [ 0xFFEFFFFFFFFFFFFF, %3 ], [ %11, %._crit_edge.us ], [ %12, %.preheader ]
  ret double %.0.lcssa
}

attributes #0 = { 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, !10}


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