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

; 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 i32 @run_tests(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @stable_tests() #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [1000 x i64], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8000, ptr %3) #3
  call void @srand48(i64 noundef 123) #3
  call void @stable_tests()
  %6 = getelementptr inbounds [1000 x i64], ptr %3, i64 0, i64 0
  call void @fill_random(ptr noundef %6, i32 noundef 1000)
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %23, %0
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 1000
  br i1 %9, label %10, label %26

10:                                               ; preds = %7
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [1000 x i64], ptr %3, i64 0, i64 %12
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = sitofp i64 %14 to double
  %16 = fdiv double %15, 0x41E0000000000000
  %17 = fmul double 1.601000e+03, %16
  %18 = fptosi double %17 to i64
  %19 = add nsw i64 0, %18
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [1000 x i64], ptr %3, i64 0, i64 %21
  store i64 %19, ptr %22, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %10
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %7, !llvm.loop !11

26:                                               ; preds = %7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %41, %26
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = icmp slt i32 %28, 8
  br i1 %29, label %30, label %44

30:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %31 = getelementptr inbounds [1000 x i64], ptr %3, i64 0, i64 0
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = call i32 @run_tests(ptr noundef %31, i32 noundef 1000, i32 noundef %32)
  store i32 %33, ptr %4, align 4, !tbaa !5
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  store i32 1, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %38

37:                                               ; preds = %30
  store i32 0, ptr %5, align 4
  br label %38

38:                                               ; preds = %37, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %39 = load i32, ptr %5, align 4
  switch i32 %39, label %45 [
    i32 0, label %40
  ]

40:                                               ; preds = %38
  br label %41

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

44:                                               ; preds = %27
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  br label %45

45:                                               ; preds = %44, %38
  call void @llvm.lifetime.end.p0(i64 8000, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %46 = load i32, ptr %1, align 4
  ret i32 %46
}

; Function Attrs: nounwind
declare void @srand48(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @fill_random(ptr noundef, i32 noundef) #1

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 "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 #3 = { 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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 i32 @run_tests(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @stable_tests() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main() local_unnamed_addr #1 {
  %1 = alloca [1000 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 8000, ptr nonnull %1) #3
  tail call void @srand48(i64 noundef 123) #3
  tail call void @stable_tests()
  call void @fill_random(ptr noundef nonnull %1, i32 noundef 1000)
  br label %2

2:                                                ; preds = %2, %0
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next.1, %2 ]
  %3 = getelementptr inbounds [1000 x i64], ptr %1, i64 0, i64 %indvars.iv
  %4 = load i64, ptr %3, align 16, !tbaa !5
  %5 = sitofp i64 %4 to double
  %6 = fmul double %5, 0x3E00000000000000
  %7 = fmul double %6, 1.601000e+03
  %8 = fptosi double %7 to i64
  store i64 %8, ptr %3, align 16, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = getelementptr inbounds [1000 x i64], ptr %1, i64 0, i64 %indvars.iv.next
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = sitofp i64 %10 to double
  %12 = fmul double %11, 0x3E00000000000000
  %13 = fmul double %12, 1.601000e+03
  %14 = fptosi double %13 to i64
  store i64 %14, ptr %9, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 1000
  br i1 %exitcond.not.1, label %.preheader.preheader, label %2, !llvm.loop !9

.preheader.preheader:                             ; preds = %2
  %15 = call i32 @run_tests(ptr noundef nonnull %1, i32 noundef 1000, i32 noundef 0)
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %.preheader.1, label %23

.preheader.1:                                     ; preds = %.preheader.preheader
  %16 = call i32 @run_tests(ptr noundef nonnull %1, i32 noundef 1000, i32 noundef 1)
  %.not.1 = icmp eq i32 %16, 0
  br i1 %.not.1, label %.preheader.2, label %23

.preheader.2:                                     ; preds = %.preheader.1
  %17 = call i32 @run_tests(ptr noundef nonnull %1, i32 noundef 1000, i32 noundef 2)
  %.not.2 = icmp eq i32 %17, 0
  br i1 %.not.2, label %.preheader.3, label %23

.preheader.3:                                     ; preds = %.preheader.2
  %18 = call i32 @run_tests(ptr noundef nonnull %1, i32 noundef 1000, i32 noundef 3)
  %.not.3 = icmp eq i32 %18, 0
  br i1 %.not.3, label %.preheader.4, label %23

.preheader.4:                                     ; preds = %.preheader.3
  %19 = call i32 @run_tests(ptr noundef nonnull %1, i32 noundef 1000, i32 noundef 4)
  %.not.4 = icmp eq i32 %19, 0
  br i1 %.not.4, label %.preheader.5, label %23

.preheader.5:                                     ; preds = %.preheader.4
  %20 = call i32 @run_tests(ptr noundef nonnull %1, i32 noundef 1000, i32 noundef 5)
  %.not.5 = icmp eq i32 %20, 0
  br i1 %.not.5, label %.preheader.6, label %23

.preheader.6:                                     ; preds = %.preheader.5
  %21 = call i32 @run_tests(ptr noundef nonnull %1, i32 noundef 1000, i32 noundef 6)
  %.not.6 = icmp eq i32 %21, 0
  br i1 %.not.6, label %.preheader.7, label %23

.preheader.7:                                     ; preds = %.preheader.6
  %22 = call i32 @run_tests(ptr noundef nonnull %1, i32 noundef 1000, i32 noundef 7)
  %.not.7 = icmp ne i32 %22, 0
  %spec.select = zext i1 %.not.7 to i32
  br label %23

23:                                               ; preds = %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %.2 = phi i32 [ 1, %.preheader.preheader ], [ 1, %.preheader.1 ], [ 1, %.preheader.2 ], [ 1, %.preheader.3 ], [ 1, %.preheader.4 ], [ 1, %.preheader.5 ], [ 1, %.preheader.6 ], [ %spec.select, %.preheader.7 ]
  call void @llvm.lifetime.end.p0(i64 8000, ptr nonnull %1) #3
  ret i32 %.2
}

; Function Attrs: nounwind
declare void @srand48(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @fill_random(ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 "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 #3 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass