; LLVM IR from keroro824/HashingDeepLearning :: SLIDE/LSH.ll (ZN3LSH5clearEv)

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

%class.LSH = type { ptr, i32, i32, i32, ptr }
%class.Bucket = type <{ ptr, i32, i32, i32, [4 x i8] }>

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) #0

declare void @_ZN6BucketC1Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN6BucketD1Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPvm(ptr noundef, i64 noundef) #5

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3LSH5clearEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #6 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %62, %1
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = getelementptr inbounds %class.LSH, ptr %6, i32 0, i32 2
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = icmp slt i32 %8, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %75

13:                                               ; preds = %7
  %14 = getelementptr inbounds %class.LSH, ptr %6, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds ptr, ptr %15, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %33, label %21

21:                                               ; preds = %13
  %22 = getelementptr inbounds i8, ptr %19, i64 -8
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds %class.Bucket, ptr %19, i64 %23
  %25 = icmp eq ptr %19, %24
  br i1 %25, label %30, label %26

26:                                               ; preds = %26, %21
  %27 = phi ptr [ %24, %21 ], [ %28, %26 ]
  %28 = getelementptr inbounds %class.Bucket, ptr %27, i64 -1
  call void @_ZN6BucketD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %28) #7
  %29 = icmp eq ptr %28, %19
  br i1 %29, label %30, label %26

30:                                               ; preds = %26, %21
  %31 = mul i64 24, %23
  %32 = add i64 %31, 8
  call void @_ZdaPvm(ptr noundef %22, i64 noundef %32) #8
  br label %33

33:                                               ; preds = %30, %13
  %34 = getelementptr inbounds %class.LSH, ptr %6, i32 0, i32 3
  %35 = load i32, ptr %34, align 8, !tbaa !14
  %36 = shl i32 1, %35
  %37 = sext i32 %36 to i64
  %38 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %37, i64 24)
  %39 = extractvalue { i64, i1 } %38, 1
  %40 = extractvalue { i64, i1 } %38, 0
  %41 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %40, i64 8)
  %42 = extractvalue { i64, i1 } %41, 1
  %43 = or i1 %39, %42
  %44 = extractvalue { i64, i1 } %41, 0
  %45 = select i1 %43, i64 -1, i64 %44
  %46 = call noalias noundef nonnull ptr @_Znam(i64 noundef %45) #9
  store i64 %37, ptr %46, align 16
  %47 = getelementptr inbounds i8, ptr %46, i64 8
  %48 = icmp eq i64 %37, 0
  br i1 %48, label %56, label %49

49:                                               ; preds = %33
  %50 = getelementptr inbounds %class.Bucket, ptr %47, i64 %37
  br label %51

51:                                               ; preds = %53, %49
  %52 = phi ptr [ %47, %49 ], [ %54, %53 ]
  invoke void @_ZN6BucketC1Ev(ptr noundef nonnull align 8 dereferenceable(20) %52)
          to label %53 unwind label %65

53:                                               ; preds = %51
  %54 = getelementptr inbounds %class.Bucket, ptr %52, i64 1
  %55 = icmp eq ptr %54, %50
  br i1 %55, label %56, label %51

56:                                               ; preds = %53, %33
  %57 = getelementptr inbounds %class.LSH, ptr %6, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = load i32, ptr %3, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds ptr, ptr %58, i64 %60
  store ptr %47, ptr %61, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %56
  %63 = load i32, ptr %3, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !15

65:                                               ; preds = %51
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %4, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %5, align 4
  %69 = icmp eq ptr %47, %52
  br i1 %69, label %74, label %70

70:                                               ; preds = %70, %65
  %71 = phi ptr [ %52, %65 ], [ %72, %70 ]
  %72 = getelementptr inbounds %class.Bucket, ptr %71, i64 -1
  call void @_ZN6BucketD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %72) #7
  %73 = icmp eq ptr %72, %47
  br i1 %73, label %74, label %70

74:                                               ; preds = %70, %65
  call void @_ZdaPvm(ptr noundef %46, i64 noundef %45) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %76

75:                                               ; preds = %12
  ret void

76:                                               ; preds = %74
  %77 = load ptr, ptr %4, align 8
  %78 = load i32, ptr %5, align 4
  %79 = insertvalue { ptr, i32 } poison, ptr %77, 0
  %80 = insertvalue { ptr, i32 } %79, i32 %78, 1
  resume { ptr, i32 } %80
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nobuiltin allocsize(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 = { nocallback nofree nosync 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 "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 = { nobuiltin 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 = { mustprogress 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 #7 = { nounwind }
attributes #8 = { builtin nounwind }
attributes #9 = { builtin allocsize(0) }

!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 = !{!12, !10, i64 12}
!12 = !{!"_ZTS3LSH", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !10, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%class.Bucket = type <{ ptr, i32, i32, i32, [4 x i8] }>

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) #0

declare void @_ZN6BucketC1Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN6BucketD1Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #3

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPvm(ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3LSH5clearEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 12
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  br label %6

._crit_edge:                                      ; preds = %38, %1
  ret void

6:                                                ; preds = %.lr.ph, %38
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %38 ]
  %7 = load ptr, ptr %0, align 8, !tbaa !11
  %8 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = icmp eq ptr %9, null
  br i1 %10, label %21, label %11

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %9, i64 -8
  %13 = load i64, ptr %12, align 8
  %14 = icmp eq i64 %13, 0
  br i1 %14, label %.loopexit17, label %.preheader16.preheader

.preheader16.preheader:                           ; preds = %11
  %15 = getelementptr inbounds %class.Bucket, ptr %9, i64 %13
  br label %.preheader16

.preheader16:                                     ; preds = %.preheader16.preheader, %.preheader16
  %16 = phi ptr [ %17, %.preheader16 ], [ %15, %.preheader16.preheader ]
  %17 = getelementptr inbounds i8, ptr %16, i64 -24
  tail call void @_ZN6BucketD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %17) #6
  %18 = icmp eq ptr %17, %9
  br i1 %18, label %.loopexit17, label %.preheader16

.loopexit17:                                      ; preds = %.preheader16, %11
  %19 = mul i64 %13, 24
  %20 = add i64 %19, 8
  tail call void @_ZdaPvm(ptr noundef nonnull %12, i64 noundef %20) #7
  br label %21

21:                                               ; preds = %.loopexit17, %6
  %22 = load i32, ptr %5, align 8, !tbaa !13
  %23 = shl nuw i32 1, %22
  %24 = sext i32 %23 to i64
  %25 = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %24, i64 24)
  %26 = extractvalue { i64, i1 } %25, 1
  %27 = extractvalue { i64, i1 } %25, 0
  %28 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %27, i64 8)
  %29 = extractvalue { i64, i1 } %28, 1
  %30 = or i1 %26, %29
  %31 = extractvalue { i64, i1 } %28, 0
  %32 = select i1 %30, i64 -1, i64 %31
  %33 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %32) #8
  store i64 %24, ptr %33, align 16
  %.ptr11 = getelementptr inbounds i8, ptr %33, i64 8
  %34 = getelementptr inbounds %class.Bucket, ptr %.ptr11, i64 %24
  br label %35

35:                                               ; preds = %36, %21
  %.idx = phi i64 [ 8, %21 ], [ %.add, %36 ]
  %.ptr.ptr = getelementptr inbounds i8, ptr %33, i64 %.idx
  invoke void @_ZN6BucketC1Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.ptr)
          to label %36 unwind label %44

36:                                               ; preds = %35
  %.add = add nuw nsw i64 %.idx, 24
  %.ptr10 = getelementptr inbounds i8, ptr %33, i64 %.add
  %37 = icmp eq ptr %.ptr10, %34
  br i1 %37, label %38, label %35

38:                                               ; preds = %36
  %39 = load ptr, ptr %0, align 8, !tbaa !11
  %40 = getelementptr inbounds ptr, ptr %39, i64 %indvars.iv
  store ptr %.ptr11, ptr %40, align 8, !tbaa !12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %6, label %._crit_edge, !llvm.loop !14

44:                                               ; preds = %35
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = icmp eq i64 %.idx, 8
  br i1 %46, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %44, %.preheader
  %.idx12 = phi i64 [ %.add13, %.preheader ], [ %.idx, %44 ]
  %.add13 = add nsw i64 %.idx12, -24
  %.ptr15 = getelementptr inbounds i8, ptr %33, i64 %.add13
  tail call void @_ZN6BucketD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr15) #6
  %47 = icmp eq i64 %.add13, 8
  br i1 %47, label %.loopexit, label %.preheader

.loopexit:                                        ; preds = %.preheader, %44
  tail call void @_ZdaPvm(ptr noundef nonnull %33, i64 noundef %32) #7
  resume { ptr, i32 } %45
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nobuiltin allocsize(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 = { "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 "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 = { nobuiltin 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 #5 = { mustprogress 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 = { nounwind }
attributes #7 = { builtin nounwind }
attributes #8 = { builtin allocsize(0) }

!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, !10, i64 12}
!6 = !{!"_ZTS3LSH", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass