; LLVM IR from pavlosdais/Abstract-Data-Types :: tests (test_BloomFilter)

; 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_insert.hash_functions = external hidden unnamed_addr constant [3 x ptr], align 16
@.str.40 = external hidden unnamed_addr constant [21 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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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) #2

declare ptr @bf_create(i32 noundef, ptr noundef, i8 noundef zeroext) #1

declare void @bf_destroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_insert() #3 {
  %1 = alloca [3 x ptr], align 16
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr %1) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %1, ptr align 16 @__const.test_insert.hash_functions, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  %10 = getelementptr inbounds [3 x ptr], ptr %1, i64 0, i64 0
  %11 = call ptr @bf_create(i32 noundef 500000, ptr noundef %10, i8 noundef zeroext 3)
  store ptr %11, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %12 = call ptr @create_ordered_array(i32 noundef 100000)
  store ptr %12, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %23, %0
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp ult i32 %14, 100000
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %13
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr %19, i64 %21
  call void @bf_insert(ptr noundef %18, ptr noundef %22)
  br label %23

23:                                               ; preds = %17
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = add i32 %24, 1
  store i32 %25, ptr %4, align 4, !tbaa !9
  br label %13, !llvm.loop !11

26:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 100000, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 200000, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = call ptr @create_ordered_array(i32 noundef %27)
  store ptr %28, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %29 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %29, ptr %9, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %46, %26
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = icmp ult i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %49

35:                                               ; preds = %30
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %37, i64 %39
  %41 = call zeroext i1 @bf_exists(ptr noundef %36, ptr noundef %40)
  br i1 %41, label %42, label %45

42:                                               ; preds = %35
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = add i32 %43, 1
  store i32 %44, ptr %8, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %42, %35
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = add i32 %47, 1
  store i32 %48, ptr %9, align 4, !tbaa !9
  br label %30, !llvm.loop !13

49:                                               ; preds = %34
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.40, i32 noundef %50)
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  call void @bf_destroy(ptr noundef %52)
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %53) #6
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %54) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %1) #6
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @create_ordered_array(i32 noundef) #4

declare void @bf_insert(ptr noundef, ptr noundef) #1

declare zeroext i1 @bf_exists(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 #6 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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_insert.hash_functions = external hidden unnamed_addr constant [3 x ptr], align 16
@.str.40 = external hidden unnamed_addr constant [21 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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: 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 ptr @bf_create(i32 noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #3

declare void @bf_destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @test_insert() local_unnamed_addr #4 {
  %1 = alloca [3 x ptr], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %1, ptr noundef nonnull align 16 dereferenceable(24) @__const.test_insert.hash_functions, i64 24, i1 false)
  %2 = call ptr @bf_create(i32 noundef 500000, ptr noundef nonnull %1, i8 noundef zeroext 3) #7
  %3 = call ptr @create_ordered_array(i32 noundef 100000)
  br label %6

4:                                                ; preds = %6
  %5 = call ptr @create_ordered_array(i32 noundef 200000)
  br label %10

6:                                                ; preds = %0, %6
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %6 ]
  %7 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv
  call void @bf_insert(ptr noundef %2, ptr noundef %7) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100000
  br i1 %exitcond.not, label %4, label %6, !llvm.loop !5

8:                                                ; preds = %10
  %9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.40, i32 noundef %spec.select)
  call void @bf_destroy(ptr noundef %2) #7
  call void @free(ptr noundef %3) #7
  call void @free(ptr noundef %5) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #7
  ret void

10:                                               ; preds = %4, %10
  %indvars.iv23 = phi i64 [ 100000, %4 ], [ %indvars.iv.next24, %10 ]
  %.01720 = phi i32 [ 0, %4 ], [ %spec.select, %10 ]
  %11 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv23
  %12 = call zeroext i1 @bf_exists(ptr noundef %2, ptr noundef nonnull %11) #7
  %13 = zext i1 %12 to i32
  %spec.select = add i32 %.01720, %13
  %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
  %exitcond26.not = icmp eq i64 %indvars.iv.next24, 200000
  br i1 %exitcond26.not, label %8, label %10, !llvm.loop !7
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @create_ordered_array(i32 noundef) local_unnamed_addr #5

declare void @bf_insert(ptr noundef, ptr noundef) local_unnamed_addr #3

declare zeroext i1 @bf_exists(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 = { inlinehint 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 #6 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass