; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

12:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %69

13:                                               ; preds = %2
  %14 = call noalias ptr @malloc(i64 noundef 16) #4
  store ptr %14, ptr %6, align 8, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %64, %13
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 2
  br i1 %17, label %18, label %67

18:                                               ; preds = %15
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = add nsw i32 %20, 0
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds double, ptr %19, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !11
  %25 = load ptr, ptr %6, align 8, !tbaa !9
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  store double %24, ptr %28, align 8, !tbaa !11
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %60, %18
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %33, label %63

33:                                               ; preds = %29
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = mul nsw i32 %35, 2
  %37 = add nsw i32 0, %36
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds double, ptr %34, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %6, align 8, !tbaa !9
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds double, ptr %41, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = fcmp olt double %40, %45
  br i1 %46, label %47, label %59

47:                                               ; preds = %33
  %48 = load ptr, ptr %5, align 8, !tbaa !9
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = mul nsw i32 %49, 2
  %51 = add nsw i32 0, %50
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds double, ptr %48, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %55, i64 %57
  store double %54, ptr %58, align 8, !tbaa !11
  br label %59

59:                                               ; preds = %47, %33
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %8, align 4, !tbaa !5
  br label %29, !llvm.loop !13

63:                                               ; preds = %29
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %7, align 4, !tbaa !5
  br label %15, !llvm.loop !15

67:                                               ; preds = %15
  %68 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %68, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %69

69:                                               ; preds = %67, %12
  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
  %70 = load ptr, ptr %3, align 8
  ret ptr %70
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }
attributes #4 = { 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local noalias noundef ptr @r82row_min(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = icmp slt i32 %0, 1
  br i1 %3, label %.loopexit, label %4

4:                                                ; preds = %2
  %5 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #3
  %.not = icmp eq i32 %0, 1
  br i1 %.not, label %.split.preheader, label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %4
  %6 = load double, ptr %1, align 8, !tbaa !5
  %wide.trip.count = zext nneg i32 %0 to i64
  %7 = add nsw i64 %wide.trip.count, -1
  %8 = add nsw i64 %wide.trip.count, -2
  %xtraiter = and i64 %7, 1
  %9 = icmp eq i64 %8, 0
  br i1 %9, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.preheader.new

.lr.ph.us.preheader.new:                          ; preds = %.lr.ph.us.preheader
  %unroll_iter = and i64 %7, -2
  %invariant.gep = getelementptr i8, ptr %1, i64 16
  br label %10

.split.preheader:                                 ; preds = %4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 16, i1 false), !tbaa !5
  br label %.loopexit

10:                                               ; preds = %10, %.lr.ph.us.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.us.preheader.new ], [ %indvars.iv.next.139, %10 ]
  %11 = phi double [ %6, %.lr.ph.us.preheader.new ], [ %18, %10 ]
  %niter = phi i64 [ 0, %.lr.ph.us.preheader.new ], [ %niter.next.1, %10 ]
  %.idx = shl nsw i64 %indvars.iv, 4
  %12 = getelementptr inbounds i8, ptr %1, i64 %.idx
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fcmp olt double %13, %11
  %15 = select i1 %14, double %13, double %11
  %indvars.iv.next = shl i64 %indvars.iv, 4
  %gep = getelementptr i8, ptr %invariant.gep, i64 %indvars.iv.next
  %16 = load double, ptr %gep, align 8, !tbaa !5
  %17 = fcmp olt double %16, %15
  %18 = select i1 %17, double %16, double %15
  %indvars.iv.next.139 = 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.loopexit, label %10, !llvm.loop !9

._crit_edge.us.unr-lcssa.loopexit:                ; preds = %10
  %19 = shl nsw i64 %indvars.iv.next.139, 4
  br label %._crit_edge.us.unr-lcssa

