; LLVM IR from clibraries/array-algorithms :: test (tests)

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

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.100 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.test_sort_partition = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @intv_all_of(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; 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 hidden i32 @compare_int(ptr noundef, ptr noundef, ptr noundef) #3

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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_sort_partition() #3 {
  %1 = alloca [20 x i32], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 80, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

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

9:                                                ; preds = %6
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %43

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %21, %10
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 20
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %24

15:                                               ; preds = %11
  %16 = call i32 @rand() #5
  %17 = srem i32 %16, 100
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [20 x i32], ptr %1, i64 0, i64 %19
  store i32 %17, ptr %20, align 4, !tbaa !5
  br label %21

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

24:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %25 = getelementptr inbounds [20 x i32], ptr %1, i64 0, i64 0
  %26 = getelementptr inbounds [20 x i32], ptr %1, i64 0, i64 0
  %27 = getelementptr inbounds i32, ptr %26, i64 20
  %28 = call ptr @intv_private__sort_partition(ptr noundef %25, ptr noundef %27, ptr noundef @compare_int, ptr noundef null)
  store ptr %28, ptr %5, align 8, !tbaa !11
  %29 = getelementptr inbounds [20 x i32], ptr %1, i64 0, i64 0
  %30 = load ptr, ptr %5, align 8, !tbaa !11
  %31 = load ptr, ptr %5, align 8, !tbaa !11
  %32 = call i32 @intv_all_of(ptr noundef %29, ptr noundef %30, ptr noundef @_is_less_equal_than, ptr noundef %31)
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %39, label %34

34:                                               ; preds = %24
  %35 = getelementptr inbounds [20 x i32], ptr %1, i64 0, i64 0
  call void @print_array(ptr noundef %35, i32 noundef 20)
  %36 = load ptr, ptr %5, align 8, !tbaa !11
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.99, i32 noundef %37)
  call void @__assert_fail(ptr noundef @.str.100, ptr noundef @.str.1, i32 noundef 573, ptr noundef @__PRETTY_FUNCTION__.test_sort_partition) #6
  unreachable

39:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %40

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

43:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 80, ptr %1) #5
  ret void
}

; Function Attrs: nounwind
declare i32 @rand() #4

