; LLVM IR from nsccgz-storage/nvlsm :: util/hash.ll (ZN7leveldb4HashEPKcmj)

; 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: mustprogress uwtable
define dso_local noundef i32 @_ZN7leveldb4HashEPKcmj(ptr noundef %0, i64 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 -962287725, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 24, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %12, i64 %13
  store ptr %14, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %15 = load i32, ptr %6, align 4, !tbaa !11
  %16 = zext i32 %15 to i64
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = mul i64 %17, 3332679571
  %19 = xor i64 %16, %18
  %20 = trunc i64 %19 to i32
  store i32 %20, ptr %10, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %26, %3
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 4
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = icmp ule ptr %23, %24
  br i1 %25, label %26, label %40

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef %27)
  store i32 %28, ptr %11, align 4, !tbaa !11
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 4
  store ptr %30, ptr %4, align 8, !tbaa !5
  %31 = load i32, ptr %11, align 4, !tbaa !11
  %32 = load i32, ptr %10, align 4, !tbaa !11
  %33 = add i32 %32, %31
  store i32 %33, ptr %10, align 4, !tbaa !11
  %34 = load i32, ptr %10, align 4, !tbaa !11
  %35 = mul i32 %34, -962287725
  store i32 %35, ptr %10, align 4, !tbaa !11
  %36 = load i32, ptr %10, align 4, !tbaa !11
  %37 = lshr i32 %36, 16
  %38 = load i32, ptr %10, align 4, !tbaa !11
  %39 = xor i32 %38, %37
  store i32 %39, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %21, !llvm.loop !13

40:                                               ; preds = %21
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = ptrtoint ptr %41 to i64
  %44 = ptrtoint ptr %42 to i64
  %45 = sub i64 %43, %44
  switch i64 %45, label %81 [
    i64 3, label %46
    i64 2, label %57
    i64 1, label %68
  ]

46:                                               ; preds = %40
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i64 2
  %49 = load i8, ptr %48, align 1, !tbaa !15
  %50 = zext i8 %49 to i32
  %51 = shl i32 %50, 16
  %52 = load i32, ptr %10, align 4, !tbaa !11
  %53 = add i32 %52, %51
  store i32 %53, ptr %10, align 4, !tbaa !11
  br label %54

54:                                               ; preds = %46
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56, %40
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %58, i64 1
  %60 = load i8, ptr %59, align 1, !tbaa !15
  %61 = zext i8 %60 to i32
  %62 = shl i32 %61, 8
  %63 = load i32, ptr %10, align 4, !tbaa !11
  %64 = add i32 %63, %62
  store i32 %64, ptr %10, align 4, !tbaa !11
  br label %65

65:                                               ; preds = %57
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67, %40
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i64 0
  %71 = load i8, ptr %70, align 1, !tbaa !15
  %72 = zext i8 %71 to i32
  %73 = load i32, ptr %10, align 4, !tbaa !11
  %74 = add i32 %73, %72
  store i32 %74, ptr %10, align 4, !tbaa !11
  %75 = load i32, ptr %10, align 4, !tbaa !11
  %76 = mul i32 %75, -962287725
  store i32 %76, ptr %10, align 4, !tbaa !11
  %77 = load i32, ptr %10, align 4, !tbaa !11
  %78 = lshr i32 %77, 24
  %79 = load i32, ptr %10, align 4, !tbaa !11
  %80 = xor i32 %79, %78
  store i32 %80, ptr %10, align 4, !tbaa !11
  br label %81

81:                                               ; preds = %68, %40
  %82 = load i32, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %82
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef) #2

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

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


; 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
define dso_local noundef i32 @_ZN7leveldb4HashEPKcmj(ptr noundef %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 %1
  %5 = trunc i64 %1 to i32
  %6 = mul i32 %5, -962287725
  %7 = xor i32 %6, %2
  %.not27 = icmp slt i64 %1, 4
  br i1 %.not27, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %9 = phi ptr [ %15, %.lr.ph ], [ %8, %.lr.ph.preheader ]
  %.029 = phi ptr [ %9, %.lr.ph ], [ %0, %.lr.ph.preheader ]
  %.02428 = phi i32 [ %14, %.lr.ph ], [ %7, %.lr.ph.preheader ]
  %10 = tail call noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef %.029)
  %11 = add i32 %10, %.02428
  %12 = mul i32 %11, -962287725
  %13 = lshr i32 %12, 16
  %14 = xor i32 %13, %12
  %15 = getelementptr inbounds i8, ptr %9, i64 4
  %.not = icmp ugt ptr %15, %4
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %3
  %.024.lcssa = phi i32 [ %7, %3 ], [ %14, %.lr.ph ]
  %.0.lcssa = phi ptr [ %0, %3 ], [ %9, %.lr.ph ]
  %16 = ptrtoint ptr %4 to i64
  %17 = ptrtoint ptr %.0.lcssa to i64
  %18 = sub i64 %16, %17
  switch i64 %18, label %38 [
    i64 3, label %19
    i64 2, label %25
    i64 1, label %31
  ]

19:                                               ; preds = %._crit_edge
  %20 = getelementptr inbounds i8, ptr %.0.lcssa, i64 2
  %21 = load i8, ptr %20, align 1, !tbaa !7
  %22 = zext i8 %21 to i32
  %23 = shl nuw nsw i32 %22, 16
  %24 = add i32 %23, %.024.lcssa
  br label %25

25:                                               ; preds = %19, %._crit_edge
  %.1 = phi i32 [ %.024.lcssa, %._crit_edge ], [ %24, %19 ]
  %26 = getelementptr inbounds i8, ptr %.0.lcssa, i64 1
  %27 = load i8, ptr %26, align 1, !tbaa !7
  %28 = zext i8 %27 to i32
  %29 = shl nuw nsw i32 %28, 8
  %30 = add i32 %29, %.1
  br label %31

31:                                               ; preds = %25, %._crit_edge
  %.2 = phi i32 [ %.024.lcssa, %._crit_edge ], [ %30, %25 ]
  %32 = load i8, ptr %.0.lcssa, align 1, !tbaa !7
  %33 = zext i8 %32 to i32
  %34 = add i32 %.2, %33
  %35 = mul i32 %34, -962287725
  %36 = lshr i32 %35, 24
  %37 = xor i32 %36, %35
  br label %38

38:                                               ; preds = %31, %._crit_edge
  %.3 = phi i32 [ %.024.lcssa, %._crit_edge ], [ %37, %31 ]
  ret i32 %.3
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7leveldb13DecodeFixed32EPKc(ptr noundef) local_unnamed_addr #1

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" }
attributes #1 = { inlinehint 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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