; LLVM IR from siconos/siconos :: externals/sort/test (stresstest)

; 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"

@original = external hidden global ptr, align 8

; 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
declare dso_local i64 @find_next(ptr noundef, i64 noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @verify_stable(ptr noundef %0, i64 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %55, %3
  %13 = load i32, ptr %8, align 4, !tbaa !11
  %14 = load i32, ptr %7, align 4, !tbaa !11
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %58

16:                                               ; preds = %12
  br label %17

17:                                               ; preds = %49, %16
  br label %18

18:                                               ; preds = %17
  %19 = load ptr, ptr @original, align 8, !tbaa !5
  %20 = load i64, ptr %9, align 8, !tbaa !9
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = load i32, ptr %8, align 4, !tbaa !11
  %23 = call i64 @find_next(ptr noundef %19, i64 noundef %20, i64 noundef %21, i32 noundef %22)
  store i64 %23, ptr %9, align 8, !tbaa !9
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = icmp eq i64 %24, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %18
  br label %54

28:                                               ; preds = %18
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = load i32, ptr %8, align 4, !tbaa !11
  %33 = call i64 @find_next(ptr noundef %29, i64 noundef %30, i64 noundef %31, i32 noundef %32)
  store i64 %33, ptr %10, align 8, !tbaa !9
  %34 = load i64, ptr %10, align 8, !tbaa !9
  %35 = load i64, ptr %6, align 8, !tbaa !9
  %36 = icmp eq i64 %34, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %28
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %59

38:                                               ; preds = %28
  %39 = load ptr, ptr @original, align 8, !tbaa !5
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = getelementptr inbounds ptr, ptr %39, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i64, ptr %10, align 8, !tbaa !9
  %45 = getelementptr inbounds ptr, ptr %43, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = icmp ne ptr %42, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %38
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %59

49:                                               ; preds = %38
  %50 = load i64, ptr %9, align 8, !tbaa !9
  %51 = add nsw i64 %50, 1
  store i64 %51, ptr %9, align 8, !tbaa !9
  %52 = load i64, ptr %10, align 8, !tbaa !9
  %53 = add nsw i64 %52, 1
  store i64 %53, ptr %10, align 8, !tbaa !9
  br label %17

54:                                               ; preds = %27
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %8, align 4, !tbaa !11
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %8, align 4, !tbaa !11
  br label %12, !llvm.loop !13

58:                                               ; preds = %12
  store i32 1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %59

59:                                               ; preds = %58, %48, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %60 = load i32, ptr %4, align 4
  ret i32 %60
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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"

@original = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
declare dso_local i64 @find_next(ptr noundef, i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @verify_stable(ptr noundef %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp sgt i32 %2, 0
  br i1 %4, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %3, %._crit_edge
  %.034 = phi i64 [ %.1.lcssa, %._crit_edge ], [ 0, %3 ]
  %.01933 = phi i64 [ %1, %._crit_edge ], [ 0, %3 ]
  %.02132 = phi i32 [ %22, %._crit_edge ], [ 0, %3 ]
  %5 = load ptr, ptr @original, align 8, !tbaa !5
  %6 = tail call i64 @find_next(ptr noundef %5, i64 noundef %.01933, i64 noundef %1, i32 noundef %.02132)
  %7 = icmp eq i64 %6, %1
  br i1 %7, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %17
  %8 = phi i64 [ %20, %17 ], [ %6, %.preheader ]
  %.130 = phi i64 [ %19, %17 ], [ %.034, %.preheader ]
  %9 = tail call i64 @find_next(ptr noundef %0, i64 noundef %.130, i64 noundef %1, i32 noundef %.02132)
  %10 = icmp eq i64 %9, %1
  br i1 %10, label %.loopexit, label %11

11:                                               ; preds = %.lr.ph
  %12 = load ptr, ptr @original, align 8, !tbaa !5
  %13 = getelementptr inbounds ptr, ptr %12, i64 %8
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds ptr, ptr %0, i64 %9
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %.not = icmp eq ptr %14, %16
  br i1 %.not, label %17, label %.loopexit

17:                                               ; preds = %11
  %18 = add nsw i64 %8, 1
  %19 = add nsw i64 %9, 1
  %20 = tail call i64 @find_next(ptr noundef nonnull %12, i64 noundef %18, i64 noundef %1, i32 noundef %.02132)
  %21 = icmp eq i64 %20, %1
  br i1 %21, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %17, %.preheader
  %.1.lcssa = phi i64 [ %.034, %.preheader ], [ %19, %17 ]
  %22 = add nuw nsw i32 %.02132, 1
  %exitcond.not = icmp eq i32 %22, %2
  br i1 %exitcond.not, label %.loopexit, label %.preheader, !llvm.loop !9

.loopexit:                                        ; preds = %._crit_edge, %11, %.lr.ph, %3
  %.022 = phi i32 [ 1, %3 ], [ 0, %.lr.ph ], [ 0, %11 ], [ 1, %._crit_edge ]
  ret i32 %.022
}

attributes #0 = { 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" }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass