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

15:                                               ; preds = %42, %6
  %16 = load i32, ptr %14, align 4, !tbaa !5
  %17 = load i32, ptr %8, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %45

19:                                               ; preds = %15
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %20

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

24:                                               ; preds = %20
  %25 = load ptr, ptr %9, align 8, !tbaa !9
  %26 = load i32, ptr %13, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = load ptr, ptr %11, align 8, !tbaa !9
  %31 = load i32, ptr %13, align 4, !tbaa !5
  %32 = load i32, ptr %14, align 4, !tbaa !5
  %33 = load i32, ptr %7, 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
  store double %29, ptr %37, align 8, !tbaa !11
  br label %38

38:                                               ; preds = %24
  %39 = load i32, ptr %13, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %13, align 4, !tbaa !5
  br label %20, !llvm.loop !13

41:                                               ; preds = %20
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %14, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %14, align 4, !tbaa !5
  br label %15, !llvm.loop !15

45:                                               ; preds = %15
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %73, %45
  %47 = load i32, ptr %14, align 4, !tbaa !5
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %50, label %76

50:                                               ; preds = %46
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %69, %50
  %52 = load i32, ptr %13, align 4, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %72

55:                                               ; preds = %51
  %56 = load ptr, ptr %10, align 8, !tbaa !9
  %57 = load i32, ptr %14, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = load ptr, ptr %12, align 8, !tbaa !9
  %62 = load i32, ptr %13, align 4, !tbaa !5
  %63 = load i32, ptr %14, align 4, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = mul nsw i32 %63, %64
  %66 = add nsw i32 %62, %65
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds double, ptr %61, i64 %67
  store double %60, ptr %68, align 8, !tbaa !11
  br label %69

69:                                               ; preds = %55
  %70 = load i32, ptr %13, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %13, align 4, !tbaa !5
  br label %51, !llvm.loop !16

72:                                               ; preds = %51
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %14, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %14, align 4, !tbaa !5
  br label %46, !llvm.loop !17

76:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  ret void
}

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}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @r8vec_mesh_2d(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = icmp sgt i32 %1, 0
  %8 = icmp sgt i32 %0, 0
  %or.cond = and i1 %7, %8
  br i1 %or.cond, label %.preheader29.us.preheader, label %._crit_edge34

.preheader29.us.preheader:                        ; preds = %6
  %9 = ptrtoint ptr %4 to i64
  %10 = ptrtoint ptr %2 to i64
  %11 = zext nneg i32 %0 to i64
  %wide.trip.count42 = zext nneg i32 %1 to i64
  %12 = sub i64 %9, %10
  %13 = shl nuw nsw i64 %11, 3
  %min.iters.check = icmp ult i32 %0, 4
  %n.vec = and i64 %11, 2147483644
  %cmp.n = icmp eq i64 %n.vec, %11
  %xtraiter = and i64 %11, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader29.us

.preheader29.us:                                  ; preds = %.preheader29.us.preheader, %._crit_edge.us
  %indvars.iv39 = phi i64 [ 0, %.preheader29.us.preheader ], [ %indvars.iv.next40, %._crit_edge.us ]
  %14 = mul nuw nsw i64 %indvars.iv39, %11
  %invariant.gep = getelementptr inbounds double, ptr %4, i64 %14
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.preheader29.us
  %15 = mul i64 %13, %indvars.iv39
  %16 = add i64 %12, %15
  %diff.check = icmp ult i64 %16, 32
  br i1 %diff.check, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.memcheck ]
  %17 = getelementptr inbounds double, ptr %2, i64 %index
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %wide.load = load <2 x double>, ptr %17, align 8, !tbaa !5
  %wide.load58 = load <2 x double>, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds double, ptr %invariant.gep, i64 %index
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  store <2 x double> %wide.load, ptr %19, align 8, !tbaa !5
  store <2 x double> %wide.load58, ptr %20, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %21 = icmp eq i64 %index.next, %n.vec
  br i1 %21, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.preheader29.us
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.preheader29.us ], [ %n.vec, %middle.block ]
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %scalar.ph.prol ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %22 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.prol
  %23 = load double, ptr %22, align 8, !tbaa !5
  %gep.prol = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv.prol
  store double %23, ptr %gep.prol, align 8, !tbaa !5
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !13

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %24 = sub nsw i64 %indvars.iv.ph, %11
  %25 = icmp ugt i64 %24, -4
  br i1 %25, label %._crit_edge.us, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %26 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  %27 = load double, ptr %26, align 8, !tbaa !5
  %gep = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv
  store double %27, ptr %gep, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next
  %29 = load double, ptr %28, align 8, !tbaa !5
  %gep.1 = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv.next
  store double %29, ptr %gep.1, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %30 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next.1
  %31 = load double, ptr %30, align 8, !tbaa !5
  %gep.2 = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv.next.1
  store double %31, ptr %gep.2, align 8, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %32 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next.2
  %33 = load double, ptr %32, align 8, !tbaa !5
  %gep.3 = getelementptr inbounds double, ptr %invariant.gep, i64 %indvars.iv.next.2
  store double %33, ptr %gep.3, align 8, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %11
  br i1 %exitcond.not.3, label %._crit_edge.us, label %scalar.ph, !llvm.loop !15

._crit_edge.us:                                   ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count42
  br i1 %exitcond43.not, label %.preheader28, label %.preheader29.us, !llvm.loop !16

.preheader28:                                     ; preds = %._crit_edge.us
  br i1 %7, label %.preheader.us.preheader, label %._crit_edge34

.preheader.us.preheader:                          ; preds = %.preheader28
  %34 = zext nneg i32 %0 to i64
  %wide.trip.count52 = zext nneg i32 %1 to i64
  %min.iters.check61 = icmp ult i32 %0, 4
  %n.vec64 = and i64 %11, 2147483644
  %cmp.n69 = icmp eq i64 %n.vec64, %11
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us35
  %indvars.iv49 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next50, %._crit_edge.us35 ]
  %35 = getelementptr inbounds double, ptr %3, i64 %indvars.iv49
  %36 = mul nuw nsw i64 %indvars.iv49, %34
  %.pre = load double, ptr %35, align 8, !tbaa !5
  %invariant.gep55 = getelementptr inbounds double, ptr %5, i64 %36
  br i1 %min.iters.check61, label %scalar.ph60.preheader, label %vector.ph62

vector.ph62:                                      ; preds = %.preheader.us
  %broadcast.splatinsert = insertelement <2 x double> poison, double %.pre, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  br label %vector.body66

vector.body66:                                    ; preds = %vector.body66, %vector.ph62
  %index67 = phi i64 [ 0, %vector.ph62 ], [ %index.next68, %vector.body66 ]
  %37 = getelementptr inbounds double, ptr %invariant.gep55, i64 %index67
  %38 = getelementptr inbounds i8, ptr %37, i64 16
  store <2 x double> %broadcast.splat, ptr %37, align 8, !tbaa !5
  store <2 x double> %broadcast.splat, ptr %38, align 8, !tbaa !5
  %index.next68 = add nuw i64 %index67, 4
  %39 = icmp eq i64 %index.next68, %n.vec64
  br i1 %39, label %middle.block59, label %vector.body66, !llvm.loop !17

middle.block59:                                   ; preds = %vector.body66
  br i1 %cmp.n69, label %._crit_edge.us35, label %scalar.ph60.preheader

scalar.ph60.preheader:                            ; preds = %middle.block59, %.preheader.us
  %indvars.iv44.ph = phi i64 [ 0, %.preheader.us ], [ %n.vec64, %middle.block59 ]
  br label %scalar.ph60

scalar.ph60:                                      ; preds = %scalar.ph60.preheader, %scalar.ph60
  %indvars.iv44 = phi i64 [ %indvars.iv.next45, %scalar.ph60 ], [ %indvars.iv44.ph, %scalar.ph60.preheader ]
  %gep56 = getelementptr inbounds double, ptr %invariant.gep55, i64 %indvars.iv44
  store double %.pre, ptr %gep56, align 8, !tbaa !5
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond48.not = icmp eq i64 %indvars.iv.next45, %34
  br i1 %exitcond48.not, label %._crit_edge.us35, label %scalar.ph60, !llvm.loop !18

._crit_edge.us35:                                 ; preds = %scalar.ph60, %middle.block59
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond53.not = icmp eq i64 %indvars.iv.next50, %wide.trip.count52
  br i1 %exitcond53.not, label %._crit_edge34, label %.preheader.us, !llvm.loop !19

._crit_edge34:                                    ; preds = %._crit_edge.us35, %6, %.preheader28
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(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" }

!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, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !10, !11}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !11, !12}
!18 = distinct !{!18, !10, !12, !11}
!19 = distinct !{!19, !10}


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