; LLVM IR from ekoontz/graphlab :: src/graphlab/extern/metis/libmetis/fortran.ll_libmetis (ChangeMesh2FNumbering2)

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

15:                                               ; preds = %25, %6
  %16 = load i64, ptr %13, align 8, !tbaa !5
  %17 = load i64, ptr %7, align 8, !tbaa !5
  %18 = icmp slt i64 %16, %17
  br i1 %18, label %19, label %28

19:                                               ; preds = %15
  %20 = load ptr, ptr %8, align 8, !tbaa !9
  %21 = load i64, ptr %13, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %20, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = add nsw i64 %23, 1
  store i64 %24, ptr %22, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %19
  %26 = load i64, ptr %13, align 8, !tbaa !5
  %27 = add nsw i64 %26, 1
  store i64 %27, ptr %13, align 8, !tbaa !5
  br label %15, !llvm.loop !11

28:                                               ; preds = %15
  store i64 0, ptr %13, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %39, %28
  %30 = load i64, ptr %13, align 8, !tbaa !5
  %31 = load i64, ptr %9, align 8, !tbaa !5
  %32 = icmp slt i64 %30, %31
  br i1 %32, label %33, label %42

33:                                               ; preds = %29
  %34 = load ptr, ptr %11, align 8, !tbaa !9
  %35 = load i64, ptr %13, align 8, !tbaa !5
  %36 = getelementptr inbounds i64, ptr %34, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %36, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %33
  %40 = load i64, ptr %13, align 8, !tbaa !5
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr %13, align 8, !tbaa !5
  br label %29, !llvm.loop !13

42:                                               ; preds = %29
  store i64 0, ptr %13, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %53, %42
  %44 = load i64, ptr %13, align 8, !tbaa !5
  %45 = load i64, ptr %10, align 8, !tbaa !5
  %46 = icmp slt i64 %44, %45
  br i1 %46, label %47, label %56

47:                                               ; preds = %43
  %48 = load ptr, ptr %12, align 8, !tbaa !9
  %49 = load i64, ptr %13, align 8, !tbaa !5
  %50 = getelementptr inbounds i64, ptr %48, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !5
  %52 = add nsw i64 %51, 1
  store i64 %52, ptr %50, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %47
  %54 = load i64, ptr %13, align 8, !tbaa !5
  %55 = add nsw i64 %54, 1
  store i64 %55, ptr %13, align 8, !tbaa !5
  br label %43, !llvm.loop !14

56:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, 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 = !{!"long", !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}


; 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__ChangeMesh2FNumbering2(i64 noundef %0, ptr nocapture noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef %4, ptr nocapture noundef %5) local_unnamed_addr #0 {
  %7 = icmp sgt i64 %0, 0
  br i1 %7, label %.lr.ph.preheader, label %.preheader14

.lr.ph.preheader:                                 ; preds = %6
  %min.iters.check = icmp ult i64 %0, 4
  br i1 %min.iters.check, label %.lr.ph.preheader51, label %vector.ph

.lr.ph.preheader51:                               ; preds = %middle.block, %.lr.ph.preheader
  %.015.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %0, 9223372036854775804
  br label %vector.body

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

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %0
  br i1 %cmp.n, label %.preheader14, label %.lr.ph.preheader51

.preheader14:                                     ; preds = %.lr.ph, %middle.block, %6
  %13 = icmp sgt i64 %2, 0
  br i1 %13, label %.lr.ph17.preheader, label %.preheader

.lr.ph17.preheader:                               ; preds = %.preheader14
  %min.iters.check25 = icmp ult i64 %2, 4
  br i1 %min.iters.check25, label %.lr.ph17.preheader50, label %vector.ph26

.lr.ph17.preheader50:                             ; preds = %middle.block23, %.lr.ph17.preheader
  %.116.ph = phi i64 [ 0, %.lr.ph17.preheader ], [ %n.vec28, %middle.block23 ]
  br label %.lr.ph17

vector.ph26:                                      ; preds = %.lr.ph17.preheader
  %n.vec28 = and i64 %2, 9223372036854775804
  br label %vector.body30

vector.body30:                                    ; preds = %vector.body30, %vector.ph26
  %index31 = phi i64 [ 0, %vector.ph26 ], [ %index.next34, %vector.body30 ]
  %14 = getelementptr inbounds i64, ptr %4, i64 %index31
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %wide.load32 = load <2 x i64>, ptr %14, align 8, !tbaa !5
  %wide.load33 = load <2 x i64>, ptr %15, align 8, !tbaa !5
  %16 = add nsw <2 x i64> %wide.load32, <i64 1, i64 1>
  %17 = add nsw <2 x i64> %wide.load33, <i64 1, i64 1>
  store <2 x i64> %16, ptr %14, align 8, !tbaa !5
  store <2 x i64> %17, ptr %15, align 8, !tbaa !5
  %index.next34 = add nuw i64 %index31, 4
  %18 = icmp eq i64 %index.next34, %n.vec28
  br i1 %18, label %middle.block23, label %vector.body30, !llvm.loop !13

