; LLVM IR from doyubkim/fluid-engine-dev :: src/jet (point_hash_grid_searcher2)

; 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.jet::Point" = type { i64, i64 }
%"class.jet::PointHashGridSearcher2" = type { %"class.jet::PointNeighborSearcher2", double, %"class.jet::Point", %"class.std::vector", %"class.std::vector.0" }
%"class.jet::PointNeighborSearcher2" = type { %"class.jet::Serializable" }
%"class.jet::Serializable" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<jet::Vector<double, 2>, std::allocator<jet::Vector<double, 2>>>::_Vector_impl" }
%"struct.std::_Vector_base<jet::Vector<double, 2>, std::allocator<jet::Vector<double, 2>>>::_Vector_impl" = type { %"struct.std::_Vector_base<jet::Vector<double, 2>, std::allocator<jet::Vector<double, 2>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<jet::Vector<double, 2>, std::allocator<jet::Vector<double, 2>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::vector<unsigned long>, std::allocator<std::vector<unsigned long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<unsigned long>, std::allocator<std::vector<unsigned long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<unsigned long>, std::allocator<std::vector<unsigned long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<unsigned long>, std::allocator<std::vector<unsigned long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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 uwtable
define dso_local noundef i64 @_ZNK3jet22PointHashGridSearcher225getHashKeyFromBucketIndexERKNS_5PointIlLm2EEE(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.jet::Point", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3jet5PointIlLm2EEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %7)
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %"class.jet::Point", ptr %8, i32 0, i32 0
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.jet::PointHashGridSearcher2", ptr %6, i32 0, i32 2
  %12 = getelementptr inbounds %"class.jet::Point", ptr %11, i32 0, i32 0
  %13 = load i64, ptr %12, align 8, !tbaa !12
  %14 = srem i64 %10, %13
  %15 = getelementptr inbounds %"class.jet::Point", ptr %5, i32 0, i32 0
  store i64 %14, ptr %15, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.jet::Point", ptr %16, i32 0, i32 1
  %18 = load i64, ptr %17, align 8, !tbaa !25
  %19 = getelementptr inbounds %"class.jet::PointHashGridSearcher2", ptr %6, i32 0, i32 2
  %20 = getelementptr inbounds %"class.jet::Point", ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !26
  %22 = srem i64 %18, %21
  %23 = getelementptr inbounds %"class.jet::Point", ptr %5, i32 0, i32 1
  store i64 %22, ptr %23, align 8, !tbaa !25
  %24 = getelementptr inbounds %"class.jet::Point", ptr %5, i32 0, i32 0
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = icmp slt i64 %25, 0
  br i1 %26, label %27, label %34

27:                                               ; preds = %2
  %28 = getelementptr inbounds %"class.jet::PointHashGridSearcher2", ptr %6, i32 0, i32 2
  %29 = getelementptr inbounds %"class.jet::Point", ptr %28, i32 0, i32 0
  %30 = load i64, ptr %29, align 8, !tbaa !12
  %31 = getelementptr inbounds %"class.jet::Point", ptr %5, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = add nsw i64 %32, %30
  store i64 %33, ptr %31, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %27, %2
  %35 = getelementptr inbounds %"class.jet::Point", ptr %5, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !25
  %37 = icmp slt i64 %36, 0
  br i1 %37, label %38, label %45

38:                                               ; preds = %34
  %39 = getelementptr inbounds %"class.jet::PointHashGridSearcher2", ptr %6, i32 0, i32 2
  %40 = getelementptr inbounds %"class.jet::Point", ptr %39, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !26
  %42 = getelementptr inbounds %"class.jet::Point", ptr %5, i32 0, i32 1
  %43 = load i64, ptr %42, align 8, !tbaa !25
  %44 = add nsw i64 %43, %41
  store i64 %44, ptr %42, align 8, !tbaa !25
  br label %45

45:                                               ; preds = %38, %34
  %46 = getelementptr inbounds %"class.jet::Point", ptr %5, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !25
  %48 = getelementptr inbounds %"class.jet::PointHashGridSearcher2", ptr %6, i32 0, i32 2
  %49 = getelementptr inbounds %"class.jet::Point", ptr %48, i32 0, i32 0
  %50 = load i64, ptr %49, align 8, !tbaa !12
  %51 = mul nsw i64 %47, %50
  %52 = getelementptr inbounds %"class.jet::Point", ptr %5, i32 0, i32 0
  %53 = load i64, ptr %52, align 8, !tbaa !9
  %54 = add nsw i64 %51, %53
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  ret i64 %54
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3jet5PointIlLm2EEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !11, i64 0}
!10 = !{!"_ZTSN3jet5PointIlLm2EEE", !11, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !11, i64 16}
!13 = !{!"_ZTSN3jet22PointHashGridSearcher2E", !14, i64 0, !16, i64 8, !10, i64 16, !17, i64 32, !21, i64 56}
!14 = !{!"_ZTSN3jet22PointNeighborSearcher2E", !15, i64 0}
!15 = !{!"_ZTSN3jet12SerializableE"}
!16 = !{!"double", !7, i64 0}
!17 = !{!"_ZTSSt6vectorIN3jet6VectorIdLm2EEESaIS2_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIN3jet6VectorIdLm2EEESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN3jet6VectorIdLm2EEESaIS2_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN3jet6VectorIdLm2EEESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTSSt6vectorIS_ImSaImEESaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseISt6vectorImSaImEESaIS2_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseISt6vectorImSaImEESaIS2_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseISt6vectorImSaImEESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!10, !11, i64 8}
!26 = !{!13, !11, i64 24}


; 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.jet::Point" = type { i64, i64 }

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

; 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 nounwind uwtable
define dso_local noundef i64 @_ZNK3jet22PointHashGridSearcher225getHashKeyFromBucketIndexERKNS_5PointIlLm2EEE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.jet::Point", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #2
  call void @_ZN3jet5PointIlLm2EEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %1)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !10
  %7 = srem i64 %4, %6
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !24
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load i64, ptr %10, align 8, !tbaa !25
  %12 = srem i64 %9, %11
  %13 = icmp slt i64 %7, 0
  %14 = select i1 %13, i64 %6, i64 0
  %spec.select = add nsw i64 %7, %14
  %15 = icmp slt i64 %12, 0
  %16 = select i1 %15, i64 %11, i64 0
  %17 = add nsw i64 %12, %16
  %18 = mul nsw i64 %17, %6
  %19 = add nsw i64 %18, %spec.select
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #2
  ret i64 %19
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3jet5PointIlLm2EEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

attributes #0 = { mustprogress 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, !7, i64 0}
!6 = !{!"_ZTSN3jet5PointIlLm2EEE", !7, i64 0, !7, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 16}
!11 = !{!"_ZTSN3jet22PointHashGridSearcher2E", !12, i64 0, !14, i64 8, !6, i64 16, !15, i64 32, !20, i64 56}
!12 = !{!"_ZTSN3jet22PointNeighborSearcher2E", !13, i64 0}
!13 = !{!"_ZTSN3jet12SerializableE"}
!14 = !{!"double", !8, i64 0}
!15 = !{!"_ZTSSt6vectorIN3jet6VectorIdLm2EEESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN3jet6VectorIdLm2EEESaIS2_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN3jet6VectorIdLm2EEESaIS2_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN3jet6VectorIdLm2EEESaIS2_EE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}
!19 = !{!"any pointer", !8, i64 0}
!20 = !{!"_ZTSSt6vectorIS_ImSaImEESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseISt6vectorImSaImEESaIS2_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseISt6vectorImSaImEESaIS2_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseISt6vectorImSaImEESaIS2_EE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}
!24 = !{!6, !7, i64 8}
!25 = !{!11, !7, i64 24}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass