; 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.68 = external hidden unnamed_addr constant [21 x i8], align 1
@__const.test_stable_partition.numbers = external hidden unnamed_addr constant [6 x i32], align 16
@__PRETTY_FUNCTION__.test_stable_partition = external hidden unnamed_addr constant [33 x i8], align 1
@__const.test_stable_partition.expected = external hidden unnamed_addr constant [6 x i32], align 16
@.str.74 = external hidden unnamed_addr constant [26 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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; 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 @test_stable_partition() #2 {
  %1 = alloca [6 x i32], align 16
  %2 = alloca ptr, align 8
  %3 = alloca [6 x i32], align 16
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %1, ptr align 16 @__const.test_stable_partition.numbers, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %5 = getelementptr inbounds [6 x i32], ptr %1, i64 0, i64 0
  %6 = getelementptr inbounds [6 x i32], ptr %1, i64 0, i64 0
  %7 = getelementptr inbounds i32, ptr %6, i64 6
  %8 = call ptr @intv_stable_partition(ptr noundef %5, ptr noundef %7, ptr noundef @pred_is_even, ptr noundef null)
  store ptr %8, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds [6 x i32], ptr %1, i64 0, i64 0
  %11 = ptrtoint ptr %9 to i64
  %12 = ptrtoint ptr %10 to i64
  %13 = sub i64 %11, %12
  %14 = sdiv exact i64 %13, 4
  %15 = icmp eq i64 %14, 3
  br i1 %15, label %16, label %17

16:                                               ; preds = %0
  br label %18

17:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str.68, ptr noundef @.str.1, i32 noundef 414, ptr noundef @__PRETTY_FUNCTION__.test_stable_partition) #6
  unreachable

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const.test_stable_partition.expected, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %37, %18
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = icmp ult i64 %21, 6
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %40

24:                                               ; preds = %19
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [6 x i32], ptr %1, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [6 x i32], ptr %3, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = icmp eq i32 %28, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %24
  br label %36

35:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.74, ptr noundef @.str.1, i32 noundef 419, ptr noundef @__PRETTY_FUNCTION__.test_stable_partition) #6
  unreachable

36:                                               ; preds = %34
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %4, align 4, !tbaa !9
  br label %19, !llvm.loop !11

40:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %1) #5
  ret void
}

declare ptr @intv_stable_partition(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [21 x i8], align 1
@__const.test_stable_partition.numbers = external hidden unnamed_addr constant [6 x i32], align 16
@__PRETTY_FUNCTION__.test_stable_partition = external hidden unnamed_addr constant [33 x i8], align 1
@__const.test_stable_partition.expected = external hidden unnamed_addr constant [6 x i32], align 16
@.str.74 = external hidden unnamed_addr constant [26 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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; 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
define dso_local void @test_stable_partition() local_unnamed_addr #2 {
  %1 = alloca [6 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %1, ptr noundef nonnull align 16 dereferenceable(24) @__const.test_stable_partition.numbers, i64 24, i1 false)
  %2 = getelementptr inbounds i8, ptr %1, i64 24
  %3 = call ptr @intv_stable_partition(ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull @pred_is_even, ptr noundef null) #5
  %4 = ptrtoint ptr %3 to i64
  %5 = ptrtoint ptr %1 to i64
  %6 = sub i64 %4, %5
  %7 = icmp eq i64 %6, 12
  br i1 %7, label %.preheader.preheader, label %11

.preheader.preheader:                             ; preds = %0
  %8 = load i32, ptr %1, align 16, !tbaa !5
  %9 = load i32, ptr @__const.test_stable_partition.expected, align 16, !tbaa !5
  %10 = icmp eq i32 %8, %9
  br i1 %10, label %.preheader.1, label %33

11:                                               ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str.68, ptr noundef nonnull @.str.1, i32 noundef 414, ptr noundef nonnull @__PRETTY_FUNCTION__.test_stable_partition) #6
  unreachable

.preheader.1:                                     ; preds = %.preheader.preheader
  %12 = getelementptr inbounds i8, ptr %1, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_stable_partition.expected, i64 4), align 4, !tbaa !5
  %15 = icmp eq i32 %13, %14
  br i1 %15, label %.preheader.2, label %33

.preheader.2:                                     ; preds = %.preheader.1
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load i32, ptr %16, align 8, !tbaa !5
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_stable_partition.expected, i64 8), align 8, !tbaa !5
  %19 = icmp eq i32 %17, %18
  br i1 %19, label %.preheader.3, label %33

.preheader.3:                                     ; preds = %.preheader.2
  %20 = getelementptr inbounds i8, ptr %1, i64 12
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_stable_partition.expected, i64 12), align 4, !tbaa !5
  %23 = icmp eq i32 %21, %22
  br i1 %23, label %.preheader.4, label %33

.preheader.4:                                     ; preds = %.preheader.3
  %24 = getelementptr inbounds i8, ptr %1, i64 16
  %25 = load i32, ptr %24, align 16, !tbaa !5
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_stable_partition.expected, i64 16), align 16, !tbaa !5
  %27 = icmp eq i32 %25, %26
  br i1 %27, label %.preheader.5, label %33

.preheader.5:                                     ; preds = %.preheader.4
  %28 = getelementptr inbounds i8, ptr %1, i64 20
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_stable_partition.expected, i64 20), align 4, !tbaa !5
  %31 = icmp eq i32 %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %.preheader.5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #5
  ret void

33:                                               ; preds = %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  call void @__assert_fail(ptr noundef nonnull @.str.74, ptr noundef nonnull @.str.1, i32 noundef 419, ptr noundef nonnull @__PRETTY_FUNCTION__.test_stable_partition) #6
  unreachable
}

declare ptr @intv_stable_partition(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { "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"}


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