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

15:                                               ; preds = %26, %6
  %16 = load i32, ptr %13, align 4, !tbaa !5
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %29

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

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

29:                                               ; preds = %15
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %41, %29
  %31 = load i32, ptr %13, align 4, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %44

34:                                               ; preds = %30
  %35 = load ptr, ptr %11, align 8, !tbaa !9
  %36 = load i32, ptr %13, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr %35, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %38, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %34
  %42 = load i32, ptr %13, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %13, align 4, !tbaa !5
  br label %30, !llvm.loop !13

44:                                               ; preds = %30
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %56, %44
  %46 = load i32, ptr %13, align 4, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !5
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %49, label %59

49:                                               ; preds = %45
  %50 = load ptr, ptr %12, align 8, !tbaa !9
  %51 = load i32, ptr %13, 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 = add nsw i32 %54, 1
  store i32 %55, ptr %53, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %49
  %57 = load i32, ptr %13, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %13, align 4, !tbaa !5
  br label %45, !llvm.loop !14

59:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  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}


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

.lr.ph.preheader:                                 ; preds = %6
  %wide.trip.count = zext nneg i32 %0 to i64
  %min.iters.check = icmp ult i32 %0, 8
  br i1 %min.iters.check, label %.lr.ph.preheader60, label %vector.ph

.lr.ph.preheader60:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.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 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %8 = getelementptr inbounds i32, ptr %1, i64 %index
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %wide.load = load <4 x i32>, ptr %8, align 4, !tbaa !5
  %wide.load31 = load <4 x i32>, ptr %9, align 4, !tbaa !5
  %10 = add nsw <4 x i32> %wide.load, <i32 1, i32 1, i32 1, i32 1>
  %11 = add nsw <4 x i32> %wide.load31, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %10, ptr %8, align 4, !tbaa !5
  store <4 x i32> %11, ptr %9, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %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, %wide.trip.count
  br i1 %cmp.n, label %.preheader14, label %.lr.ph.preheader60

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

.lr.ph17.preheader:                               ; preds = %.preheader14
  %wide.trip.count24 = zext nneg i32 %2 to i64
  %min.iters.check34 = icmp ult i32 %2, 8
  br i1 %min.iters.check34, label %.lr.ph17.preheader59, label %vector.ph35

.lr.ph17.preheader59:                             ; preds = %middle.block32, %.lr.ph17.preheader
  %indvars.iv21.ph = phi i64 [ 0, %.lr.ph17.preheader ], [ %n.vec37, %middle.block32 ]
  br label %.lr.ph17

vector.ph35:                                      ; preds = %.lr.ph17.preheader
  %n.vec37 = and i64 %wide.trip.count24, 2147483640
  br label %vector.body39

vector.body39:                                    ; preds = %vector.body39, %vector.ph35
  %index40 = phi i64 [ 0, %vector.ph35 ], [ %index.next43, %vector.body39 ]
  %14 = getelementptr inbounds i32, ptr %4, i64 %index40
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %wide.load41 = load <4 x i32>, ptr %14, align 4, !tbaa !5
  %wide.load42 = load <4 x i32>, ptr %15, align 4, !tbaa !5
  %16 = add nsw <4 x i32> %wide.load41, <i32 1, i32 1, i32 1, i32 1>
  %17 = add nsw <4 x i32> %wide.load42, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %16, ptr %14, align 4, !tbaa !5
  store <4 x i32> %17, ptr %15, align 4, !tbaa !5
  %index.next43 = add nuw i64 %index40, 8
  %18 = icmp eq i64 %index.next43, %n.vec37
  br i1 %18, label %middle.block32, label %vector.body39, !llvm.loop !13

middle.block32:                                   ; preds = %vector.body39
  %cmp.n44 = icmp eq i64 %n.vec37, %wide.trip.count24
  br i1 %cmp.n44, label %.preheader, label %.lr.ph17.preheader59

.lr.ph:                                           ; preds = %.lr.ph.preheader60, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader60 ]
  %19 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %19, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader14, label %.lr.ph, !llvm.loop !14

.preheader:                                       ; preds = %.lr.ph17, %middle.block32, %.preheader14
  %22 = icmp sgt i32 %3, 0
  br i1 %22, label %.lr.ph19.preheader, label %._crit_edge

.lr.ph19.preheader:                               ; preds = %.preheader
  %wide.trip.count29 = zext nneg i32 %3 to i64
  %min.iters.check47 = icmp ult i32 %3, 8
  br i1 %min.iters.check47, label %.lr.ph19.preheader58, label %vector.ph48

.lr.ph19.preheader58:                             ; preds = %middle.block45, %.lr.ph19.preheader
  %indvars.iv26.ph = phi i64 [ 0, %.lr.ph19.preheader ], [ %n.vec50, %middle.block45 ]
  br label %.lr.ph19

vector.ph48:                                      ; preds = %.lr.ph19.preheader
  %n.vec50 = and i64 %wide.trip.count29, 2147483640
  br label %vector.body52

vector.body52:                                    ; preds = %vector.body52, %vector.ph48
  %index53 = phi i64 [ 0, %vector.ph48 ], [ %index.next56, %vector.body52 ]
  %23 = getelementptr inbounds i32, ptr %5, i64 %index53
  %24 = getelementptr inbounds i8, ptr %23, i64 16
  %wide.load54 = load <4 x i32>, ptr %23, align 4, !tbaa !5
  %wide.load55 = load <4 x i32>, ptr %24, align 4, !tbaa !5
  %25 = add nsw <4 x i32> %wide.load54, <i32 1, i32 1, i32 1, i32 1>
  %26 = add nsw <4 x i32> %wide.load55, <i32 1, i32 1, i32 1, i32 1>
  store <4 x i32> %25, ptr %23, align 4, !tbaa !5
  store <4 x i32> %26, ptr %24, align 4, !tbaa !5
  %index.next56 = add nuw i64 %index53, 8
  %27 = icmp eq i64 %index.next56, %n.vec50
  br i1 %27, label %middle.block45, label %vector.body52, !llvm.loop !15

middle.block45:                                   ; preds = %vector.body52
  %cmp.n57 = icmp eq i64 %n.vec50, %wide.trip.count29
  br i1 %cmp.n57, label %._crit_edge, label %.lr.ph19.preheader58

.lr.ph17:                                         ; preds = %.lr.ph17.preheader59, %.lr.ph17
  %indvars.iv21 = phi i64 [ %indvars.iv.next22, %.lr.ph17 ], [ %indvars.iv21.ph, %.lr.ph17.preheader59 ]
  %28 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv21
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 4, !tbaa !5
  %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
  %exitcond25.not = icmp eq i64 %indvars.iv.next22, %wide.trip.count24
  br i1 %exitcond25.not, label %.preheader, label %.lr.ph17, !llvm.loop !16

.lr.ph19:                                         ; preds = %.lr.ph19.preheader58, %.lr.ph19
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %.lr.ph19 ], [ %indvars.iv26.ph, %.lr.ph19.preheader58 ]
  %31 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv26
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %31, align 4, !tbaa !5
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond30.not = icmp eq i64 %indvars.iv.next27, %wide.trip.count29
  br i1 %exitcond30.not, label %._crit_edge, label %.lr.ph19, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph19, %middle.block45, %.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, !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