; LLVM IR from GGiecold-zz/Cluster_Ensembles :: src/Cluster_Ensembles/Hypergraph_Partitioning/metis-5.1.0/libmetis (fortran)

; 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 @libmetis__ChangeMesh2FNumbering(i32 noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !5
  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
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %29, %6
  %15 = load i32, ptr %13, align 4, !tbaa !5
  %16 = load ptr, ptr %8, align 8, !tbaa !9
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds i32, ptr %16, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = icmp slt i32 %15, %20
  br i1 %21, label %22, label %32

22:                                               ; preds = %14
  %23 = load ptr, ptr %9, align 8, !tbaa !9
  %24 = load i32, ptr %13, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i32, ptr %23, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %26, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %22
  %30 = load i32, ptr %13, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %13, align 4, !tbaa !5
  br label %14, !llvm.loop !11

32:                                               ; preds = %14
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %44, %32
  %34 = load i32, ptr %13, align 4, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = icmp sle i32 %34, %35
  br i1 %36, label %37, label %47

37:                                               ; preds = %33
  %38 = load ptr, ptr %8, align 8, !tbaa !9
  %39 = load i32, ptr %13, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %41, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %37
  %45 = load i32, ptr %13, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %13, align 4, !tbaa !5
  br label %33, !llvm.loop !13

47:                                               ; preds = %33
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %63, %47
  %49 = load i32, ptr %13, align 4, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !9
  %51 = load i32, ptr %10, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr %50, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = icmp slt i32 %49, %54
  br i1 %55, label %56, label %66

56:                                               ; preds = %48
  %57 = load ptr, ptr %12, align 8, !tbaa !9
  %58 = load i32, ptr %13, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr %57, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %60, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %56
  %64 = load i32, ptr %13, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %13, align 4, !tbaa !5
  br label %48, !llvm.loop !14

66:                                               ; preds = %48
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %78, %66
  %68 = load i32, ptr %13, align 4, !tbaa !5
  %69 = load i32, ptr %10, align 4, !tbaa !5
  %70 = icmp sle i32 %68, %69
  br i1 %70, label %71, label %81

71:                                               ; preds = %67
  %72 = load ptr, ptr %11, align 8, !tbaa !9
  %73 = load i32, ptr %13, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i32, ptr %72, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %75, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %71
  %79 = load i32, ptr %13, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %13, align 4, !tbaa !5
  br label %67, !llvm.loop !15

81:                                               ; preds = %67
  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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; 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 @libmetis__ChangeMesh2FNumbering(i32 noundef %0, ptr nocapture noundef %1, ptr nocapture noundef %2, i32 noundef %3, ptr nocapture noundef %4, ptr nocapture noundef %5) local_unnamed_addr #0 {
  %7 = sext i32 %0 to i64
  %8 = getelementptr inbounds i32, ptr %1, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.preheader23

.preheader23:                                     ; preds = %.lr.ph, %6
  %.not25 = icmp slt i32 %0, 0
  br i1 %.not25, label %.preheader22, label %.lr.ph27.preheader

.lr.ph27.preheader:                               ; preds = %.preheader23
  %11 = add nuw i32 %0, 1
  %wide.trip.count = zext i32 %11 to i64
  %min.iters.check = icmp ult i32 %0, 7
  br i1 %min.iters.check, label %.lr.ph27.preheader60, label %vector.ph

.lr.ph27.preheader60:                             ; preds = %middle.block, %.lr.ph27.preheader
  %indvars.iv34.ph = phi i64 [ 0, %.lr.ph27.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph27

vector.ph:                                        ; preds = %.lr.ph27.preheader
  %n.vec = and i64 %wide.trip.count, 4294967288
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %12 = getelementptr inbounds i32, ptr %1, i64 %index
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %wide.load = load <4 x i32>, ptr %12, align 4, !tbaa !5
  %wide.load45 = load <4 x i32>, ptr %13, align 4, !tbaa !5
  %14 = add nsw <4 x i32> %wide.load, <i32 1, i32 1, i32 1, i32 1>
  %15 = add nsw <4 x i32> %wide.load45, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %14, ptr %12, align 4, !tbaa !5
  store <4 x i32> %15, ptr %13, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %16 = icmp eq i64 %index.next, %n.vec
  br i1 %16, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.preheader22, label %.lr.ph27.preheader60

.lr.ph:                                           ; preds = %6, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %6 ]
  %17 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %17, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = icmp slt i64 %indvars.iv.next, %21
  br i1 %22, label %.lr.ph, label %.preheader23, !llvm.loop !13

.preheader22:                                     ; preds = %.lr.ph27, %middle.block, %.preheader23
  %23 = sext i32 %3 to i64
  %24 = getelementptr inbounds i32, ptr %4, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %.lr.ph29, label %.preheader

.lr.ph27:                                         ; preds = %.lr.ph27.preheader60, %.lr.ph27
  %indvars.iv34 = phi i64 [ %indvars.iv.next35, %.lr.ph27 ], [ %indvars.iv34.ph, %.lr.ph27.preheader60 ]
  %27 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv34
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %27, align 4, !tbaa !5
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next35, %wide.trip.count
  br i1 %exitcond.not, label %.preheader22, label %.lr.ph27, !llvm.loop !14

.preheader:                                       ; preds = %.lr.ph29, %.preheader22
  %.not2130 = icmp slt i32 %3, 0
  br i1 %.not2130, label %._crit_edge, label %.lr.ph32.preheader

.lr.ph32.preheader:                               ; preds = %.preheader
  %30 = add nuw i32 %3, 1
  %wide.trip.count43 = zext i32 %30 to i64
  %min.iters.check48 = icmp ult i32 %3, 7
  br i1 %min.iters.check48, label %.lr.ph32.preheader59, label %vector.ph49

.lr.ph32.preheader59:                             ; preds = %middle.block46, %.lr.ph32.preheader
  %indvars.iv40.ph = phi i64 [ 0, %.lr.ph32.preheader ], [ %n.vec51, %middle.block46 ]
  br label %.lr.ph32

vector.ph49:                                      ; preds = %.lr.ph32.preheader
  %n.vec51 = and i64 %wide.trip.count43, 4294967288
  br label %vector.body53

vector.body53:                                    ; preds = %vector.body53, %vector.ph49
  %index54 = phi i64 [ 0, %vector.ph49 ], [ %index.next57, %vector.body53 ]
  %31 = getelementptr inbounds i32, ptr %4, i64 %index54
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  %wide.load55 = load <4 x i32>, ptr %31, align 4, !tbaa !5
  %wide.load56 = load <4 x i32>, ptr %32, align 4, !tbaa !5
  %33 = add nsw <4 x i32> %wide.load55, <i32 1, i32 1, i32 1, i32 1>
  %34 = add nsw <4 x i32> %wide.load56, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %33, ptr %31, align 4, !tbaa !5
  store <4 x i32> %34, ptr %32, align 4, !tbaa !5
  %index.next57 = add nuw i64 %index54, 8
  %35 = icmp eq i64 %index.next57, %n.vec51
  br i1 %35, label %middle.block46, label %vector.body53, !llvm.loop !15

middle.block46:                                   ; preds = %vector.body53
  %cmp.n58 = icmp eq i64 %n.vec51, %wide.trip.count43
  br i1 %cmp.n58, label %._crit_edge, label %.lr.ph32.preheader59

.lr.ph29:                                         ; preds = %.preheader22, %.lr.ph29
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %.lr.ph29 ], [ 0, %.preheader22 ]
  %36 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv37
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %36, align 4, !tbaa !5
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %39 = load i32, ptr %24, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = icmp slt i64 %indvars.iv.next38, %40
  br i1 %41, label %.lr.ph29, label %.preheader, !llvm.loop !16

.lr.ph32:                                         ; preds = %.lr.ph32.preheader59, %.lr.ph32
  %indvars.iv40 = phi i64 [ %indvars.iv.next41, %.lr.ph32 ], [ %indvars.iv40.ph, %.lr.ph32.preheader59 ]
  %42 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv40
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %42, align 4, !tbaa !5
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %exitcond44.not = icmp eq i64 %indvars.iv.next41, %wide.trip.count43
  br i1 %exitcond44.not, label %._crit_edge, label %.lr.ph32, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph32, %middle.block46, %.preheader
  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 = !{!"int", !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, !10}
!14 = distinct !{!14, !10, !12, !11}
!15 = distinct !{!15, !10, !11, !12}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10, !12, !11}


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