; 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_reverse.word = external hidden unnamed_addr constant [4 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__.test_reverse = external hidden unnamed_addr constant [24 x i8], align 1
@__const.test_reverse.word.31 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.34 = 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

; 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 willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @test_reverse() #4 {
  %1 = alloca [4 x i8], align 1
  %2 = alloca [7 x i8], align 1
  %3 = alloca [16 x i8], align 16
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr align 1 @__const.test_reverse.word, i64 4, i1 false)
  %5 = getelementptr inbounds [4 x i8], ptr %1, i64 0, i64 0
  %6 = getelementptr inbounds [4 x i8], ptr %1, i64 0, i64 0
  %7 = getelementptr inbounds i8, ptr %6, i64 3
  call void @string_reverse(ptr noundef %5, ptr noundef %7)
  %8 = getelementptr inbounds [4 x i8], ptr %1, i64 0, i64 0
  %9 = call i32 @strcmp(ptr noundef %8, ptr noundef @.str.29) #7
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %0
  br label %13

12:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str.30, ptr noundef @.str.1, i32 noundef 184, ptr noundef @__PRETTY_FUNCTION__.test_reverse) #8
  unreachable

13:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  call void @llvm.lifetime.start.p0(i64 7, ptr %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %2, ptr align 1 @__const.test_reverse.word.31, i64 7, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %14 = getelementptr inbounds [7 x i8], ptr %2, i64 0, i64 0
  %15 = getelementptr inbounds [7 x i8], ptr %2, i64 0, i64 0
  %16 = getelementptr inbounds i8, ptr %15, i64 6
  %17 = getelementptr inbounds [16 x i8], ptr %3, i64 0, i64 0
  %18 = call ptr @string_reverse_copy(ptr noundef %14, ptr noundef %16, ptr noundef %17)
  store ptr %18, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  store i8 0, ptr %19, align 1, !tbaa !9
  %20 = getelementptr inbounds [16 x i8], ptr %3, i64 0, i64 0
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.32, ptr noundef %20)
  %22 = getelementptr inbounds [16 x i8], ptr %3, i64 0, i64 0
  %23 = call i32 @strcmp(ptr noundef %22, ptr noundef @.str.33) #7
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %13
  br label %27

26:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.34, ptr noundef @.str.1, i32 noundef 192, ptr noundef @__PRETTY_FUNCTION__.test_reverse) #8
  unreachable

27:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 7, ptr %2) #6
  ret void
}

declare void @string_reverse(ptr noundef, ptr noundef) #5

declare ptr @string_reverse_copy(ptr noundef, ptr noundef, ptr noundef) #5

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

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 willreturn memory(read) "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 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 #5 = { "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 = { nounwind willreturn memory(read) }
attributes #8 = { 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}


; 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_reverse.word = external hidden unnamed_addr constant [4 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__.test_reverse = external hidden unnamed_addr constant [24 x i8], align 1
@__const.test_reverse.word.31 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.34 = 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

; 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @test_reverse() local_unnamed_addr #4 {
  %1 = alloca [4 x i8], align 4
  %2 = alloca [7 x i8], align 1
  %3 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %4 = load i32, ptr @__const.test_reverse.word, align 1
  store i32 %4, ptr %1, align 4
  %5 = getelementptr inbounds i8, ptr %1, i64 3
  call void @string_reverse(ptr noundef nonnull %1, ptr noundef nonnull %5) #7
  %6 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.29) #8
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %9, label %8

8:                                                ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str.30, ptr noundef nonnull @.str.1, i32 noundef 184, ptr noundef nonnull @__PRETTY_FUNCTION__.test_reverse) #9
  unreachable

9:                                                ; preds = %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 7, ptr nonnull %2) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(7) %2, ptr noundef nonnull align 1 dereferenceable(7) @__const.test_reverse.word.31, i64 7, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  %10 = getelementptr inbounds i8, ptr %2, i64 6
  %11 = call ptr @string_reverse_copy(ptr noundef nonnull %2, ptr noundef nonnull %10, ptr noundef nonnull %3) #7
  store i8 0, ptr %11, align 1, !tbaa !5
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.32, ptr noundef nonnull %3)
  %13 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.33) #8
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %16, label %15

15:                                               ; preds = %9
  call void @__assert_fail(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.1, i32 noundef 192, ptr noundef nonnull @__PRETTY_FUNCTION__.test_reverse) #9
  unreachable

16:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 7, ptr nonnull %2) #7
  ret void
}

declare void @string_reverse(ptr noundef, ptr noundef) local_unnamed_addr #5

declare ptr @string_reverse_copy(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

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

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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 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 #5 = { "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 = { 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { 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"}


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