; LLVM IR from ryanlayer/giggle :: test/unit (test_bpt)

; 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"

@__const.test_b_search.D = external hidden unnamed_addr constant [10 x i32], align 16
@__const.test_b_search.A = external hidden unnamed_addr constant [20 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local void @test_b_search() #0 {
  %1 = alloca [10 x i32], align 16
  %2 = alloca [20 x i32], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 40, ptr %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %1, ptr align 16 @__const.test_b_search.D, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 80, ptr %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.test_b_search.A, i64 80, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %17, %0
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 20
  br i1 %6, label %7, label %20

7:                                                ; preds = %4
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [20 x i32], ptr %2, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = getelementptr inbounds [10 x i32], ptr %1, i64 0, i64 0
  %15 = call i32 @b_search(i32 noundef %13, ptr noundef %14, i32 noundef 10)
  %16 = sext i32 %15 to i64
  call void @UnityAssertEqualNumber(i64 noundef %12, i64 noundef %16, ptr noundef null, i64 noundef 68, i32 noundef 148)
  br label %17

17:                                               ; preds = %7
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %3, align 4, !tbaa !5
  br label %4, !llvm.loop !9

20:                                               ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %1) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef) #3

declare i32 @b_search(i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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"}


; 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"

@__const.test_b_search.D = external hidden unnamed_addr constant [10 x i32], align 16
@__const.test_b_search.A = external hidden unnamed_addr constant [20 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local void @test_b_search() local_unnamed_addr #0 {
  %1 = alloca [10 x i32], align 16
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(40) %1, ptr noundef nonnull align 16 dereferenceable(40) @__const.test_b_search.D, i64 40, i1 false)
  %2 = load i32, ptr @__const.test_b_search.A, align 16, !tbaa !5
  %3 = zext i32 %2 to i64
  %4 = call i32 @b_search(i32 noundef 0, ptr noundef nonnull %1, i32 noundef 10) #4
  %5 = sext i32 %4 to i64
  call void @UnityAssertEqualNumber(i64 noundef %3, i64 noundef %5, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 4), align 4, !tbaa !5
  %7 = zext i32 %6 to i64
  %8 = call i32 @b_search(i32 noundef 1, ptr noundef nonnull %1, i32 noundef 10) #4
  %9 = sext i32 %8 to i64
  call void @UnityAssertEqualNumber(i64 noundef %7, i64 noundef %9, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 8), align 8, !tbaa !5
  %11 = zext i32 %10 to i64
  %12 = call i32 @b_search(i32 noundef 2, ptr noundef nonnull %1, i32 noundef 10) #4
  %13 = sext i32 %12 to i64
  call void @UnityAssertEqualNumber(i64 noundef %11, i64 noundef %13, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 12), align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = call i32 @b_search(i32 noundef 3, ptr noundef nonnull %1, i32 noundef 10) #4
  %17 = sext i32 %16 to i64
  call void @UnityAssertEqualNumber(i64 noundef %15, i64 noundef %17, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 16), align 16, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = call i32 @b_search(i32 noundef 4, ptr noundef nonnull %1, i32 noundef 10) #4
  %21 = sext i32 %20 to i64
  call void @UnityAssertEqualNumber(i64 noundef %19, i64 noundef %21, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 20), align 4, !tbaa !5
  %23 = zext i32 %22 to i64
  %24 = call i32 @b_search(i32 noundef 5, ptr noundef nonnull %1, i32 noundef 10) #4
  %25 = sext i32 %24 to i64
  call void @UnityAssertEqualNumber(i64 noundef %23, i64 noundef %25, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 24), align 8, !tbaa !5
  %27 = zext i32 %26 to i64
  %28 = call i32 @b_search(i32 noundef 6, ptr noundef nonnull %1, i32 noundef 10) #4
  %29 = sext i32 %28 to i64
  call void @UnityAssertEqualNumber(i64 noundef %27, i64 noundef %29, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 28), align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = call i32 @b_search(i32 noundef 7, ptr noundef nonnull %1, i32 noundef 10) #4
  %33 = sext i32 %32 to i64
  call void @UnityAssertEqualNumber(i64 noundef %31, i64 noundef %33, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %34 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 32), align 16, !tbaa !5
  %35 = zext i32 %34 to i64
  %36 = call i32 @b_search(i32 noundef 8, ptr noundef nonnull %1, i32 noundef 10) #4
  %37 = sext i32 %36 to i64
  call void @UnityAssertEqualNumber(i64 noundef %35, i64 noundef %37, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %38 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 36), align 4, !tbaa !5
  %39 = zext i32 %38 to i64
  %40 = call i32 @b_search(i32 noundef 9, ptr noundef nonnull %1, i32 noundef 10) #4
  %41 = sext i32 %40 to i64
  call void @UnityAssertEqualNumber(i64 noundef %39, i64 noundef %41, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 40), align 8, !tbaa !5
  %43 = zext i32 %42 to i64
  %44 = call i32 @b_search(i32 noundef 10, ptr noundef nonnull %1, i32 noundef 10) #4
  %45 = sext i32 %44 to i64
  call void @UnityAssertEqualNumber(i64 noundef %43, i64 noundef %45, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %46 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 44), align 4, !tbaa !5
  %47 = zext i32 %46 to i64
  %48 = call i32 @b_search(i32 noundef 11, ptr noundef nonnull %1, i32 noundef 10) #4
  %49 = sext i32 %48 to i64
  call void @UnityAssertEqualNumber(i64 noundef %47, i64 noundef %49, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %50 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 48), align 16, !tbaa !5
  %51 = zext i32 %50 to i64
  %52 = call i32 @b_search(i32 noundef 12, ptr noundef nonnull %1, i32 noundef 10) #4
  %53 = sext i32 %52 to i64
  call void @UnityAssertEqualNumber(i64 noundef %51, i64 noundef %53, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %54 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 52), align 4, !tbaa !5
  %55 = zext i32 %54 to i64
  %56 = call i32 @b_search(i32 noundef 13, ptr noundef nonnull %1, i32 noundef 10) #4
  %57 = sext i32 %56 to i64
  call void @UnityAssertEqualNumber(i64 noundef %55, i64 noundef %57, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %58 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 56), align 8, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = call i32 @b_search(i32 noundef 14, ptr noundef nonnull %1, i32 noundef 10) #4
  %61 = sext i32 %60 to i64
  call void @UnityAssertEqualNumber(i64 noundef %59, i64 noundef %61, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %62 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 60), align 4, !tbaa !5
  %63 = zext i32 %62 to i64
  %64 = call i32 @b_search(i32 noundef 15, ptr noundef nonnull %1, i32 noundef 10) #4
  %65 = sext i32 %64 to i64
  call void @UnityAssertEqualNumber(i64 noundef %63, i64 noundef %65, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %66 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 64), align 16, !tbaa !5
  %67 = zext i32 %66 to i64
  %68 = call i32 @b_search(i32 noundef 16, ptr noundef nonnull %1, i32 noundef 10) #4
  %69 = sext i32 %68 to i64
  call void @UnityAssertEqualNumber(i64 noundef %67, i64 noundef %69, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %70 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 68), align 4, !tbaa !5
  %71 = zext i32 %70 to i64
  %72 = call i32 @b_search(i32 noundef 17, ptr noundef nonnull %1, i32 noundef 10) #4
  %73 = sext i32 %72 to i64
  call void @UnityAssertEqualNumber(i64 noundef %71, i64 noundef %73, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %74 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 72), align 8, !tbaa !5
  %75 = zext i32 %74 to i64
  %76 = call i32 @b_search(i32 noundef 18, ptr noundef nonnull %1, i32 noundef 10) #4
  %77 = sext i32 %76 to i64
  call void @UnityAssertEqualNumber(i64 noundef %75, i64 noundef %77, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  %78 = load i32, ptr getelementptr inbounds (i8, ptr @__const.test_b_search.A, i64 76), align 4, !tbaa !5
  %79 = zext i32 %78 to i64
  %80 = call i32 @b_search(i32 noundef 19, ptr noundef nonnull %1, i32 noundef 10) #4
  %81 = sext i32 %80 to i64
  call void @UnityAssertEqualNumber(i64 noundef %79, i64 noundef %81, ptr noundef null, i64 noundef 68, i32 noundef 148) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %1) #4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

declare void @UnityAssertEqualNumber(i64 noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

declare i32 @b_search(i32 noundef, ptr noundef, i32 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) #1

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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