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

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

13:                                               ; preds = %23, %5
  %14 = load i64, ptr %11, align 8, !tbaa !5
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = icmp slt i64 %14, %15
  br i1 %16, label %17, label %26

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

23:                                               ; preds = %17
  %24 = load i64, ptr %11, align 8, !tbaa !5
  %25 = add nsw i64 %24, 1
  store i64 %25, ptr %11, align 8, !tbaa !5
  br label %13, !llvm.loop !11

26:                                               ; preds = %13
  %27 = load ptr, ptr %9, align 8, !tbaa !9
  %28 = load i64, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds i64, ptr %27, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !5
  store i64 %30, ptr %12, align 8, !tbaa !5
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %41, %26
  %32 = load i64, ptr %11, align 8, !tbaa !5
  %33 = load i64, ptr %12, align 8, !tbaa !5
  %34 = icmp slt i64 %32, %33
  br i1 %34, label %35, label %44

35:                                               ; preds = %31
  %36 = load ptr, ptr %10, align 8, !tbaa !9
  %37 = load i64, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds i64, ptr %36, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !5
  %40 = add nsw i64 %39, 1
  store i64 %40, ptr %38, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %35
  %42 = load i64, ptr %11, align 8, !tbaa !5
  %43 = add nsw i64 %42, 1
  store i64 %43, ptr %11, align 8, !tbaa !5
  br label %31, !llvm.loop !13

44:                                               ; preds = %31
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %55, %44
  %46 = load i64, ptr %11, align 8, !tbaa !5
  %47 = load i64, ptr %8, align 8, !tbaa !5
  %48 = icmp sle i64 %46, %47
  br i1 %48, label %49, label %58

49:                                               ; preds = %45
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = load i64, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds i64, ptr %50, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !5
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %52, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %49
  %56 = load i64, ptr %11, align 8, !tbaa !5
  %57 = add nsw i64 %56, 1
  store i64 %57, ptr %11, align 8, !tbaa !5
  br label %45, !llvm.loop !14

58:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #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__ChangeMesh2FNumbering(i64 noundef %0, ptr nocapture noundef %1, i64 noundef %2, ptr nocapture noundef %3, ptr nocapture noundef %4) local_unnamed_addr #0 {
  %6 = icmp sgt i64 %0, 0
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %5
  %min.iters.check = icmp ult i64 %0, 4
  br i1 %min.iters.check, label %.lr.ph.preheader55, label %vector.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 ]
  %7 = getelementptr inbounds i64, ptr %1, i64 %index
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %wide.load = load <2 x i64>, ptr %7, align 8, !tbaa !5
  %wide.load26 = load <2 x i64>, ptr %8, align 8, !tbaa !5
  %9 = add nsw <2 x i64> %wide.load, <i64 1, i64 1>
  %10 = add nsw <2 x i64> %wide.load26, <i64 1, i64 1>
  store <2 x i64> %9, ptr %7, align 8, !tbaa !5
  store <2 x i64> %10, ptr %8, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %11 = icmp eq i64 %index.next, %n.vec
  br i1 %11, 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 %._crit_edge, label %.lr.ph.preheader55

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

.lr.ph:                                           ; preds = %.lr.ph.preheader55, %.lr.ph
  %.016 = phi i64 [ %15, %.lr.ph ], [ %.016.ph, %.lr.ph.preheader55 ]
  %12 = getelementptr inbounds i64, ptr %1, i64 %.016
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = add nsw i64 %13, 1
  store i64 %14, ptr %12, align 8, !tbaa !5
  %15 = add nuw nsw i64 %.016, 1
  %exitcond.not = icmp eq i64 %15, %0
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %5
  %16 = getelementptr inbounds i64, ptr %3, i64 %2
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = icmp sgt i64 %17, 0
  br i1 %18, label %.lr.ph19.preheader, label %.preheader

.lr.ph19.preheader:                               ; preds = %._crit_edge
  %min.iters.check29 = icmp ult i64 %17, 4
  br i1 %min.iters.check29, label %.lr.ph19.preheader54, label %vector.ph30

.lr.ph19.preheader54:                             ; preds = %middle.block27, %.lr.ph19.preheader
  %.117.ph = phi i64 [ 0, %.lr.ph19.preheader ], [ %n.vec32, %middle.block27 ]
  br label %.lr.ph19

vector.ph30:                                      ; preds = %.lr.ph19.preheader
  %n.vec32 = and i64 %17, 9223372036854775804
  br label %vector.body34

