; 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_fill.nums = external hidden unnamed_addr constant [5 x i32], align 16
@.str.40 = external hidden unnamed_addr constant [13 x i8], align 1
@__PRETTY_FUNCTION__.test_fill = external hidden unnamed_addr constant [21 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [15 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
define dso_local void @test_fill() #3 {
  %1 = alloca [5 x i32], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 20, ptr %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %1, ptr align 16 @__const.test_fill.nums, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 2, ptr %2, align 4, !tbaa !5
  %6 = getelementptr inbounds [5 x i32], ptr %1, i64 0, i64 0
  %7 = getelementptr inbounds [5 x i32], ptr %1, i64 0, i64 0
  %8 = getelementptr inbounds i32, ptr %7, i64 5
  %9 = call ptr @intv_fill(ptr noundef %6, ptr noundef %8, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %10

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

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %26

14:                                               ; preds = %10
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [5 x i32], ptr %1, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = icmp eq i32 %18, 2
  br i1 %19, label %20, label %21

20:                                               ; preds = %14
  br label %22

21:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.40, ptr noundef @.str.1, i32 noundef 247, ptr noundef @__PRETTY_FUNCTION__.test_fill) #6
  unreachable

22:                                               ; preds = %20
  br label %23

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

26:                                               ; preds = %13
  store i32 -5, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %27 = getelementptr inbounds [5 x i32], ptr %1, i64 0, i64 0
  %28 = call ptr @intv_fill_n(ptr noundef %27, i64 noundef 3, ptr noundef %2)
  store ptr %28, ptr %4, align 8, !tbaa !11
  store i32 -10, ptr %2, align 4, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !11
  %30 = call ptr @intv_fill_n(ptr noundef %29, i64 noundef 2, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %44, %26
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 3
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %47

35:                                               ; preds = %31
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [5 x i32], ptr %1, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = icmp eq i32 %39, -5
  br i1 %40, label %41, label %42

41:                                               ; preds = %35
  br label %43

42:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.41, ptr noundef @.str.1, i32 noundef 256, ptr noundef @__PRETTY_FUNCTION__.test_fill) #6
  unreachable

43:                                               ; preds = %41
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %5, align 4, !tbaa !5
  br label %31, !llvm.loop !13

47:                                               ; preds = %34
  %48 = getelementptr inbounds [5 x i32], ptr %1, i64 0, i64 3
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = icmp eq i32 %49, -10
  br i1 %50, label %51, label %52

51:                                               ; preds = %47
  br label %53

52:                                               ; preds = %47
  call void @__assert_fail(ptr noundef @.str.42, ptr noundef @.str.1, i32 noundef 258, ptr noundef @__PRETTY_FUNCTION__.test_fill) #6
  unreachable

53:                                               ; preds = %51
  %54 = getelementptr inbounds [5 x i32], ptr %1, i64 0, i64 4
  %55 = load i32, ptr %54, align 16, !tbaa !5
  %56 = icmp eq i32 %55, -10
  br i1 %56, label %57, label %58

57:                                               ; preds = %53
  br label %59

58:                                               ; preds = %53
  call void @__assert_fail(ptr noundef @.str.43, ptr noundef @.str.1, i32 noundef 259, ptr noundef @__PRETTY_FUNCTION__.test_fill) #6
  unreachable

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

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

declare ptr @intv_fill_n(ptr noundef, i64 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"}
!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
@__const.test_fill.nums = external hidden unnamed_addr constant [5 x i32], align 16
@.str.40 = external hidden unnamed_addr constant [13 x i8], align 1
@__PRETTY_FUNCTION__.test_fill = external hidden unnamed_addr constant [21 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [15 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: 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
define dso_local void @test_fill() local_unnamed_addr #3 {
  %1 = alloca [5 x i32], align 16
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(20) %1, ptr noundef nonnull align 16 dereferenceable(20) @__const.test_fill.nums, i64 20, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 2, ptr %2, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 20
  %4 = call ptr @intv_fill(ptr noundef nonnull %1, ptr noundef nonnull %3, ptr noundef nonnull %2) #5
  %5 = load i32, ptr %1, align 16, !tbaa !5
  %6 = icmp eq i32 %5, 2
  br i1 %6, label %7, label %32

7:                                                ; preds = %0
  %8 = getelementptr inbounds i8, ptr %1, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %11, label %32

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !5
  %14 = icmp eq i32 %13, 2
  br i1 %14, label %15, label %32

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %1, i64 12
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %32

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %1, i64 16
  %21 = load i32, ptr %20, align 16, !tbaa !5
  %22 = icmp eq i32 %21, 2
  br i1 %22, label %23, label %32

23:                                               ; preds = %19
  store i32 -5, ptr %2, align 4, !tbaa !5
  %24 = call ptr @intv_fill_n(ptr noundef nonnull %1, i64 noundef 3, ptr noundef nonnull %2) #5
  store i32 -10, ptr %2, align 4, !tbaa !5
  %25 = call ptr @intv_fill_n(ptr noundef %24, i64 noundef 2, ptr noundef nonnull %2) #5
  %26 = load i32, ptr %1, align 16, !tbaa !5
  %27 = icmp eq i32 %26, -5
  %28 = load i32, ptr %8, align 4
  %29 = icmp eq i32 %28, -5
  %or.cond = select i1 %27, i1 %29, i1 false
  %30 = load i32, ptr %12, align 8
  %31 = icmp eq i32 %30, -5
  %or.cond13 = select i1 %or.cond, i1 %31, i1 false
  br i1 %or.cond13, label %33, label %36

32:                                               ; preds = %19, %15, %11, %7, %0
  call void @__assert_fail(ptr noundef nonnull @.str.40, ptr noundef nonnull @.str.1, i32 noundef 247, ptr noundef nonnull @__PRETTY_FUNCTION__.test_fill) #6
  unreachable

33:                                               ; preds = %23
  %34 = load i32, ptr %16, align 4, !tbaa !5
  %35 = icmp eq i32 %34, -10
  br i1 %35, label %38, label %37

36:                                               ; preds = %23
  call void @__assert_fail(ptr noundef nonnull @.str.41, ptr noundef nonnull @.str.1, i32 noundef 256, ptr noundef nonnull @__PRETTY_FUNCTION__.test_fill) #6
  unreachable

37:                                               ; preds = %33
  call void @__assert_fail(ptr noundef nonnull @.str.42, ptr noundef nonnull @.str.1, i32 noundef 258, ptr noundef nonnull @__PRETTY_FUNCTION__.test_fill) #6
  unreachable

38:                                               ; preds = %33
  %39 = load i32, ptr %20, align 16, !tbaa !5
  %40 = icmp eq i32 %39, -10
  br i1 %40, label %42, label %41

41:                                               ; preds = %38
  call void @__assert_fail(ptr noundef nonnull @.str.43, ptr noundef nonnull @.str.1, i32 noundef 259, ptr noundef nonnull @__PRETTY_FUNCTION__.test_fill) #6
  unreachable

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

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

declare ptr @intv_fill_n(ptr noundef, i64 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 = { 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"}


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