; Function Attrs: nounwind uwtable
declare hidden ptr @intv_private__sort_partition(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @_is_less_equal_than(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { noreturn 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 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !10}


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

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.100 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.test_sort_partition = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @intv_all_of(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; 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 hidden i32 @compare_int(ptr noundef, ptr noundef, ptr noundef) #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @test_sort_partition() local_unnamed_addr #3 {
  %1 = alloca [20 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %1) #6
  %2 = getelementptr inbounds i8, ptr %1, i64 80
  %3 = getelementptr inbounds i8, ptr %1, i64 4
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = getelementptr inbounds i8, ptr %1, i64 12
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = getelementptr inbounds i8, ptr %1, i64 20
  %8 = getelementptr inbounds i8, ptr %1, i64 24
  %9 = getelementptr inbounds i8, ptr %1, i64 28
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  %11 = getelementptr inbounds i8, ptr %1, i64 36
  %12 = getelementptr inbounds i8, ptr %1, i64 40
  %13 = getelementptr inbounds i8, ptr %1, i64 44
  %14 = getelementptr inbounds i8, ptr %1, i64 48
  %15 = getelementptr inbounds i8, ptr %1, i64 52
  %16 = getelementptr inbounds i8, ptr %1, i64 56
  %17 = getelementptr inbounds i8, ptr %1, i64 60
  %18 = getelementptr inbounds i8, ptr %1, i64 64
  %19 = getelementptr inbounds i8, ptr %1, i64 68
  %20 = getelementptr inbounds i8, ptr %1, i64 72
  %21 = getelementptr inbounds i8, ptr %1, i64 76
  br label %.preheader

22:                                               ; preds = %.preheader
  %23 = add nuw nsw i32 %.09, 1
  %exitcond.not = icmp eq i32 %23, 100
  br i1 %exitcond.not, label %66, label %.preheader, !llvm.loop !5

.preheader:                                       ; preds = %0, %22
  %.09 = phi i32 [ 0, %0 ], [ %23, %22 ]
  %24 = call i32 @rand() #6
  %25 = srem i32 %24, 100
  store i32 %25, ptr %1, align 16, !tbaa !7
  %26 = call i32 @rand() #6
  %27 = srem i32 %26, 100
  store i32 %27, ptr %3, align 4, !tbaa !7
  %28 = call i32 @rand() #6
  %29 = srem i32 %28, 100
  store i32 %29, ptr %4, align 8, !tbaa !7
  %30 = call i32 @rand() #6
  %31 = srem i32 %30, 100
  store i32 %31, ptr %5, align 4, !tbaa !7
  %32 = call i32 @rand() #6
  %33 = srem i32 %32, 100
  store i32 %33, ptr %6, align 16, !tbaa !7
  %34 = call i32 @rand() #6
  %35 = srem i32 %34, 100
  store i32 %35, ptr %7, align 4, !tbaa !7
  %36 = call i32 @rand() #6
  %37 = srem i32 %36, 100
  store i32 %37, ptr %8, align 8, !tbaa !7
  %38 = call i32 @rand() #6
  %39 = srem i32 %38, 100
  store i32 %39, ptr %9, align 4, !tbaa !7
  %40 = call i32 @rand() #6
  %41 = srem i32 %40, 100
  store i32 %41, ptr %10, align 16, !tbaa !7
  %42 = call i32 @rand() #6
  %43 = srem i32 %42, 100
  store i32 %43, ptr %11, align 4, !tbaa !7
  %44 = call i32 @rand() #6
  %45 = srem i32 %44, 100
  store i32 %45, ptr %12, align 8, !tbaa !7
  %46 = call i32 @rand() #6
  %47 = srem i32 %46, 100
  store i32 %47, ptr %13, align 4, !tbaa !7
  %48 = call i32 @rand() #6
  %49 = srem i32 %48, 100
  store i32 %49, ptr %14, align 16, !tbaa !7
  %50 = call i32 @rand() #6
  %51 = srem i32 %50, 100
  store i32 %51, ptr %15, align 4, !tbaa !7
  %52 = call i32 @rand() #6
  %53 = srem i32 %52, 100
  store i32 %53, ptr %16, align 8, !tbaa !7
  %54 = call i32 @rand() #6
  %55 = srem i32 %54, 100
  store i32 %55, ptr %17, align 4, !tbaa !7
  %56 = call i32 @rand() #6
  %57 = srem i32 %56, 100
  store i32 %57, ptr %18, align 16, !tbaa !7
  %58 = call i32 @rand() #6
  %59 = srem i32 %58, 100
  store i32 %59, ptr %19, align 4, !tbaa !7
  %60 = call i32 @rand() #6
  %61 = srem i32 %60, 100
  store i32 %61, ptr %20, align 8, !tbaa !7
  %62 = call i32 @rand() #6
  %63 = srem i32 %62, 100
  store i32 %63, ptr %21, align 4, !tbaa !7
  %64 = call ptr @intv_private__sort_partition(ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull @compare_int, ptr noundef null)
  %65 = call i32 @intv_all_of(ptr noundef nonnull %1, ptr noundef %64, ptr noundef nonnull @_is_less_equal_than, ptr noundef %64) #6
  %.not = icmp eq i32 %65, 0
  br i1 %.not, label %67, label %22

66:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #6
  ret void

67:                                               ; preds = %.preheader
  call void @print_array(ptr noundef nonnull %1, i32 noundef 20)
  %68 = load i32, ptr %64, align 4, !tbaa !7
  %69 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.99, i32 noundef %68)
  call void @__assert_fail(ptr noundef nonnull @.str.100, ptr noundef nonnull @.str.1, i32 noundef 573, ptr noundef nonnull @__PRETTY_FUNCTION__.test_sort_partition) #7
  unreachable
}

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden ptr @intv_private__sort_partition(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @_is_less_equal_than(ptr noundef, ptr noundef) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { noreturn 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 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 #4 = { nofree 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass