; 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.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.93 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.94 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__.test_sample = external hidden unnamed_addr constant [23 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @string_end(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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) #1

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

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

8:                                                ; preds = %36, %0
  %9 = load i32, ptr %3, align 4, !tbaa !10
  %10 = icmp slt i32 %9, 4
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %39

12:                                               ; preds = %8
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  %14 = load i32, ptr %3, align 4, !tbaa !10
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i8, ptr %13, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !9
  %18 = sext i8 %17 to i32
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.93, i32 noundef %18)
  br label %20

20:                                               ; preds = %30, %12
  %21 = load i8, ptr %2, align 1, !tbaa !9
  %22 = sext i8 %21 to i32
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = load i32, ptr %3, align 4, !tbaa !10
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = icmp ne i32 %22, %28
  br i1 %29, label %30, label %35

30:                                               ; preds = %20
  %31 = load ptr, ptr %1, align 8, !tbaa !5
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = call ptr @string_end(ptr noundef %32)
  %34 = call ptr @string_sample(ptr noundef %31, ptr noundef %33, ptr noundef %2, i64 noundef 1)
  br label %20, !llvm.loop !12

35:                                               ; preds = %20
  br label %36

36:                                               ; preds = %35
  %37 = load i32, ptr %3, align 4, !tbaa !10
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %3, align 4, !tbaa !10
  br label %8, !llvm.loop !14

39:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 5, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %40 = load ptr, ptr %1, align 8, !tbaa !5
  %41 = load ptr, ptr %1, align 8, !tbaa !5
  %42 = call ptr @string_end(ptr noundef %41)
  %43 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %44 = call ptr @string_sample(ptr noundef %40, ptr noundef %42, ptr noundef %43, i64 noundef 5)
  store ptr %44, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %45 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  store ptr %45, ptr %6, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = ptrtoint ptr %46 to i64
  %49 = ptrtoint ptr %47 to i64
  %50 = sub i64 %48, %49
  %51 = icmp eq i64 %50, 4
  br i1 %51, label %52, label %53

52:                                               ; preds = %39
  br label %54

53:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.94, ptr noundef @.str.1, i32 noundef 516, ptr noundef @__PRETTY_FUNCTION__.test_sample) #5
  unreachable

54:                                               ; preds = %52
  %55 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 4
  store i8 0, ptr %55, align 1, !tbaa !9
  %56 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.32, ptr noundef %56)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %58 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 0
  %59 = load i8, ptr %58, align 1, !tbaa !9
  %60 = sext i8 %59 to i32
  %61 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 1
  %62 = load i8, ptr %61, align 1, !tbaa !9
  %63 = sext i8 %62 to i32
  %64 = add nsw i32 %60, %63
  %65 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 2
  %66 = load i8, ptr %65, align 1, !tbaa !9
  %67 = sext i8 %66 to i32
  %68 = add nsw i32 %64, %67
  %69 = getelementptr inbounds [5 x i8], ptr %4, i64 0, i64 3
  %70 = load i8, ptr %69, align 1, !tbaa !9
  %71 = sext i8 %70 to i32
  %72 = add nsw i32 %68, %71
  store i32 %72, ptr %7, align 4, !tbaa !10
  %73 = load i32, ptr %7, align 4, !tbaa !10
  %74 = icmp eq i32 %73, 394
  br i1 %74, label %75, label %76

75:                                               ; preds = %54
  br label %77

76:                                               ; preds = %54
  call void @__assert_fail(ptr noundef @.str.95, ptr noundef @.str.1, i32 noundef 522, ptr noundef @__PRETTY_FUNCTION__.test_sample) #5
  unreachable

77:                                               ; preds = %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 5, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

declare ptr @string_sample(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync 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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.93 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.94 = external hidden unnamed_addr constant [17 x i8], align 1
@__PRETTY_FUNCTION__.test_sample = external hidden unnamed_addr constant [23 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @string_end(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @test_sample() local_unnamed_addr #0 {
  %1 = alloca i8, align 1
  %2 = alloca [5 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #5
  store i8 122, ptr %1, align 1, !tbaa !5
  %3 = load i8, ptr @.str.6, align 1, !tbaa !5
  %4 = sext i8 %3 to i32
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.93, i32 noundef %4)
  %.not12 = icmp eq i8 %3, 122
  br i1 %.not12, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %6 = call ptr @string_end(ptr noundef nonnull @.str.6)
  %7 = call ptr @string_sample(ptr noundef nonnull @.str.6, ptr noundef %6, ptr noundef nonnull %1, i64 noundef 1) #5
  %8 = load i8, ptr %1, align 1, !tbaa !5
  %.not = icmp eq i8 %8, %3
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %0
  %9 = load i8, ptr getelementptr inbounds (i8, ptr @.str.6, i64 1), align 1, !tbaa !5
  %10 = sext i8 %9 to i32
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.93, i32 noundef %10)
  %12 = load i8, ptr %1, align 1, !tbaa !5
  %.not12.1 = icmp eq i8 %12, %9
  br i1 %.not12.1, label %._crit_edge.1, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %._crit_edge, %.lr.ph.1
  %13 = call ptr @string_end(ptr noundef nonnull @.str.6)
  %14 = call ptr @string_sample(ptr noundef nonnull @.str.6, ptr noundef %13, ptr noundef nonnull %1, i64 noundef 1) #5
  %15 = load i8, ptr %1, align 1, !tbaa !5
  %.not.1 = icmp eq i8 %15, %9
  br i1 %.not.1, label %._crit_edge.1, label %.lr.ph.1, !llvm.loop !8

._crit_edge.1:                                    ; preds = %.lr.ph.1, %._crit_edge
  %16 = load i8, ptr getelementptr inbounds (i8, ptr @.str.6, i64 2), align 1, !tbaa !5
  %17 = sext i8 %16 to i32
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.93, i32 noundef %17)
  %19 = load i8, ptr %1, align 1, !tbaa !5
  %.not12.2 = icmp eq i8 %19, %16
  br i1 %.not12.2, label %._crit_edge.2, label %.lr.ph.2

.lr.ph.2:                                         ; preds = %._crit_edge.1, %.lr.ph.2
  %20 = call ptr @string_end(ptr noundef nonnull @.str.6)
  %21 = call ptr @string_sample(ptr noundef nonnull @.str.6, ptr noundef %20, ptr noundef nonnull %1, i64 noundef 1) #5
  %22 = load i8, ptr %1, align 1, !tbaa !5
  %.not.2 = icmp eq i8 %22, %16
  br i1 %.not.2, label %._crit_edge.2, label %.lr.ph.2, !llvm.loop !8

._crit_edge.2:                                    ; preds = %.lr.ph.2, %._crit_edge.1
  %23 = load i8, ptr getelementptr inbounds (i8, ptr @.str.6, i64 3), align 1, !tbaa !5
  %24 = sext i8 %23 to i32
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.93, i32 noundef %24)
  %26 = load i8, ptr %1, align 1, !tbaa !5
  %.not12.3 = icmp eq i8 %26, %23
  br i1 %.not12.3, label %._crit_edge.3, label %.lr.ph.3

.lr.ph.3:                                         ; preds = %._crit_edge.2, %.lr.ph.3
  %27 = call ptr @string_end(ptr noundef nonnull @.str.6)
  %28 = call ptr @string_sample(ptr noundef nonnull @.str.6, ptr noundef %27, ptr noundef nonnull %1, i64 noundef 1) #5
  %29 = load i8, ptr %1, align 1, !tbaa !5
  %.not.3 = icmp eq i8 %29, %23
  br i1 %.not.3, label %._crit_edge.3, label %.lr.ph.3, !llvm.loop !8

._crit_edge.3:                                    ; preds = %.lr.ph.3, %._crit_edge.2
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %2) #5
  %30 = call ptr @string_end(ptr noundef nonnull @.str.6)
  %31 = call ptr @string_sample(ptr noundef nonnull @.str.6, ptr noundef %30, ptr noundef nonnull %2, i64 noundef 5) #5
  %32 = ptrtoint ptr %31 to i64
  %33 = ptrtoint ptr %2 to i64
  %34 = sub i64 %32, %33
  %35 = icmp eq i64 %34, 4
  br i1 %35, label %37, label %36

36:                                               ; preds = %._crit_edge.3
  call void @__assert_fail(ptr noundef nonnull @.str.94, ptr noundef nonnull @.str.1, i32 noundef 516, ptr noundef nonnull @__PRETTY_FUNCTION__.test_sample) #6
  unreachable

37:                                               ; preds = %._crit_edge.3
  %38 = getelementptr inbounds i8, ptr %2, i64 4
  store i8 0, ptr %38, align 1, !tbaa !5
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.32, ptr noundef nonnull %2)
  %40 = load i8, ptr %2, align 1, !tbaa !5
  %41 = sext i8 %40 to i32
  %42 = getelementptr inbounds i8, ptr %2, i64 1
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = sext i8 %43 to i32
  %45 = add nsw i32 %44, %41
  %46 = getelementptr inbounds i8, ptr %2, i64 2
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %48 = sext i8 %47 to i32
  %49 = add nsw i32 %45, %48
  %50 = getelementptr inbounds i8, ptr %2, i64 3
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = sext i8 %51 to i32
  %53 = add nsw i32 %49, %52
  %54 = icmp eq i32 %53, 394
  br i1 %54, label %56, label %55

55:                                               ; preds = %37
  call void @__assert_fail(ptr noundef nonnull @.str.95, ptr noundef nonnull @.str.1, i32 noundef 522, ptr noundef nonnull @__PRETTY_FUNCTION__.test_sample) #6
  unreachable

56:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %2) #5
  ret void
}

declare ptr @string_sample(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync 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 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass