; 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
@__const.test_minmax.nums = external hidden unnamed_addr constant [2 x i32], align 4
@.str.51 = external hidden unnamed_addr constant [54 x i8], align 1
@__PRETTY_FUNCTION__.test_minmax = external hidden unnamed_addr constant [23 x i8], align 1
@.str.52 = external hidden unnamed_addr constant [54 x i8], align 1
@__const.test_minmax.nums.53 = external hidden unnamed_addr constant [2 x i32], align 4
@.str.54 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [60 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: 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
define dso_local void @test_minmax() #3 {
  %1 = alloca [2 x i32], align 4
  %2 = alloca [2 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %1, ptr align 4 @__const.test_minmax.nums, i64 8, i1 false)
  %3 = getelementptr inbounds [2 x i32], ptr %1, i64 0, i64 0
  %4 = getelementptr inbounds i32, ptr %3, i64 0
  %5 = getelementptr inbounds [2 x i32], ptr %1, i64 0, i64 0
  %6 = getelementptr inbounds i32, ptr %5, i64 1
  %7 = call ptr @intv_min(ptr noundef %4, ptr noundef %6, ptr noundef @compare_int, ptr noundef null)
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp eq i32 %8, 1
  br i1 %9, label %10, label %11

10:                                               ; preds = %0
  br label %12

11:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str.51, ptr noundef @.str.1, i32 noundef 335, ptr noundef @__PRETTY_FUNCTION__.test_minmax) #6
  unreachable

12:                                               ; preds = %10
  %13 = getelementptr inbounds [2 x i32], ptr %1, i64 0, i64 0
  %14 = getelementptr inbounds i32, ptr %13, i64 0
  %15 = getelementptr inbounds [2 x i32], ptr %1, i64 0, i64 0
  %16 = getelementptr inbounds i32, ptr %15, i64 1
  %17 = call ptr @intv_max(ptr noundef %14, ptr noundef %16, ptr noundef @compare_int, ptr noundef null)
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = icmp eq i32 %18, 2
  br i1 %19, label %20, label %21

20:                                               ; preds = %12
  br label %22

21:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.52, ptr noundef @.str.1, i32 noundef 336, ptr noundef @__PRETTY_FUNCTION__.test_minmax) #6
  unreachable

22:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 @__const.test_minmax.nums.53, i64 8, i1 false)
  %23 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 0
  %24 = getelementptr inbounds i32, ptr %23, i64 0
  %25 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 0
  %26 = getelementptr inbounds i32, ptr %25, i64 1
  %27 = call ptr @intv_min(ptr noundef %24, ptr noundef %26, ptr noundef @compare_int, ptr noundef null)
  %28 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 0
  %29 = getelementptr inbounds i32, ptr %28, i64 0
  %30 = icmp eq ptr %27, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %22
  br label %33

32:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.54, ptr noundef @.str.1, i32 noundef 340, ptr noundef @__PRETTY_FUNCTION__.test_minmax) #6
  unreachable

33:                                               ; preds = %31
  %34 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 0
  %35 = getelementptr inbounds i32, ptr %34, i64 0
  %36 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 0
  %37 = getelementptr inbounds i32, ptr %36, i64 1
  %38 = call ptr @intv_max(ptr noundef %35, ptr noundef %37, ptr noundef @compare_int, ptr noundef null)
  %39 = getelementptr inbounds [2 x i32], ptr %2, i64 0, i64 0
  %40 = getelementptr inbounds i32, ptr %39, i64 1
  %41 = icmp eq ptr %38, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %33
  br label %44

43:                                               ; preds = %33
  call void @__assert_fail(ptr noundef @.str.55, ptr noundef @.str.1, i32 noundef 341, ptr noundef @__PRETTY_FUNCTION__.test_minmax) #6
  unreachable

44:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  ret void
}

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

declare ptr @intv_max(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 = { 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 = { "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"}


; 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
@__const.test_minmax.nums = external hidden unnamed_addr constant [2 x i32], align 4
@.str.51 = external hidden unnamed_addr constant [54 x i8], align 1
@__PRETTY_FUNCTION__.test_minmax = external hidden unnamed_addr constant [23 x i8], align 1
@.str.52 = external hidden unnamed_addr constant [54 x i8], align 1
@__const.test_minmax.nums.53 = external hidden unnamed_addr constant [2 x i32], align 4
@.str.54 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [60 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local void @test_minmax() local_unnamed_addr #2 {
  %1 = alloca [2 x i32], align 8
  %2 = alloca [2 x i32], align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %3 = load i64, ptr @__const.test_minmax.nums, align 4
  store i64 %3, ptr %1, align 8
  %4 = getelementptr inbounds i8, ptr %1, i64 4
  %5 = call ptr @intv_min(ptr noundef nonnull %1, ptr noundef nonnull %4, ptr noundef nonnull @compare_int, ptr noundef null) #4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %9, label %8

8:                                                ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str.51, ptr noundef nonnull @.str.1, i32 noundef 335, ptr noundef nonnull @__PRETTY_FUNCTION__.test_minmax) #5
  unreachable

9:                                                ; preds = %0
  %10 = call ptr @intv_max(ptr noundef nonnull %1, ptr noundef nonnull %4, ptr noundef nonnull @compare_int, ptr noundef null) #4
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 2
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @__assert_fail(ptr noundef nonnull @.str.52, ptr noundef nonnull @.str.1, i32 noundef 336, ptr noundef nonnull @__PRETTY_FUNCTION__.test_minmax) #5
  unreachable

14:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %15 = load i64, ptr @__const.test_minmax.nums.53, align 4
  store i64 %15, ptr %2, align 8
  %16 = getelementptr inbounds i8, ptr %2, i64 4
  %17 = call ptr @intv_min(ptr noundef nonnull %2, ptr noundef nonnull %16, ptr noundef nonnull @compare_int, ptr noundef null) #4
  %18 = icmp eq ptr %17, %2
  br i1 %18, label %20, label %19

19:                                               ; preds = %14
  call void @__assert_fail(ptr noundef nonnull @.str.54, ptr noundef nonnull @.str.1, i32 noundef 340, ptr noundef nonnull @__PRETTY_FUNCTION__.test_minmax) #5
  unreachable

20:                                               ; preds = %14
  %21 = call ptr @intv_max(ptr noundef nonnull %2, ptr noundef nonnull %16, ptr noundef nonnull @compare_int, ptr noundef null) #4
  %22 = icmp eq ptr %21, %16
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  call void @__assert_fail(ptr noundef nonnull @.str.55, ptr noundef nonnull @.str.1, i32 noundef 341, ptr noundef nonnull @__PRETTY_FUNCTION__.test_minmax) #5
  unreachable

24:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret void
}

declare ptr @intv_min(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @intv_max(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 }
attributes #5 = { 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,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SimplifyCFGPass