._crit_edge.us.unr-lcssa:                         ; preds = %._crit_edge.us.unr-lcssa.loopexit, %.lr.ph.us.preheader
  %.lcssa36.ph = phi double [ poison, %.lr.ph.us.preheader ], [ %18, %._crit_edge.us.unr-lcssa.loopexit ]
  %indvars.iv.unr = phi i64 [ 16, %.lr.ph.us.preheader ], [ %19, %._crit_edge.us.unr-lcssa.loopexit ]
  %.unr = phi double [ %6, %.lr.ph.us.preheader ], [ %18, %._crit_edge.us.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  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
  %20 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv.unr
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = fcmp olt double %21, %.unr
  %23 = select i1 %22, double %21, double %.unr
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %.lcssa36 = phi double [ %.lcssa36.ph, %._crit_edge.us.unr-lcssa ], [ %23, %._crit_edge.us.epilog-lcssa ]
  store double %.lcssa36, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %1, i64 8
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %5, i64 8
  %xtraiter41 = and i64 %7, 1
  %27 = icmp eq i64 %8, 0
  br i1 %27, label %._crit_edge.us.1.unr-lcssa, label %._crit_edge.us.new

._crit_edge.us.new:                               ; preds = %._crit_edge.us
  %unroll_iter45 = and i64 %7, -2
  %invariant.gep49 = getelementptr i8, ptr %1, i64 16
  br label %28

28:                                               ; preds = %28, %._crit_edge.us.new
  %indvars.iv.1 = phi i64 [ 1, %._crit_edge.us.new ], [ %indvars.iv.next.1.1, %28 ]
  %29 = phi double [ %25, %._crit_edge.us.new ], [ %36, %28 ]
  %niter46 = phi i64 [ 0, %._crit_edge.us.new ], [ %niter46.next.1, %28 ]
  %.idx33 = shl nsw i64 %indvars.iv.1, 4
  %30 = getelementptr inbounds i8, ptr %1, i64 %.idx33
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = fcmp olt double %31, %29
  %33 = select i1 %32, double %31, double %29
  %indvars.iv.next.1 = shl i64 %indvars.iv.1, 4
  %gep50 = getelementptr i8, ptr %invariant.gep49, i64 %indvars.iv.next.1
  %34 = load double, ptr %gep50, align 8, !tbaa !5
  %35 = fcmp olt double %34, %33
  %36 = select i1 %35, double %34, double %33
  %indvars.iv.next.1.1 = add nuw nsw i64 %indvars.iv.1, 2
  %niter46.next.1 = add i64 %niter46, 2
  %niter46.ncmp.1 = icmp eq i64 %niter46.next.1, %unroll_iter45
  br i1 %niter46.ncmp.1, label %._crit_edge.us.1.unr-lcssa.loopexit, label %28, !llvm.loop !9

._crit_edge.us.1.unr-lcssa.loopexit:              ; preds = %28
  %37 = shl nsw i64 %indvars.iv.next.1.1, 4
  br label %._crit_edge.us.1.unr-lcssa

._crit_edge.us.1.unr-lcssa:                       ; preds = %._crit_edge.us.1.unr-lcssa.loopexit, %._crit_edge.us
  %.lcssa.ph = phi double [ poison, %._crit_edge.us ], [ %36, %._crit_edge.us.1.unr-lcssa.loopexit ]
  %indvars.iv.1.unr = phi i64 [ 16, %._crit_edge.us ], [ %37, %._crit_edge.us.1.unr-lcssa.loopexit ]
  %.unr42 = phi double [ %25, %._crit_edge.us ], [ %36, %._crit_edge.us.1.unr-lcssa.loopexit ]
  %lcmp.mod43.not = icmp eq i64 %xtraiter41, 0
  br i1 %lcmp.mod43.not, label %._crit_edge.us.1, label %._crit_edge.us.1.epilog-lcssa

._crit_edge.us.1.epilog-lcssa:                    ; preds = %._crit_edge.us.1.unr-lcssa
  %38 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv.1.unr
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = fcmp olt double %39, %.unr42
  %41 = select i1 %40, double %39, double %.unr42
  br label %._crit_edge.us.1

._crit_edge.us.1:                                 ; preds = %._crit_edge.us.1.unr-lcssa, %._crit_edge.us.1.epilog-lcssa
  %.lcssa = phi double [ %.lcssa.ph, %._crit_edge.us.1.unr-lcssa ], [ %41, %._crit_edge.us.1.epilog-lcssa ]
  store double %.lcssa, ptr %26, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge.us.1, %.split.preheader, %2
  %.020 = phi ptr [ null, %2 ], [ %5, %.split.preheader ], [ %5, %._crit_edge.us.1 ]
  ret ptr %.020
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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


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