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

; 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__Change2FNumberingOrder(i64 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, 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 ptr %2, ptr %8, align 8, !tbaa !9
  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 = %28, %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 %31

17:                                               ; preds = %13
  %18 = load ptr, ptr %9, 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
  %23 = load ptr, ptr %10, align 8, !tbaa !9
  %24 = load i64, ptr %11, align 8, !tbaa !5
  %25 = getelementptr inbounds i64, ptr %23, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = add nsw i64 %26, 1
  store i64 %27, ptr %25, align 8, !tbaa !5
  br label %28

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

31:                                               ; preds = %13
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load i64, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds i64, ptr %32, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !5
  store i64 %35, ptr %12, align 8, !tbaa !5
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %46, %31
  %37 = load i64, ptr %11, align 8, !tbaa !5
  %38 = load i64, ptr %12, align 8, !tbaa !5
  %39 = icmp slt i64 %37, %38
  br i1 %39, label %40, label %49

40:                                               ; preds = %36
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  %42 = load i64, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds i64, ptr %41, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !5
  %45 = add nsw i64 %44, 1
  store i64 %45, ptr %43, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %40
  %47 = load i64, ptr %11, align 8, !tbaa !5
  %48 = add nsw i64 %47, 1
  store i64 %48, ptr %11, align 8, !tbaa !5
  br label %36, !llvm.loop !13

49:                                               ; preds = %36
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %60, %49
  %51 = load i64, ptr %11, align 8, !tbaa !5
  %52 = load i64, ptr %6, align 8, !tbaa !5
  %53 = icmp sle i64 %51, %52
  br i1 %53, label %54, label %63

54:                                               ; preds = %50
  %55 = load ptr, ptr %7, align 8, !tbaa !9
  %56 = load i64, ptr %11, align 8, !tbaa !5
  %57 = getelementptr inbounds i64, ptr %55, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !5
  %59 = add nsw i64 %58, 1
  store i64 %59, ptr %57, align 8, !tbaa !5
  br label %60

60:                                               ; preds = %54
  %61 = load i64, ptr %11, align 8, !tbaa !5
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %11, align 8, !tbaa !5
  br label %50, !llvm.loop !14

63:                                               ; preds = %50
  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__Change2FNumberingOrder(i64 noundef %0, ptr nocapture noundef %1, ptr nocapture 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, 6
  br i1 %min.iters.check, label %.lr.ph.preheader61, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %7 = shl i64 %0, 3
  %scevgep = getelementptr i8, ptr %3, i64 %7
  %scevgep29 = getelementptr i8, ptr %4, i64 %7
  %bound0 = icmp ugt ptr %scevgep29, %3
  %bound1 = icmp ugt ptr %scevgep, %4
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph.preheader61, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %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 %3, i64 %index
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %wide.load = load <2 x i64>, ptr %8, align 8, !tbaa !5, !alias.scope !9, !noalias !12
  %wide.load30 = load <2 x i64>, ptr %9, align 8, !tbaa !5, !alias.scope !9, !noalias !12
  %10 = add nsw <2 x i64> %wide.load, <i64 1, i64 1>
  %11 = add nsw <2 x i64> %wide.load30, <i64 1, i64 1>
  store <2 x i64> %10, ptr %8, align 8, !tbaa !5, !alias.scope !9, !noalias !12
  store <2 x i64> %11, ptr %9, align 8, !tbaa !5, !alias.scope !9, !noalias !12
  %12 = getelementptr inbounds i64, ptr %4, i64 %index
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %wide.load31 = load <2 x i64>, ptr %12, align 8, !tbaa !5, !alias.scope !12
  %wide.load32 = load <2 x i64>, ptr %13, align 8, !tbaa !5, !alias.scope !12
  %14 = add nsw <2 x i64> %wide.load31, <i64 1, i64 1>
  %15 = add nsw <2 x i64> %wide.load32, <i64 1, i64 1>
  store <2 x i64> %14, ptr %12, align 8, !tbaa !5, !alias.scope !12
  store <2 x i64> %15, ptr %13, align 8, !tbaa !5, !alias.scope !12
  %index.next = add nuw i64 %index, 4
  %16 = icmp eq i64 %index.next, %n.vec
  br i1 %16, label %middle.block, label %vector.body, !llvm.loop !14

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

.lr.ph.preheader61:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %.019.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %0, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader61
  %17 = getelementptr inbounds i64, ptr %3, i64 %.019.ph
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = add nsw i64 %18, 1
  store i64 %19, ptr %17, align 8, !tbaa !5
  %20 = getelementptr inbounds i64, ptr %4, i64 %.019.ph
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = add nsw i64 %21, 1
  store i64 %22, ptr %20, align 8, !tbaa !5
  %23 = or disjoint i64 %.019.ph, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader61
  %.019.unr = phi i64 [ %.019.ph, %.lr.ph.preheader61 ], [ %23, %.lr.ph.prol ]
  %24 = add nsw i64 %0, -1
  %25 = icmp eq i64 %.019.ph, %24
  br i1 %25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.019 = phi i64 [ %39, %.lr.ph ], [ %.019.unr, %.lr.ph.prol.loopexit ]
  %26 = getelementptr inbounds i64, ptr %3, i64 %.019
  %27 = load i64, ptr %26, align 8, !tbaa !5
  %28 = add nsw i64 %27, 1
  store i64 %28, ptr %26, align 8, !tbaa !5
  %29 = getelementptr inbounds i64, ptr %4, i64 %.019
  %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 %.019, 1
  %33 = getelementptr inbounds i64, ptr %3, i64 %32
  %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 = getelementptr inbounds i64, ptr %4, i64 %32
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %36, align 8, !tbaa !5
  %39 = add nuw nsw i64 %.019, 2
  %exitcond.not.1 = icmp eq i64 %39, %0
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %5
  %40 = getelementptr inbounds i64, ptr %1, i64 %0
  %41 = load i64, ptr %40, align 8, !tbaa !5
  %42 = icmp sgt i64 %41, 0
  br i1 %42, label %.lr.ph22.preheader, label %.preheader

.lr.ph22.preheader:                               ; preds = %._crit_edge
  %min.iters.check35 = icmp ult i64 %41, 4
  br i1 %min.iters.check35, label %.lr.ph22.preheader60, label %vector.ph36

.lr.ph22.preheader60:                             ; preds = %middle.block33, %.lr.ph22.preheader
  %.120.ph = phi i64 [ 0, %.lr.ph22.preheader ], [ %n.vec38, %middle.block33 ]
  br label %.lr.ph22

vector.ph36:                                      ; preds = %.lr.ph22.preheader
  %n.vec38 = and i64 %41, 9223372036854775804
  br label %vector.body40

vector.body40:                                    ; preds = %vector.body40, %vector.ph36
  %index41 = phi i64 [ 0, %vector.ph36 ], [ %index.next44, %vector.body40 ]
  %43 = getelementptr inbounds i64, ptr %2, i64 %index41
  %44 = getelementptr inbounds i8, ptr %43, i64 16
  %wide.load42 = load <2 x i64>, ptr %43, align 8, !tbaa !5
  %wide.load43 = load <2 x i64>, ptr %44, align 8, !tbaa !5
  %45 = add nsw <2 x i64> %wide.load42, <i64 1, i64 1>
  %46 = add nsw <2 x i64> %wide.load43, <i64 1, i64 1>
  store <2 x i64> %45, ptr %43, align 8, !tbaa !5
  store <2 x i64> %46, ptr %44, align 8, !tbaa !5
  %index.next44 = add nuw i64 %index41, 4
  %47 = icmp eq i64 %index.next44, %n.vec38
  br i1 %47, label %middle.block33, label %vector.body40, !llvm.loop !19

middle.block33:                                   ; preds = %vector.body40
  %cmp.n45 = icmp eq i64 %41, %n.vec38
  br i1 %cmp.n45, label %.preheader, label %.lr.ph22.preheader60

.preheader:                                       ; preds = %.lr.ph22, %middle.block33, %._crit_edge
  %.not23 = icmp slt i64 %0, 0
  br i1 %.not23, label %._crit_edge26, label %.lr.ph25.preheader

.lr.ph25.preheader:                               ; preds = %.preheader
  %48 = add nuw i64 %0, 1
  %min.iters.check48 = icmp ult i64 %0, 3
  br i1 %min.iters.check48, label %.lr.ph25.preheader59, label %vector.ph49

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

vector.ph49:                                      ; preds = %.lr.ph25.preheader
  %n.vec51 = and i64 %48, -4
  br label %vector.body53

vector.body53:                                    ; preds = %vector.body53, %vector.ph49
  %index54 = phi i64 [ 0, %vector.ph49 ], [ %index.next57, %vector.body53 ]
  %49 = getelementptr inbounds i64, ptr %1, i64 %index54
  %50 = getelementptr inbounds i8, ptr %49, i64 16
  %wide.load55 = load <2 x i64>, ptr %49, align 8, !tbaa !5
  %wide.load56 = load <2 x i64>, ptr %50, align 8, !tbaa !5
  %51 = add nsw <2 x i64> %wide.load55, <i64 1, i64 1>
  %52 = add nsw <2 x i64> %wide.load56, <i64 1, i64 1>
  store <2 x i64> %51, ptr %49, align 8, !tbaa !5
  store <2 x i64> %52, ptr %50, align 8, !tbaa !5
  %index.next57 = add nuw i64 %index54, 4
  %53 = icmp eq i64 %index.next57, %n.vec51
  br i1 %53, label %middle.block46, label %vector.body53, !llvm.loop !20

middle.block46:                                   ; preds = %vector.body53
  %cmp.n58 = icmp eq i64 %48, %n.vec51
  br i1 %cmp.n58, label %._crit_edge26, label %.lr.ph25.preheader59

.lr.ph22:                                         ; preds = %.lr.ph22.preheader60, %.lr.ph22
  %.120 = phi i64 [ %57, %.lr.ph22 ], [ %.120.ph, %.lr.ph22.preheader60 ]
  %54 = getelementptr inbounds i64, ptr %2, i64 %.120
  %55 = load i64, ptr %54, align 8, !tbaa !5
  %56 = add nsw i64 %55, 1
  store i64 %56, ptr %54, align 8, !tbaa !5
  %57 = add nuw nsw i64 %.120, 1
  %exitcond27.not = icmp eq i64 %57, %41
  br i1 %exitcond27.not, label %.preheader, label %.lr.ph22, !llvm.loop !21

.lr.ph25:                                         ; preds = %.lr.ph25.preheader59, %.lr.ph25
  %.224 = phi i64 [ %61, %.lr.ph25 ], [ %.224.ph, %.lr.ph25.preheader59 ]
  %58 = getelementptr inbounds i64, ptr %1, i64 %.224
  %59 = load i64, ptr %58, align 8, !tbaa !5
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %58, align 8, !tbaa !5
  %61 = add nuw i64 %.224, 1
  %exitcond28.not = icmp eq i64 %.224, %0
  br i1 %exitcond28.not, label %._crit_edge26, label %.lr.ph25, !llvm.loop !22

._crit_edge26:                                    ; preds = %.lr.ph25, %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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = !{!13}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !15, !16, !17}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !15, !16}
!19 = distinct !{!19, !15, !16, !17}
!20 = distinct !{!20, !15, !16, !17}
!21 = distinct !{!21, !15, !17, !16}
!22 = distinct !{!22, !15, !17, !16}


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