; LLVM IR from yinqiwen/ardb :: src/common/geo/geohash_helper.ll (ZN4ardb13GeoHashHelper13GetCoordRangeEhR12GeoHashRangeS2_)

; 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.GeoHashRange = type { double, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN4ardb13GeoHashHelper13GetCoordRangeEhR12GeoHashRangeS2_(i8 noundef zeroext %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2) #0 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store i8 %0, ptr %5, align 1, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !8
  store ptr %2, ptr %7, align 8, !tbaa !8
  %8 = load i8, ptr %5, align 1, !tbaa !5
  %9 = zext i8 %8 to i32
  switch i32 %9, label %28 [
    i32 1, label %10
    i32 2, label %19
  ]

10:                                               ; preds = %3
  %11 = load ptr, ptr %6, align 8, !tbaa !8
  %12 = getelementptr inbounds %struct.GeoHashRange, ptr %11, i32 0, i32 0
  store double 0x40554345B6C3760C, ptr %12, align 8, !tbaa !10
  %13 = load ptr, ptr %6, align 8, !tbaa !8
  %14 = getelementptr inbounds %struct.GeoHashRange, ptr %13, i32 0, i32 1
  store double 0xC0554345B6C3760C, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %7, align 8, !tbaa !8
  %16 = getelementptr inbounds %struct.GeoHashRange, ptr %15, i32 0, i32 0
  store double 1.800000e+02, ptr %16, align 8, !tbaa !10
  %17 = load ptr, ptr %7, align 8, !tbaa !8
  %18 = getelementptr inbounds %struct.GeoHashRange, ptr %17, i32 0, i32 1
  store double -1.800000e+02, ptr %18, align 8, !tbaa !13
  br label %29

19:                                               ; preds = %3
  %20 = load ptr, ptr %6, align 8, !tbaa !8
  %21 = getelementptr inbounds %struct.GeoHashRange, ptr %20, i32 0, i32 0
  store double 0x41731C05E5EB851F, ptr %21, align 8, !tbaa !10
  %22 = load ptr, ptr %6, align 8, !tbaa !8
  %23 = getelementptr inbounds %struct.GeoHashRange, ptr %22, i32 0, i32 1
  store double 0xC1731C05E5EB851F, ptr %23, align 8, !tbaa !13
  %24 = load ptr, ptr %7, align 8, !tbaa !8
  %25 = getelementptr inbounds %struct.GeoHashRange, ptr %24, i32 0, i32 0
  store double 0x41731C05E5EB851F, ptr %25, align 8, !tbaa !10
  %26 = load ptr, ptr %7, align 8, !tbaa !8
  %27 = getelementptr inbounds %struct.GeoHashRange, ptr %26, i32 0, i32 1
  store double 0xC1731C05E5EB851F, ptr %27, align 8, !tbaa !13
  br label %29

28:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  br label %30

29:                                               ; preds = %19, %10
  store i32 0, ptr %4, align 4
  br label %30

30:                                               ; preds = %29, %28
  %31 = load i32, ptr %4, align 4
  ret i32 %31
}

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"_ZTS12GeoHashRange", !12, i64 0, !12, i64 8}
!12 = !{!"double", !6, i64 0}
!13 = !{!11, !12, 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 nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local noundef range(i32 -1, 1) i32 @_ZN4ardb13GeoHashHelper13GetCoordRangeEhR12GeoHashRangeS2_(i8 noundef zeroext %0, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(16) %1, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(16) %2) local_unnamed_addr #0 align 2 {
  switch i8 %0, label %7 [
    i8 1, label %.sink.split
    i8 2, label %4
  ]

4:                                                ; preds = %3
  br label %.sink.split

.sink.split:                                      ; preds = %3, %4
  %5 = phi <2 x double> [ <double 0x41731C05E5EB851F, double 0xC1731C05E5EB851F>, %4 ], [ <double 0x40554345B6C3760C, double 0xC0554345B6C3760C>, %3 ]
  %6 = phi <2 x double> [ <double 0x41731C05E5EB851F, double 0xC1731C05E5EB851F>, %4 ], [ <double 1.800000e+02, double -1.800000e+02>, %3 ]
  store <2 x double> %5, ptr %1, align 8, !tbaa !5
  store <2 x double> %6, ptr %2, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %.sink.split, %3
  %.0 = phi i32 [ -1, %3 ], [ 0, %.sink.split ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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