vector.body34:                                    ; preds = %vector.body34, %vector.ph30
  %index35 = phi i64 [ 0, %vector.ph30 ], [ %index.next38, %vector.body34 ]
  %19 = getelementptr inbounds i64, ptr %4, i64 %index35
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %wide.load36 = load <2 x i64>, ptr %19, align 8, !tbaa !5
  %wide.load37 = load <2 x i64>, ptr %20, align 8, !tbaa !5
  %21 = add nsw <2 x i64> %wide.load36, <i64 1, i64 1>
  %22 = add nsw <2 x i64> %wide.load37, <i64 1, i64 1>
  store <2 x i64> %21, ptr %19, align 8, !tbaa !5
  store <2 x i64> %22, ptr %20, align 8, !tbaa !5
  %index.next38 = add nuw i64 %index35, 4
  %23 = icmp eq i64 %index.next38, %n.vec32
  br i1 %23, label %middle.block27, label %vector.body34, !llvm.loop !14

middle.block27:                                   ; preds = %vector.body34
  %cmp.n39 = icmp eq i64 %17, %n.vec32
  br i1 %cmp.n39, label %.preheader, label %.lr.ph19.preheader54

.preheader:                                       ; preds = %.lr.ph19, %middle.block27, %._crit_edge
  %.not20 = icmp slt i64 %2, 0
  br i1 %.not20, label %._crit_edge23, label %.lr.ph22.preheader

.lr.ph22.preheader:                               ; preds = %.preheader
  %24 = add nuw i64 %2, 1
  %min.iters.check42 = icmp ult i64 %2, 3
  br i1 %min.iters.check42, label %.lr.ph22.preheader53, label %vector.ph43

.lr.ph22.preheader53:                             ; preds = %middle.block40, %.lr.ph22.preheader
  %.221.ph = phi i64 [ 0, %.lr.ph22.preheader ], [ %n.vec45, %middle.block40 ]
  br label %.lr.ph22

vector.ph43:                                      ; preds = %.lr.ph22.preheader
  %n.vec45 = and i64 %24, -4
  br label %vector.body47

vector.body47:                                    ; preds = %vector.body47, %vector.ph43
  %index48 = phi i64 [ 0, %vector.ph43 ], [ %index.next51, %vector.body47 ]
  %25 = getelementptr inbounds i64, ptr %3, i64 %index48
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %wide.load49 = load <2 x i64>, ptr %25, align 8, !tbaa !5
  %wide.load50 = load <2 x i64>, ptr %26, align 8, !tbaa !5
  %27 = add nsw <2 x i64> %wide.load49, <i64 1, i64 1>
  %28 = add nsw <2 x i64> %wide.load50, <i64 1, i64 1>
  store <2 x i64> %27, ptr %25, align 8, !tbaa !5
  store <2 x i64> %28, ptr %26, align 8, !tbaa !5
  %index.next51 = add nuw i64 %index48, 4
  %29 = icmp eq i64 %index.next51, %n.vec45
  br i1 %29, label %middle.block40, label %vector.body47, !llvm.loop !15

middle.block40:                                   ; preds = %vector.body47
  %cmp.n52 = icmp eq i64 %24, %n.vec45
  br i1 %cmp.n52, label %._crit_edge23, label %.lr.ph22.preheader53

.lr.ph19:                                         ; preds = %.lr.ph19.preheader54, %.lr.ph19
  %.117 = phi i64 [ %33, %.lr.ph19 ], [ %.117.ph, %.lr.ph19.preheader54 ]
  %30 = getelementptr inbounds i64, ptr %4, i64 %.117
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = add nsw i64 %31, 1
  store i64 %32, ptr %30, align 8, !tbaa !5
  %33 = add nuw nsw i64 %.117, 1
  %exitcond24.not = icmp eq i64 %33, %17
  br i1 %exitcond24.not, label %.preheader, label %.lr.ph19, !llvm.loop !16

.lr.ph22:                                         ; preds = %.lr.ph22.preheader53, %.lr.ph22
  %.221 = phi i64 [ %37, %.lr.ph22 ], [ %.221.ph, %.lr.ph22.preheader53 ]
  %34 = getelementptr inbounds i64, ptr %3, i64 %.221
  %35 = load i64, ptr %34, align 8, !tbaa !5
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %34, align 8, !tbaa !5
  %37 = add nuw i64 %.221, 1
  %exitcond25.not = icmp eq i64 %.221, %2
  br i1 %exitcond25.not, label %._crit_edge23, label %.lr.ph22, !llvm.loop !17

._crit_edge23:                                    ; preds = %.lr.ph22, %middle.block40, %.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, !12, !11}
!14 = distinct !{!14, !10, !11, !12}
!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