; LLVM IR from apache/kvrocks :: src/types/geohash.ll (Z13GeohashDecodeRK12GeoHashRangeS1_RK11GeoHashBitsP11GeoHashArea)

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

%struct.GeoHashArea = type { %struct.GeoHashBits, %struct.GeoHashRange, %struct.GeoHashRange }
%struct.GeoHashBits = type <{ i64, i8, [7 x i8] }>
%struct.GeoHashRange = type { double, double }

; 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 i32 @_Z13GeohashDecodeRK12GeoHashRangeS1_RK11GeoHashBitsP11GeoHashArea(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(9) %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca i64, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = call noundef zeroext i1 @_Z10HASHISZERORK11GeoHashBits(ptr noundef nonnull align 8 dereferenceable(9) %16)
  br i1 %17, label %27, label %18

18:                                               ; preds = %4
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %27

21:                                               ; preds = %18
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = call noundef zeroext i1 @_Z11RANGEISZERORK12GeoHashRange(ptr noundef nonnull align 8 dereferenceable(16) %22)
  br i1 %23, label %27, label %24

24:                                               ; preds = %21
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = call noundef zeroext i1 @_Z11RANGEISZERORK12GeoHashRange(ptr noundef nonnull align 8 dereferenceable(16) %25)
  br i1 %26, label %27, label %28

27:                                               ; preds = %24, %21, %18, %4
  store i32 0, ptr %5, align 4
  br label %128

28:                                               ; preds = %24
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.GeoHashArea, ptr %30, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %31, ptr align 8 %29, i64 9, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.GeoHashBits, ptr %32, i32 0, i32 1
  %34 = load i8, ptr %33, align 8, !tbaa !13
  store i8 %34, ptr %10, align 1, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.GeoHashBits, ptr %35, i32 0, i32 0
  %37 = load i64, ptr %36, align 8, !tbaa !15
  %38 = call noundef i64 @_ZL14Deinterleave64m(i64 noundef %37)
  store i64 %38, ptr %11, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.GeoHashRange, ptr %39, i32 0, i32 1
  %41 = load double, ptr %40, align 8, !tbaa !16
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.GeoHashRange, ptr %42, i32 0, i32 0
  %44 = load double, ptr %43, align 8, !tbaa !19
  %45 = fsub double %41, %44
  store double %45, ptr %12, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.GeoHashRange, ptr %46, i32 0, i32 1
  %48 = load double, ptr %47, align 8, !tbaa !16
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.GeoHashRange, ptr %49, i32 0, i32 0
  %51 = load double, ptr %50, align 8, !tbaa !19
  %52 = fsub double %48, %51
  store double %52, ptr %13, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %53 = load i64, ptr %11, align 8, !tbaa !10
  %54 = trunc i64 %53 to i32
  store i32 %54, ptr %14, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %55 = load i64, ptr %11, align 8, !tbaa !10
  %56 = lshr i64 %55, 32
  %57 = trunc i64 %56 to i32
  store i32 %57, ptr %15, align 4, !tbaa !21
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.GeoHashRange, ptr %58, i32 0, i32 0
  %60 = load double, ptr %59, align 8, !tbaa !19
  %61 = load i32, ptr %14, align 4, !tbaa !21
  %62 = uitofp i32 %61 to double
  %63 = fmul double %62, 1.000000e+00
  %64 = load i8, ptr %10, align 1, !tbaa !12
  %65 = zext i8 %64 to i32
  %66 = zext i32 %65 to i64
  %67 = shl i64 1, %66
  %68 = uitofp i64 %67 to double
  %69 = fdiv double %63, %68
  %70 = load double, ptr %12, align 8, !tbaa !20
  %71 = call double @llvm.fmuladd.f64(double %69, double %70, double %60)
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.GeoHashArea, ptr %72, i32 0, i32 2
  %74 = getelementptr inbounds %struct.GeoHashRange, ptr %73, i32 0, i32 0
  store double %71, ptr %74, align 8, !tbaa !23
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.GeoHashRange, ptr %75, i32 0, i32 0
  %77 = load double, ptr %76, align 8, !tbaa !19
  %78 = load i32, ptr %14, align 4, !tbaa !21
  %79 = add i32 %78, 1
  %80 = uitofp i32 %79 to double
  %81 = fmul double %80, 1.000000e+00
  %82 = load i8, ptr %10, align 1, !tbaa !12
  %83 = zext i8 %82 to i32
  %84 = zext i32 %83 to i64
  %85 = shl i64 1, %84
  %86 = uitofp i64 %85 to double
  %87 = fdiv double %81, %86
  %88 = load double, ptr %12, align 8, !tbaa !20
  %89 = call double @llvm.fmuladd.f64(double %87, double %88, double %77)
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.GeoHashArea, ptr %90, i32 0, i32 2
  %92 = getelementptr inbounds %struct.GeoHashRange, ptr %91, i32 0, i32 1
  store double %89, ptr %92, align 8, !tbaa !25
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.GeoHashRange, ptr %93, i32 0, i32 0
  %95 = load double, ptr %94, align 8, !tbaa !19
  %96 = load i32, ptr %15, align 4, !tbaa !21
  %97 = uitofp i32 %96 to double
  %98 = fmul double %97, 1.000000e+00
  %99 = load i8, ptr %10, align 1, !tbaa !12
  %100 = zext i8 %99 to i32
  %101 = zext i32 %100 to i64
  %102 = shl i64 1, %101
  %103 = uitofp i64 %102 to double
  %104 = fdiv double %98, %103
  %105 = load double, ptr %13, align 8, !tbaa !20
  %106 = call double @llvm.fmuladd.f64(double %104, double %105, double %95)
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.GeoHashArea, ptr %107, i32 0, i32 1
  %109 = getelementptr inbounds %struct.GeoHashRange, ptr %108, i32 0, i32 0
  store double %106, ptr %109, align 8, !tbaa !26
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.GeoHashRange, ptr %110, i32 0, i32 0
  %112 = load double, ptr %111, align 8, !tbaa !19
  %113 = load i32, ptr %15, align 4, !tbaa !21
  %114 = add i32 %113, 1
  %115 = uitofp i32 %114 to double
  %116 = fmul double %115, 1.000000e+00
  %117 = load i8, ptr %10, align 1, !tbaa !12
  %118 = zext i8 %117 to i32
  %119 = zext i32 %118 to i64
  %120 = shl i64 1, %119
  %121 = uitofp i64 %120 to double
  %122 = fdiv double %116, %121
  %123 = load double, ptr %13, align 8, !tbaa !20
  %124 = call double @llvm.fmuladd.f64(double %122, double %123, double %112)
  %125 = load ptr, ptr %9, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.GeoHashArea, ptr %125, i32 0, i32 1
  %127 = getelementptr inbounds %struct.GeoHashRange, ptr %126, i32 0, i32 1
  store double %124, ptr %127, align 8, !tbaa !27
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  br label %128

128:                                              ; preds = %28, %27
  %129 = load i32, ptr %5, align 4
  ret i32 %129
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z10HASHISZERORK11GeoHashBits(ptr noundef nonnull align 8 dereferenceable(9)) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z11RANGEISZERORK12GeoHashRange(ptr noundef nonnull align 8 dereferenceable(16)) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL14Deinterleave64m(i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{i64 0, i64 8, !10, i64 8, i64 1, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !7, i64 8}
!14 = !{!"_ZTS11GeoHashBits", !11, i64 0, !7, i64 8}
!15 = !{!14, !11, i64 0}
!16 = !{!17, !18, i64 8}
!17 = !{!"_ZTS12GeoHashRange", !18, i64 0, !18, i64 8}
!18 = !{!"double", !7, i64 0}
!19 = !{!17, !18, i64 0}
!20 = !{!18, !18, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!24, !18, i64 32}
!24 = !{!"_ZTS11GeoHashArea", !14, i64 0, !17, i64 16, !17, i64 32}
!25 = !{!24, !18, i64 40}
!26 = !{!24, !18, i64 16}
!27 = !{!24, !18, 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z13GeohashDecodeRK12GeoHashRangeS1_RK11GeoHashBitsP11GeoHashArea(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(9) %2, ptr noundef writeonly %3) local_unnamed_addr #0 {
  %5 = tail call noundef zeroext i1 @_Z10HASHISZERORK11GeoHashBits(ptr noundef nonnull align 8 dereferenceable(9) %2)
  %6 = icmp eq ptr %3, null
  %or.cond.not = or i1 %6, %5
  br i1 %or.cond.not, label %51, label %7

7:                                                ; preds = %4
  %8 = tail call noundef zeroext i1 @_Z11RANGEISZERORK12GeoHashRange(ptr noundef nonnull align 8 dereferenceable(16) %1)
  br i1 %8, label %51, label %9

9:                                                ; preds = %7
  %10 = tail call noundef zeroext i1 @_Z11RANGEISZERORK12GeoHashRange(ptr noundef nonnull align 8 dereferenceable(16) %0)
  br i1 %10, label %51, label %11

11:                                               ; preds = %9
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(9) %3, ptr noundef nonnull align 8 dereferenceable(9) %2, i64 9, i1 false), !tbaa.struct !5
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  %13 = load i8, ptr %12, align 8, !tbaa !11
  %14 = load i64, ptr %2, align 8, !tbaa !13
  %15 = tail call noundef i64 @_ZL14Deinterleave64m(i64 noundef %14)
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load double, ptr %16, align 8, !tbaa !14
  %18 = load double, ptr %1, align 8, !tbaa !17
  %19 = fsub double %17, %18
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load double, ptr %20, align 8, !tbaa !14
  %22 = load double, ptr %0, align 8, !tbaa !17
  %23 = fsub double %21, %22
  %24 = trunc i64 %15 to i32
  %25 = lshr i64 %15, 32
  %26 = trunc nuw i64 %25 to i32
  %27 = uitofp i32 %24 to double
  %28 = zext nneg i8 %13 to i64
  %29 = shl nuw i64 1, %28
  %30 = uitofp i64 %29 to double
  %31 = fdiv double %27, %30
  %32 = tail call double @llvm.fmuladd.f64(double %31, double %19, double %18)
  %33 = getelementptr inbounds i8, ptr %3, i64 32
  store double %32, ptr %33, align 8, !tbaa !18
  %34 = load double, ptr %1, align 8, !tbaa !17
  %35 = add i32 %24, 1
  %36 = uitofp i32 %35 to double
  %37 = fdiv double %36, %30
  %38 = tail call double @llvm.fmuladd.f64(double %37, double %19, double %34)
  %39 = getelementptr inbounds i8, ptr %3, i64 40
  store double %38, ptr %39, align 8, !tbaa !20
  %40 = load double, ptr %0, align 8, !tbaa !17
  %41 = uitofp i32 %26 to double
  %42 = fdiv double %41, %30
  %43 = tail call double @llvm.fmuladd.f64(double %42, double %23, double %40)
  %44 = getelementptr inbounds i8, ptr %3, i64 16
  store double %43, ptr %44, align 8, !tbaa !21
  %45 = load double, ptr %0, align 8, !tbaa !17
  %46 = add i32 %26, 1
  %47 = uitofp i32 %46 to double
  %48 = fdiv double %47, %30
  %49 = tail call double @llvm.fmuladd.f64(double %48, double %23, double %45)
  %50 = getelementptr inbounds i8, ptr %3, i64 24
  store double %49, ptr %50, align 8, !tbaa !22
  br label %51

51:                                               ; preds = %4, %7, %9, %11
  %.0 = phi i32 [ 1, %11 ], [ 0, %9 ], [ 0, %7 ], [ 0, %4 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z10HASHISZERORK11GeoHashBits(ptr noundef nonnull align 8 dereferenceable(9)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z11RANGEISZERORK12GeoHashRange(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL14Deinterleave64m(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{i64 0, i64 8, !6, i64 8, i64 1, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !8, i64 8}
!12 = !{!"_ZTS11GeoHashBits", !7, i64 0, !8, i64 8}
!13 = !{!12, !7, i64 0}
!14 = !{!15, !16, i64 8}
!15 = !{!"_ZTS12GeoHashRange", !16, i64 0, !16, i64 8}
!16 = !{!"double", !8, i64 0}
!17 = !{!15, !16, i64 0}
!18 = !{!19, !16, i64 32}
!19 = !{!"_ZTS11GeoHashArea", !12, i64 0, !15, i64 16, !15, i64 32}
!20 = !{!19, !16, i64 40}
!21 = !{!19, !16, i64 16}
!22 = !{!19, !16, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass