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

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

@RN_EPSILON = external global double, align 8

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z11RNIsNotZerodd(double noundef, double noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK8R4Matrix11HasRotationEv(ptr noundef nonnull align 8 dereferenceable(128) %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.R4Matrix, ptr %4, i32 0, i32 0
  %6 = getelementptr inbounds [4 x [4 x double]], ptr %5, i64 0, i64 0
  %7 = getelementptr inbounds [4 x double], ptr %6, i64 0, i64 1
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %10 = call noundef i32 @_Z11RNIsNotZerodd(double noundef %8, double noundef %9)
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  store i32 1, ptr %2, align 4
  br label %59

13:                                               ; preds = %1
  %14 = getelementptr inbounds %class.R4Matrix, ptr %4, i32 0, i32 0
  %15 = getelementptr inbounds [4 x [4 x double]], ptr %14, i64 0, i64 0
  %16 = getelementptr inbounds [4 x double], ptr %15, i64 0, i64 2
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %19 = call noundef i32 @_Z11RNIsNotZerodd(double noundef %17, double noundef %18)
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %13
  store i32 1, ptr %2, align 4
  br label %59

22:                                               ; preds = %13
  %23 = getelementptr inbounds %class.R4Matrix, ptr %4, i32 0, i32 0
  %24 = getelementptr inbounds [4 x [4 x double]], ptr %23, i64 0, i64 1
  %25 = getelementptr inbounds [4 x double], ptr %24, i64 0, i64 0
  %26 = load double, ptr %25, align 8, !tbaa !9
  %27 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %28 = call noundef i32 @_Z11RNIsNotZerodd(double noundef %26, double noundef %27)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %22
  store i32 1, ptr %2, align 4
  br label %59

31:                                               ; preds = %22
  %32 = getelementptr inbounds %class.R4Matrix, ptr %4, i32 0, i32 0
  %33 = getelementptr inbounds [4 x [4 x double]], ptr %32, i64 0, i64 1
  %34 = getelementptr inbounds [4 x double], ptr %33, i64 0, i64 2
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %37 = call noundef i32 @_Z11RNIsNotZerodd(double noundef %35, double noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %31
  store i32 1, ptr %2, align 4
  br label %59

40:                                               ; preds = %31
  %41 = getelementptr inbounds %class.R4Matrix, ptr %4, i32 0, i32 0
  %42 = getelementptr inbounds [4 x [4 x double]], ptr %41, i64 0, i64 2
  %43 = getelementptr inbounds [4 x double], ptr %42, i64 0, i64 0
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %46 = call noundef i32 @_Z11RNIsNotZerodd(double noundef %44, double noundef %45)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %40
  store i32 1, ptr %2, align 4
  br label %59

49:                                               ; preds = %40
  %50 = getelementptr inbounds %class.R4Matrix, ptr %4, i32 0, i32 0
  %51 = getelementptr inbounds [4 x [4 x double]], ptr %50, i64 0, i64 2
  %52 = getelementptr inbounds [4 x double], ptr %51, i64 0, i64 1
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %55 = call noundef i32 @_Z11RNIsNotZerodd(double noundef %53, double noundef %54)
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %49
  store i32 1, ptr %2, align 4
  br label %59

58:                                               ; preds = %49
  store i32 0, ptr %2, align 4
  br label %59

59:                                               ; preds = %58, %57, %48, %39, %30, %21, %12
  %60 = load i32, ptr %2, align 4
  ret i32 %60
}

attributes #0 = { 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 #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" }

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

@RN_EPSILON = external local_unnamed_addr global double, align 8

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z11RNIsNotZerodd(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK8R4Matrix11HasRotationEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(128) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %5 = tail call noundef i32 @_Z11RNIsNotZerodd(double noundef %3, double noundef %4)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %31

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %10 = tail call noundef i32 @_Z11RNIsNotZerodd(double noundef %8, double noundef %9)
  %.not1 = icmp eq i32 %10, 0
  br i1 %.not1, label %11, label %31

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %15 = tail call noundef i32 @_Z11RNIsNotZerodd(double noundef %13, double noundef %14)
  %.not2 = icmp eq i32 %15, 0
  br i1 %.not2, label %16, label %31

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %0, i64 48
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %20 = tail call noundef i32 @_Z11RNIsNotZerodd(double noundef %18, double noundef %19)
  %.not3 = icmp eq i32 %20, 0
  br i1 %.not3, label %21, label %31

21:                                               ; preds = %16
  %22 = getelementptr inbounds i8, ptr %0, i64 64
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %25 = tail call noundef i32 @_Z11RNIsNotZerodd(double noundef %23, double noundef %24)
  %.not4 = icmp eq i32 %25, 0
  br i1 %.not4, label %26, label %31

26:                                               ; preds = %21
  %27 = getelementptr inbounds i8, ptr %0, i64 72
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %30 = tail call noundef i32 @_Z11RNIsNotZerodd(double noundef %28, double noundef %29)
  %.not5 = icmp ne i32 %30, 0
  %. = zext i1 %.not5 to i32
  br label %31

31:                                               ; preds = %26, %21, %16, %11, %6, %1
  %.0 = phi i32 [ 1, %1 ], [ 1, %6 ], [ 1, %11 ], [ 1, %16 ], [ 1, %21 ], [ %., %26 ]
  ret i32 %.0
}

attributes #0 = { 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 #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" }

!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,SROAPass,SimplifyCFGPass,TailCallElimPass