middle.block23:                                   ; preds = %vector.body30
  %cmp.n35 = icmp eq i64 %n.vec28, %2
  br i1 %cmp.n35, label %.preheader, label %.lr.ph17.preheader50

.lr.ph:                                           ; preds = %.lr.ph.preheader51, %.lr.ph
  %.015 = phi i64 [ %22, %.lr.ph ], [ %.015.ph, %.lr.ph.preheader51 ]
  %19 = getelementptr inbounds i64, ptr %1, i64 %.015
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = add nsw i64 %20, 1
  store i64 %21, ptr %19, align 8, !tbaa !5
  %22 = add nuw nsw i64 %.015, 1
  %exitcond.not = icmp eq i64 %22, %0
  br i1 %exitcond.not, label %.preheader14, label %.lr.ph, !llvm.loop !14

.preheader:                                       ; preds = %.lr.ph17, %middle.block23, %.preheader14
  %23 = icmp sgt i64 %3, 0
  br i1 %23, label %.lr.ph19.preheader, label %._crit_edge

.lr.ph19.preheader:                               ; preds = %.preheader
  %min.iters.check38 = icmp ult i64 %3, 4
  br i1 %min.iters.check38, label %.lr.ph19.preheader49, label %vector.ph39

.lr.ph19.preheader49:                             ; preds = %middle.block36, %.lr.ph19.preheader
  %.218.ph = phi i64 [ 0, %.lr.ph19.preheader ], [ %n.vec41, %middle.block36 ]
  br label %.lr.ph19

vector.ph39:                                      ; preds = %.lr.ph19.preheader
  %n.vec41 = and i64 %3, 9223372036854775804
  br label %vector.body43

vector.body43:                                    ; preds = %vector.body43, %vector.ph39
  %index44 = phi i64 [ 0, %vector.ph39 ], [ %index.next47, %vector.body43 ]
  %24 = getelementptr inbounds i64, ptr %5, i64 %index44
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load45 = load <2 x i64>, ptr %24, align 8, !tbaa !5
  %wide.load46 = load <2 x i64>, ptr %25, align 8, !tbaa !5
  %26 = add nsw <2 x i64> %wide.load45, <i64 1, i64 1>
  %27 = add nsw <2 x i64> %wide.load46, <i64 1, i64 1>
  store <2 x i64> %26, ptr %24, align 8, !tbaa !5
  store <2 x i64> %27, ptr %25, align 8, !tbaa !5
  %index.next47 = add nuw i64 %index44, 4
  %28 = icmp eq i64 %index.next47, %n.vec41
  br i1 %28, label %middle.block36, label %vector.body43, !llvm.loop !15

middle.block36:                                   ; preds = %vector.body43
  %cmp.n48 = icmp eq i64 %n.vec41, %3
  br i1 %cmp.n48, label %._crit_edge, label %.lr.ph19.preheader49

.lr.ph17:                                         ; preds = %.lr.ph17.preheader50, %.lr.ph17
  %.116 = phi i64 [ %32, %.lr.ph17 ], [ %.116.ph, %.lr.ph17.preheader50 ]
  %29 = getelementptr inbounds i64, ptr %4, i64 %.116
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = add nsw i64 %30, 1
  store i64 %31, ptr %29, align 8, !tbaa !5
  %32 = add nuw nsw i64 %.116, 1
  %exitcond20.not = icmp eq i64 %32, %2
  br i1 %exitcond20.not, label %.preheader, label %.lr.ph17, !llvm.loop !16

.lr.ph19:                                         ; preds = %.lr.ph19.preheader49, %.lr.ph19
  %.218 = phi i64 [ %36, %.lr.ph19 ], [ %.218.ph, %.lr.ph19.preheader49 ]
  %33 = getelementptr inbounds i64, ptr %5, i64 %.218
  %34 = load i64, ptr %33, align 8, !tbaa !5
  %35 = add nsw i64 %34, 1
  store i64 %35, ptr %33, align 8, !tbaa !5
  %36 = add nuw nsw i64 %.218, 1
  %exitcond21.not = icmp eq i64 %36, %3
  br i1 %exitcond21.not, label %._crit_edge, label %.lr.ph19, !llvm.loop !17

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


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