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

; 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.GeoHashBits = type <{ i64, i8, [7 x i8] }>
%struct.GeoHashRange = type { double, double }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z13GeohashEncodePK12GeoHashRangeS1_ddhP11GeoHashBits(ptr noundef %0, ptr noundef %1, double noundef %2, double noundef %3, i8 noundef zeroext %4, ptr noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i8, align 1
  %13 = alloca ptr, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store double %2, ptr %10, align 8, !tbaa !9
  store double %3, ptr %11, align 8, !tbaa !9
  store i8 %4, ptr %12, align 1, !tbaa !11
  store ptr %5, ptr %13, align 8, !tbaa !5
  %16 = load ptr, ptr %13, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %32

18:                                               ; preds = %6
  %19 = load i8, ptr %12, align 1, !tbaa !11
  %20 = zext i8 %19 to i32
  %21 = icmp sgt i32 %20, 32
  br i1 %21, label %32, label %22

22:                                               ; preds = %18
  %23 = load i8, ptr %12, align 1, !tbaa !11
  %24 = zext i8 %23 to i32
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %32, label %26

26:                                               ; preds = %22
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = call noundef zeroext i1 @_Z12RANGEPISZEROPK12GeoHashRange(ptr noundef %27)
  br i1 %28, label %32, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_Z12RANGEPISZEROPK12GeoHashRange(ptr noundef %30)
  br i1 %31, label %32, label %33

32:                                               ; preds = %29, %26, %22, %18, %6
  store i32 0, ptr %7, align 4
  br label %124

33:                                               ; preds = %29
  %34 = load double, ptr %10, align 8, !tbaa !9
  %35 = fcmp ogt double %34, 1.800000e+02
  br i1 %35, label %45, label %36

36:                                               ; preds = %33
  %37 = load double, ptr %10, align 8, !tbaa !9
  %38 = fcmp olt double %37, -1.800000e+02
  br i1 %38, label %45, label %39

39:                                               ; preds = %36
  %40 = load double, ptr %11, align 8, !tbaa !9
  %41 = fcmp ogt double %40, 0x40554345B1A57F00
  br i1 %41, label %45, label %42

42:                                               ; preds = %39
  %43 = load double, ptr %11, align 8, !tbaa !9
  %44 = fcmp olt double %43, 0xC0554345B1A57F00
  br i1 %44, label %45, label %46

45:                                               ; preds = %42, %39, %36, %33
  store i32 0, ptr %7, align 4
  br label %124

46:                                               ; preds = %42
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.GeoHashBits, ptr %47, i32 0, i32 0
  store i64 0, ptr %48, align 8, !tbaa !12
  %49 = load i8, ptr %12, align 1, !tbaa !11
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.GeoHashBits, ptr %50, i32 0, i32 1
  store i8 %49, ptr %51, align 8, !tbaa !15
  %52 = load double, ptr %11, align 8, !tbaa !9
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.GeoHashRange, ptr %53, i32 0, i32 0
  %55 = load double, ptr %54, align 8, !tbaa !16
  %56 = fcmp olt double %52, %55
  br i1 %56, label %75, label %57

57:                                               ; preds = %46
  %58 = load double, ptr %11, align 8, !tbaa !9
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.GeoHashRange, ptr %59, i32 0, i32 1
  %61 = load double, ptr %60, align 8, !tbaa !18
  %62 = fcmp ogt double %58, %61
  br i1 %62, label %75, label %63

63:                                               ; preds = %57
  %64 = load double, ptr %10, align 8, !tbaa !9
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.GeoHashRange, ptr %65, i32 0, i32 0
  %67 = load double, ptr %66, align 8, !tbaa !16
  %68 = fcmp olt double %64, %67
  br i1 %68, label %75, label %69

69:                                               ; preds = %63
  %70 = load double, ptr %10, align 8, !tbaa !9
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.GeoHashRange, ptr %71, i32 0, i32 1
  %73 = load double, ptr %72, align 8, !tbaa !18
  %74 = fcmp ogt double %70, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %69, %63, %57, %46
  store i32 0, ptr %7, align 4
  br label %124

76:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %77 = load double, ptr %11, align 8, !tbaa !9
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.GeoHashRange, ptr %78, i32 0, i32 0
  %80 = load double, ptr %79, align 8, !tbaa !16
  %81 = fsub double %77, %80
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.GeoHashRange, ptr %82, i32 0, i32 1
  %84 = load double, ptr %83, align 8, !tbaa !18
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.GeoHashRange, ptr %85, i32 0, i32 0
  %87 = load double, ptr %86, align 8, !tbaa !16
  %88 = fsub double %84, %87
  %89 = fdiv double %81, %88
  store double %89, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %90 = load double, ptr %10, align 8, !tbaa !9
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.GeoHashRange, ptr %91, i32 0, i32 0
  %93 = load double, ptr %92, align 8, !tbaa !16
  %94 = fsub double %90, %93
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.GeoHashRange, ptr %95, i32 0, i32 1
  %97 = load double, ptr %96, align 8, !tbaa !18
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.GeoHashRange, ptr %98, i32 0, i32 0
  %100 = load double, ptr %99, align 8, !tbaa !16
  %101 = fsub double %97, %100
  %102 = fdiv double %94, %101
  store double %102, ptr %15, align 8, !tbaa !9
  %103 = load i8, ptr %12, align 1, !tbaa !11
  %104 = zext i8 %103 to i32
  %105 = zext i32 %104 to i64
  %106 = shl i64 1, %105
  %107 = uitofp i64 %106 to double
  %108 = load double, ptr %14, align 8, !tbaa !9
  %109 = fmul double %108, %107
  store double %109, ptr %14, align 8, !tbaa !9
  %110 = load i8, ptr %12, align 1, !tbaa !11
  %111 = zext i8 %110 to i32
  %112 = zext i32 %111 to i64
  %113 = shl i64 1, %112
  %114 = uitofp i64 %113 to double
  %115 = load double, ptr %15, align 8, !tbaa !9
  %116 = fmul double %115, %114
  store double %116, ptr %15, align 8, !tbaa !9
  %117 = load double, ptr %14, align 8, !tbaa !9
  %118 = fptoui double %117 to i32
  %119 = load double, ptr %15, align 8, !tbaa !9
  %120 = fptoui double %119 to i32
  %121 = call noundef i64 @_ZL12Interleave64jj(i32 noundef %118, i32 noundef %120)
  %122 = load ptr, ptr %13, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.GeoHashBits, ptr %122, i32 0, i32 0
  store i64 %121, ptr %123, align 8, !tbaa !12
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %124

124:                                              ; preds = %76, %75, %45, %32
  %125 = load i32, ptr %7, align 4
  ret i32 %125
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z12RANGEPISZEROPK12GeoHashRange(ptr 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: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL12Interleave64jj(i32 noundef, i32 noundef) #3

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

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 = { inlinehint 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!"double", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTS11GeoHashBits", !14, i64 0, !7, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!13, !7, i64 8}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTS12GeoHashRange", !10, i64 0, !10, i64 8}
!18 = !{!17, !10, i64 8}


; 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 uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z13GeohashEncodePK12GeoHashRangeS1_ddhP11GeoHashBits(ptr noundef %0, ptr noundef %1, double noundef %2, double noundef %3, i8 noundef zeroext %4, ptr noundef writeonly %5) local_unnamed_addr #0 {
  %7 = icmp eq ptr %5, null
  %8 = add i8 %4, -33
  %9 = icmp ult i8 %8, -32
  %or.cond5 = or i1 %7, %9
  br i1 %or.cond5, label %48, label %10

10:                                               ; preds = %6
  %11 = tail call noundef zeroext i1 @_Z12RANGEPISZEROPK12GeoHashRange(ptr noundef %1)
  br i1 %11, label %48, label %12

12:                                               ; preds = %10
  %13 = tail call noundef zeroext i1 @_Z12RANGEPISZEROPK12GeoHashRange(ptr noundef %0)
  br i1 %13, label %48, label %14

14:                                               ; preds = %12
  %15 = tail call double @llvm.fabs.f64(double %2)
  %or.cond7 = fcmp ogt double %15, 1.800000e+02
  %16 = fcmp ogt double %3, 0x40554345B1A57F00
  %or.cond9 = or i1 %or.cond7, %16
  %17 = fcmp olt double %3, 0xC0554345B1A57F00
  %or.cond11 = or i1 %17, %or.cond9
  br i1 %or.cond11, label %48, label %18

18:                                               ; preds = %14
  store i64 0, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %5, i64 8
  store i8 %4, ptr %19, align 8, !tbaa !10
  %20 = load double, ptr %1, align 8, !tbaa !11
  %21 = fcmp ogt double %20, %3
  br i1 %21, label %48, label %22

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %1, i64 8
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = fcmp olt double %24, %3
  br i1 %25, label %48, label %26

26:                                               ; preds = %22
  %27 = load double, ptr %0, align 8, !tbaa !11
  %28 = fcmp ogt double %27, %2
  br i1 %28, label %48, label %29

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  %31 = load double, ptr %30, align 8, !tbaa !14
  %32 = fcmp olt double %31, %2
  br i1 %32, label %48, label %33

33:                                               ; preds = %29
  %34 = fsub double %3, %20
  %35 = fsub double %24, %20
  %36 = fdiv double %34, %35
  %37 = fsub double %2, %27
  %38 = fsub double %31, %27
  %39 = fdiv double %37, %38
  %40 = zext nneg i8 %4 to i64
  %41 = shl nuw nsw i64 1, %40
  %42 = uitofp nneg i64 %41 to double
  %43 = fmul double %36, %42
  %44 = fmul double %39, %42
  %45 = fptoui double %43 to i32
  %46 = fptoui double %44 to i32
  %47 = tail call noundef i64 @_ZL12Interleave64jj(i32 noundef %45, i32 noundef %46)
  store i64 %47, ptr %5, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %18, %22, %26, %29, %14, %6, %10, %12, %33
  %.0 = phi i32 [ 1, %33 ], [ 0, %12 ], [ 0, %10 ], [ 0, %6 ], [ 0, %14 ], [ 0, %29 ], [ 0, %26 ], [ 0, %22 ], [ 0, %18 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z12RANGEPISZEROPK12GeoHashRange(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL12Interleave64jj(i32 noundef, i32 noundef) local_unnamed_addr #2

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

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 = { inlinehint 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 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 = !{!6, !7, i64 0}
!6 = !{!"_ZTS11GeoHashBits", !7, i64 0, !8, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !8, i64 8}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS12GeoHashRange", !13, i64 0, !13, i64 8}
!13 = !{!"double", !8, i64 0}
!14 = !{!12, !13, i64 8}


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