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

; 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 i32 @_Z2hxPii(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %33, %2
  %9 = load i32, ptr %6, align 4, !tbaa !9
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = call noundef i32 @_Z3hx2i(i32 noundef %10)
  %12 = mul nsw i32 %9, %11
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %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 %31

17:                                               ; preds = %8
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = call noundef i32 @_Z3hx1i(i32 noundef %19)
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %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 !9
  %30 = icmp ne i32 %29, 0
  br label %31

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

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

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

45:                                               ; preds = %36
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %55

46:                                               ; preds = %36
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = call noundef i32 @_Z3hx1i(i32 noundef %47)
  %49 = load i32, ptr %6, align 4, !tbaa !9
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = call noundef i32 @_Z3hx2i(i32 noundef %50)
  %52 = mul nsw i32 %49, %51
  %53 = add nsw i32 %48, %52
  %54 = srem i32 %53, 10
  store i32 %54, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %55

55:                                               ; preds = %46, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %56 = load i32, ptr %3, align 4
  ret i32 %56
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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 range(i32 -9, 10) i32 @_Z2hxPii(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = tail call noundef i32 @_Z3hx2i(i32 noundef %1)
  %4 = tail call noundef i32 @_Z3hx2i(i32 noundef %1)
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2, %14
  %.015 = phi i32 [ %15, %14 ], [ 0, %2 ]
  %6 = tail call noundef i32 @_Z3hx1i(i32 noundef %1)
  %7 = tail call noundef i32 @_Z3hx2i(i32 noundef %1)
  %8 = mul nsw i32 %7, %.015
  %9 = add nsw i32 %8, %6
  %10 = srem i32 %9, 10
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds i32, ptr %0, 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 %.015, 1
  %16 = tail call noundef i32 @_Z3hx2i(i32 noundef %1)
  %17 = mul nsw i32 %16, %15
  %18 = tail call noundef i32 @_Z3hx2i(i32 noundef %1)
  %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 ], [ %.015, %.lr.ph ]
  %21 = tail call noundef i32 @_Z3hx2i(i32 noundef %1)
  %22 = mul nsw i32 %21, %.0.lcssa
  %23 = tail call noundef i32 @_Z3hx2i(i32 noundef %1)
  %24 = mul nsw i32 %23, 10
  %25 = icmp eq i32 %22, %24
  br i1 %25, label %32, label %26

26:                                               ; preds = %.critedge
  %27 = tail call noundef i32 @_Z3hx1i(i32 noundef %1)
  %28 = tail call noundef i32 @_Z3hx2i(i32 noundef %1)
  %29 = mul nsw i32 %28, %.0.lcssa
  %30 = add nsw i32 %29, %27
  %31 = srem i32 %30, 10
  br label %32

32:                                               ; preds = %.critedge, %26
  %.014 = phi i32 [ %31, %26 ], [ -1, %.critedge ]
  ret i32 %.014
}

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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass