; LLVM IR from Thre4dripper/DSA-Programs :: 18. Hashing/Closed Hashing/DoubleHashing.ll (Z6SearchiPi)

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

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3hx1i(i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3hx2i(i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z6SearchiPi(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %34, %2
  %9 = load i32, ptr %6, align 4, !tbaa !5
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = call noundef i32 @_Z3hx2i(i32 noundef %10)
  %12 = mul nsw i32 %9, %11
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = call noundef i32 @_Z3hx2i(i32 noundef %13)
  %15 = mul nsw i32 10, %14
  %16 = icmp slt i32 %12, %15
  br i1 %16, label %17, label %32

17:                                               ; preds = %8
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = call noundef i32 @_Z3hx1i(i32 noundef %19)
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = call noundef i32 @_Z3hx2i(i32 noundef %22)
  %24 = mul nsw i32 %21, %23
  %25 = add nsw i32 %20, %24
  %26 = srem i32 %25, 10
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr %18, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = icmp ne i32 %29, %30
  br label %32

32:                                               ; preds = %17, %8
  %33 = phi i1 [ false, %8 ], [ %31, %17 ]
  br i1 %33, label %34, label %37

34:                                               ; preds = %32
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %6, align 4, !tbaa !5
  br label %8, !llvm.loop !11

37:                                               ; preds = %32
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = call noundef i32 @_Z3hx2i(i32 noundef %39)
  %41 = mul nsw i32 %38, %40
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = call noundef i32 @_Z3hx2i(i32 noundef %42)
  %44 = mul nsw i32 10, %43
  %45 = icmp eq i32 %41, %44
  br i1 %45, label %46, label %47

46:                                               ; preds = %37
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %48

47:                                               ; preds = %37
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %48

48:                                               ; preds = %47, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %49 = load i1, ptr %3, align 1
  ret i1 %49
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3hx1i(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3hx2i(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z6SearchiPi(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call noundef i32 @_Z3hx2i(i32 noundef %0)
  %4 = tail call noundef i32 @_Z3hx2i(i32 noundef %0)
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2, %14
  %.013 = phi i32 [ %15, %14 ], [ 0, %2 ]
  %6 = tail call noundef i32 @_Z3hx1i(i32 noundef %0)
  %7 = tail call noundef i32 @_Z3hx2i(i32 noundef %0)
  %8 = mul nsw i32 %7, %.013
  %9 = add nsw i32 %8, %6
  %10 = srem i32 %9, 10
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds i32, ptr %1, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %.not = icmp eq i32 %13, %0
  br i1 %.not, label %.critedge, label %14

14:                                               ; preds = %.lr.ph
  %15 = add nuw nsw i32 %.013, 1
  %16 = tail call noundef i32 @_Z3hx2i(i32 noundef %0)
  %17 = mul nsw i32 %16, %15
  %18 = tail call noundef i32 @_Z3hx2i(i32 noundef %0)
  %19 = mul nsw i32 %18, 10
  %20 = icmp slt i32 %17, %19
  br i1 %20, label %.lr.ph, label %.critedge, !llvm.loop !9

.critedge:                                        ; preds = %.lr.ph, %14, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %15, %14 ], [ %.013, %.lr.ph ]
  %21 = tail call noundef i32 @_Z3hx2i(i32 noundef %0)
  %22 = mul nsw i32 %21, %.0.lcssa
  %23 = tail call noundef i32 @_Z3hx2i(i32 noundef %0)
  %24 = mul nsw i32 %23, 10
  %25 = icmp ne i32 %22, %24
  ret i1 %25
}

attributes #0 = { mustprogress 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" }

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass