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

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

11:                                               ; preds = %21, %4
  %12 = load i64, ptr %9, align 8, !tbaa !5
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = icmp slt i64 %12, %13
  br i1 %14, label %15, label %24

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

21:                                               ; preds = %15
  %22 = load i64, ptr %9, align 8, !tbaa !5
  %23 = add nsw i64 %22, 1
  store i64 %23, ptr %9, align 8, !tbaa !5
  br label %11, !llvm.loop !11

24:                                               ; preds = %11
  %25 = load ptr, ptr %6, align 8, !tbaa !9
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds i64, ptr %25, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !5
  store i64 %28, ptr %10, align 8, !tbaa !5
  store i64 0, ptr %9, align 8, !tbaa !5
  br label %29

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

33:                                               ; preds = %29
  %34 = load ptr, ptr %7, align 8, !tbaa !9
  %35 = load i64, ptr %9, 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 %9, align 8, !tbaa !5
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr %9, align 8, !tbaa !5
  br label %29, !llvm.loop !13

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

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

47:                                               ; preds = %43
  %48 = load ptr, ptr %6, align 8, !tbaa !9
  %49 = load i64, ptr %9, 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 %9, align 8, !tbaa !5
  %55 = add nsw i64 %54, 1
  store i64 %55, ptr %9, align 8, !tbaa !5
  br label %43, !llvm.loop !14

56:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #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__Change2FNumbering(i64 noundef %0, ptr nocapture noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3) local_unnamed_addr #0 {
  %5 = icmp sgt i64 %0, 0
  br i1 %5, label %.lr.ph.preheader, label %._crit_edge

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

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

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

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %4
  %15 = getelementptr inbounds i64, ptr %1, i64 %0
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = icmp sgt i64 %16, 0
  br i1 %17, label %.lr.ph20.preheader, label %.preheader

.lr.ph20.preheader:                               ; preds = %._crit_edge
  %min.iters.check30 = icmp ult i64 %16, 4
  br i1 %min.iters.check30, label %.lr.ph20.preheader55, label %vector.ph31

.lr.ph20.preheader55:                             ; preds = %middle.block28, %.lr.ph20.preheader
  %.118.ph = phi i64 [ 0, %.lr.ph20.preheader ], [ %n.vec33, %middle.block28 ]
  br label %.lr.ph20

vector.ph31:                                      ; preds = %.lr.ph20.preheader
  %n.vec33 = and i64 %16, 9223372036854775804
  br label %vector.body35

vector.body35:                                    ; preds = %vector.body35, %vector.ph31
  %index36 = phi i64 [ 0, %vector.ph31 ], [ %index.next39, %vector.body35 ]
  %18 = getelementptr inbounds i64, ptr %2, i64 %index36
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %wide.load37 = load <2 x i64>, ptr %18, align 8, !tbaa !5
  %wide.load38 = load <2 x i64>, ptr %19, align 8, !tbaa !5
  %20 = add nsw <2 x i64> %wide.load37, <i64 1, i64 1>
  %21 = add nsw <2 x i64> %wide.load38, <i64 1, i64 1>
  store <2 x i64> %20, ptr %18, align 8, !tbaa !5
  store <2 x i64> %21, ptr %19, align 8, !tbaa !5
  %index.next39 = add nuw i64 %index36, 4
  %22 = icmp eq i64 %index.next39, %n.vec33
  br i1 %22, label %middle.block28, label %vector.body35, !llvm.loop !14

middle.block28:                                   ; preds = %vector.body35
  %cmp.n40 = icmp eq i64 %16, %n.vec33
  br i1 %cmp.n40, label %.preheader, label %.lr.ph20.preheader55

.preheader:                                       ; preds = %.lr.ph20, %middle.block28, %._crit_edge
  %.not21 = icmp slt i64 %0, 0
  br i1 %.not21, label %._crit_edge24, label %.lr.ph23.preheader

.lr.ph23.preheader:                               ; preds = %.preheader
  %23 = add nuw i64 %0, 1
  %min.iters.check43 = icmp ult i64 %0, 3
  br i1 %min.iters.check43, label %.lr.ph23.preheader54, label %vector.ph44

.lr.ph23.preheader54:                             ; preds = %middle.block41, %.lr.ph23.preheader
  %.222.ph = phi i64 [ 0, %.lr.ph23.preheader ], [ %n.vec46, %middle.block41 ]
  br label %.lr.ph23

vector.ph44:                                      ; preds = %.lr.ph23.preheader
  %n.vec46 = and i64 %23, -4
  br label %vector.body48

vector.body48:                                    ; preds = %vector.body48, %vector.ph44
  %index49 = phi i64 [ 0, %vector.ph44 ], [ %index.next52, %vector.body48 ]
  %24 = getelementptr inbounds i64, ptr %1, i64 %index49
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load50 = load <2 x i64>, ptr %24, align 8, !tbaa !5
  %wide.load51 = load <2 x i64>, ptr %25, align 8, !tbaa !5
  %26 = add nsw <2 x i64> %wide.load50, <i64 1, i64 1>
  %27 = add nsw <2 x i64> %wide.load51, <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.next52 = add nuw i64 %index49, 4
  %28 = icmp eq i64 %index.next52, %n.vec46
  br i1 %28, label %middle.block41, label %vector.body48, !llvm.loop !15

middle.block41:                                   ; preds = %vector.body48
  %cmp.n53 = icmp eq i64 %23, %n.vec46
  br i1 %cmp.n53, label %._crit_edge24, label %.lr.ph23.preheader54

.lr.ph20:                                         ; preds = %.lr.ph20.preheader55, %.lr.ph20
  %.118 = phi i64 [ %32, %.lr.ph20 ], [ %.118.ph, %.lr.ph20.preheader55 ]
  %29 = getelementptr inbounds i64, ptr %2, i64 %.118
  %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 %.118, 1
  %exitcond25.not = icmp eq i64 %32, %16
  br i1 %exitcond25.not, label %.preheader, label %.lr.ph20, !llvm.loop !16

.lr.ph23:                                         ; preds = %.lr.ph23.preheader54, %.lr.ph23
  %.222 = phi i64 [ %36, %.lr.ph23 ], [ %.222.ph, %.lr.ph23.preheader54 ]
  %33 = getelementptr inbounds i64, ptr %1, i64 %.222
  %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 i64 %.222, 1
  %exitcond26.not = icmp eq i64 %.222, %0
  br i1 %exitcond26.not, label %._crit_edge24, label %.lr.ph23, !llvm.loop !17

._crit_edge24:                                    ; preds = %.lr.ph23, %middle.block41, %.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