; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3Vector.ll (ZNK8R3Vector7SextantEv)

; 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.R3Vector = type { [3 x double] }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK8R3Vector7SextantEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  %5 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %6 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %7 = load double, ptr %6, align 8, !tbaa !9
  %8 = call double @llvm.fabs.f64(double %7)
  %9 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %10 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 1
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = call double @llvm.fabs.f64(double %11)
  %13 = fcmp oge double %8, %12
  br i1 %13, label %14, label %38

14:                                               ; preds = %1
  %15 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %16 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 0
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = call double @llvm.fabs.f64(double %17)
  %19 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %20 = getelementptr inbounds [3 x double], ptr %19, i64 0, i64 2
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = call double @llvm.fabs.f64(double %21)
  %23 = fcmp oge double %18, %22
  br i1 %23, label %24, label %31

24:                                               ; preds = %14
  %25 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %26 = getelementptr inbounds [3 x double], ptr %25, i64 0, i64 0
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = fcmp oge double %27, 0.000000e+00
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  store i32 1, ptr %2, align 4
  br label %62

30:                                               ; preds = %24
  store i32 0, ptr %2, align 4
  br label %62

31:                                               ; preds = %14
  %32 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %33 = getelementptr inbounds [3 x double], ptr %32, i64 0, i64 2
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = fcmp oge double %34, 0.000000e+00
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store i32 5, ptr %2, align 4
  br label %62

37:                                               ; preds = %31
  store i32 4, ptr %2, align 4
  br label %62

38:                                               ; preds = %1
  %39 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %40 = getelementptr inbounds [3 x double], ptr %39, i64 0, i64 1
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = call double @llvm.fabs.f64(double %41)
  %43 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %44 = getelementptr inbounds [3 x double], ptr %43, i64 0, i64 2
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = call double @llvm.fabs.f64(double %45)
  %47 = fcmp oge double %42, %46
  br i1 %47, label %48, label %55

48:                                               ; preds = %38
  %49 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %50 = getelementptr inbounds [3 x double], ptr %49, i64 0, i64 1
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = fcmp oge double %51, 0.000000e+00
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  store i32 3, ptr %2, align 4
  br label %62

54:                                               ; preds = %48
  store i32 2, ptr %2, align 4
  br label %62

55:                                               ; preds = %38
  %56 = getelementptr inbounds %class.R3Vector, ptr %4, i32 0, i32 0
  %57 = getelementptr inbounds [3 x double], ptr %56, i64 0, i64 2
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = fcmp oge double %58, 0.000000e+00
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  store i32 5, ptr %2, align 4
  br label %62

61:                                               ; preds = %55
  store i32 4, ptr %2, align 4
  br label %62

62:                                               ; preds = %61, %60, %54, %53, %37, %36, %30, %29
  %63 = load i32, ptr %2, align 4
  ret i32 %63
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

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


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef range(i32 0, 6) i32 @_ZNK8R3Vector7SextantEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0) local_unnamed_addr #1 align 2 {
  %2 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %3 = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %2)
  %4 = extractelement <2 x double> %3, i64 0
  %5 = extractelement <2 x double> %3, i64 1
  %6 = fcmp ult double %4, %5
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = tail call double @llvm.fabs.f64(double %8)
  br i1 %6, label %17, label %10

10:                                               ; preds = %1
  %11 = fcmp ult double %4, %9
  br i1 %11, label %15, label %12

12:                                               ; preds = %10
  %13 = extractelement <2 x double> %2, i64 0
  %14 = fcmp oge double %13, 0.000000e+00
  %. = zext i1 %14 to i32
  br label %24

15:                                               ; preds = %10
  %16 = fcmp ult double %8, 0.000000e+00
  %.3 = select i1 %16, i32 4, i32 5
  br label %24

17:                                               ; preds = %1
  %18 = fcmp ult double %5, %9
  br i1 %18, label %22, label %19

19:                                               ; preds = %17
  %20 = extractelement <2 x double> %2, i64 1
  %21 = fcmp ult double %20, 0.000000e+00
  %.4 = select i1 %21, i32 2, i32 3
  br label %24

22:                                               ; preds = %17
  %23 = fcmp ult double %8, 0.000000e+00
  %.5 = select i1 %23, i32 4, i32 5
  br label %24

24:                                               ; preds = %22, %19, %15, %12
  %.0 = phi i32 [ %., %12 ], [ %.3, %15 ], [ %.4, %19 ], [ %.5, %22 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fabs.v2f64(<2 x double>) #2

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


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