; LLVM IR from ThePhysicsGuys/Physics3D :: tests/rotationTests.ll (Z38rotationImplementationIdenticalInversev)

; 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.P3D::MatrixRotationTemplate" = type { %"class.P3D::Matrix" }
%"class.P3D::Matrix" = type { [9 x double] }
%class.TolerantAssertComparer.7 = type { i32, ptr, double }
%class.TolerantAssertComparer = type { i32, ptr, double }
%"class.P3D::QuaternionRotationTemplate" = type { %"struct.P3D::Quaternion" }
%"struct.P3D::Quaternion" = type { double, %union.anon.8 }
%union.anon.8 = type { %struct.anon.9 }
%struct.anon.9 = type { double, double, double }
%struct.TolerantAssertBuilder = type { i32, double }
%class.TestInterface = type <{ i64, i8, [7 x i8] }>

@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@_ZTI14AssertionError = external dso_local constant { ptr, ptr }, align 8

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN21TolerantAssertBuilderIdEC2Eid(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, double noundef) unnamed_addr #1 align 2

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

; Function Attrs: uwtable
declare hidden noundef ptr @_ZTW15__testInterface() #2

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZN14AssertionErrorC1EiPKc(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef, ptr noundef) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN13TestInterface10markAssertEv(ptr noundef nonnull align 8 dereferenceable(9)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3P3D22MatrixRotationTemplateIdE15fromEulerAnglesEddd(ptr dead_on_unwind noalias writable sret(%"class.P3D::MatrixRotationTemplate") align 8, double noundef, double noundef, double noundef) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK21TolerantAssertBuilderIdEltIN3P3D6MatrixIdLm3ELm3EEEEE22TolerantAssertComparerIT_dERKS6_(ptr dead_on_unwind noalias writable sret(%class.TolerantAssertComparer.7) align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(72)) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK22TolerantAssertComparerIN3P3D6MatrixIdLm3ELm3EEEdEeqIS2_EES_IbdERKT_(ptr dead_on_unwind noalias writable sret(%class.TolerantAssertComparer) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(72)) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNK3P3D22MatrixRotationTemplateIdE16asRotationMatrixEv(ptr dead_on_unwind noalias writable sret(%"class.P3D::Matrix") align 8, ptr noundef nonnull align 8 dereferenceable(72)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3P3D26QuaternionRotationTemplateIdE15fromEulerAnglesEddd(ptr dead_on_unwind noalias writable sret(%"class.P3D::QuaternionRotationTemplate") align 8, double noundef, double noundef, double noundef) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3P3D26QuaternionRotationTemplateIdE16asRotationMatrixEv(ptr dead_on_unwind noalias writable sret(%"class.P3D::Matrix") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #5 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z38rotationImplementationIdenticalInversev() #5 personality ptr @__gxx_personality_v0 {
  %1 = alloca double, align 8
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca %"class.P3D::QuaternionRotationTemplate", align 8
  %6 = alloca %"class.P3D::MatrixRotationTemplate", align 8
  %7 = alloca %class.TolerantAssertComparer, align 8
  %8 = alloca %class.TolerantAssertComparer.7, align 8
  %9 = alloca %struct.TolerantAssertBuilder, align 8
  %10 = alloca %"class.P3D::Matrix", align 8
  %11 = alloca %"class.P3D::QuaternionRotationTemplate", align 8
  %12 = alloca %"class.P3D::Matrix", align 8
  %13 = alloca %"class.P3D::MatrixRotationTemplate", align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  store double 1.500000e+00, ptr %1, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %68, %0
  %17 = load double, ptr %1, align 8, !tbaa !5
  %18 = fcmp olt double %17, 1.500000e+00
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  br label %71

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store double 1.500000e+00, ptr %3, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %64, %20
  %22 = load double, ptr %3, align 8, !tbaa !5
  %23 = fcmp olt double %22, 1.500000e+00
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %67

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store double 1.500000e+00, ptr %4, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %60, %25
  %27 = load double, ptr %4, align 8, !tbaa !5
  %28 = fcmp olt double %27, 1.500000e+00
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %63

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #6
  %31 = load double, ptr %1, align 8, !tbaa !5
  %32 = load double, ptr %3, align 8, !tbaa !5
  %33 = load double, ptr %4, align 8, !tbaa !5
  call void @_ZN3P3D26QuaternionRotationTemplateIdE15fromEulerAnglesEddd(ptr dead_on_unwind writable sret(%"class.P3D::QuaternionRotationTemplate") align 8 %5, double noundef %31, double noundef %32, double noundef %33)
  call void @llvm.lifetime.start.p0(i64 72, ptr %6) #6
  %34 = load double, ptr %1, align 8, !tbaa !5
  %35 = load double, ptr %3, align 8, !tbaa !5
  %36 = load double, ptr %4, align 8, !tbaa !5
  call void @_ZN3P3D22MatrixRotationTemplateIdE15fromEulerAnglesEddd(ptr dead_on_unwind writable sret(%"class.P3D::MatrixRotationTemplate") align 8 %6, double noundef %34, double noundef %35, double noundef %36)
  br label %37

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  call void @_ZN21TolerantAssertBuilderIdEC2Eid(ptr noundef nonnull align 8 dereferenceable(16) %9, i32 noundef 210, double noundef 1.000000e-08)
  call void @llvm.lifetime.start.p0(i64 72, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #6
  call void @_ZNK3P3D26QuaternionRotationTemplateIdEcoEv(ptr dead_on_unwind writable sret(%"class.P3D::QuaternionRotationTemplate") align 8 %11, ptr noundef nonnull align 8 dereferenceable(32) %5)
  call void @_ZNK3P3D26QuaternionRotationTemplateIdE16asRotationMatrixEv(ptr dead_on_unwind writable sret(%"class.P3D::Matrix") align 8 %10, ptr noundef nonnull align 8 dereferenceable(32) %11)
  call void @_ZNK21TolerantAssertBuilderIdEltIN3P3D6MatrixIdLm3ELm3EEEEE22TolerantAssertComparerIT_dERKS6_(ptr dead_on_unwind writable sret(%class.TolerantAssertComparer.7) align 8 %8, ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(72) %10)
  call void @llvm.lifetime.start.p0(i64 72, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 72, ptr %13) #6
  call void @_ZNK3P3D22MatrixRotationTemplateIdEcoEv(ptr dead_on_unwind writable sret(%"class.P3D::MatrixRotationTemplate") align 8 %13, ptr noundef nonnull align 8 dereferenceable(72) %6)
  call void @_ZNK3P3D22MatrixRotationTemplateIdE16asRotationMatrixEv(ptr dead_on_unwind writable sret(%"class.P3D::Matrix") align 8 %12, ptr noundef nonnull align 8 dereferenceable(72) %13)
  call void @_ZNK22TolerantAssertComparerIN3P3D6MatrixIdLm3ELm3EEEdEeqIS2_EES_IbdERKT_(ptr dead_on_unwind writable sret(%class.TolerantAssertComparer) align 8 %7, ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(72) %12)
  %38 = getelementptr inbounds %class.TolerantAssertComparer, ptr %7, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = load i8, ptr %39, align 1, !tbaa !13, !range !15, !noundef !16
  %41 = trunc i8 %40 to i1
  %42 = xor i1 %41, true
  call void @llvm.lifetime.end.p0(i64 72, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 72, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 72, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #6
  br i1 %42, label %43, label %56

43:                                               ; preds = %37
  %44 = call ptr @_ZTW15__testInterface()
  %45 = getelementptr inbounds %class.TestInterface, ptr %44, i32 0, i32 1
  %46 = load i8, ptr %45, align 8, !tbaa !17, !range !15, !noundef !16
  %47 = trunc i8 %46 to i1
  br i1 %47, label %48, label %49

48:                                               ; preds = %43
  br label %49

49:                                               ; preds = %48, %43
  %50 = call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZN14AssertionErrorC1EiPKc(ptr noundef nonnull align 8 dereferenceable(12) %50, i32 noundef 210, ptr noundef @.str.3)
          to label %51 unwind label %52

51:                                               ; preds = %49
  call void @__cxa_throw(ptr %50, ptr @_ZTI14AssertionError, ptr null) #7
  unreachable

52:                                               ; preds = %49
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %14, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %15, align 4
  call void @__cxa_free_exception(ptr %50) #6
  call void @llvm.lifetime.end.p0(i64 72, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  br label %72

56:                                               ; preds = %37
  %57 = call ptr @_ZTW15__testInterface()
  call void @_ZN13TestInterface10markAssertEv(ptr noundef nonnull align 8 dereferenceable(9) %57)
  br label %58

58:                                               ; preds = %56
  br label %59

59:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 72, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #6
  br label %60

60:                                               ; preds = %59
  %61 = load double, ptr %4, align 8, !tbaa !5
  %62 = fadd double %61, 5.000000e-01
  store double %62, ptr %4, align 8, !tbaa !5
  br label %26, !llvm.loop !20

63:                                               ; preds = %29
  br label %64

64:                                               ; preds = %63
  %65 = load double, ptr %3, align 8, !tbaa !5
  %66 = fadd double %65, 5.000000e-01
  store double %66, ptr %3, align 8, !tbaa !5
  br label %21, !llvm.loop !22

67:                                               ; preds = %24
  br label %68

68:                                               ; preds = %67
  %69 = load double, ptr %1, align 8, !tbaa !5
  %70 = fadd double %69, 5.000000e-01
  store double %70, ptr %1, align 8, !tbaa !5
  br label %16, !llvm.loop !23

71:                                               ; preds = %19
  ret void

72:                                               ; preds = %52
  %73 = load ptr, ptr %14, align 8
  %74 = load i32, ptr %15, align 4
  %75 = insertvalue { ptr, i32 } poison, ptr %73, 0
  %76 = insertvalue { ptr, i32 } %75, i32 %74, 1
  resume { ptr, i32 } %76
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3P3D26QuaternionRotationTemplateIdEcoEv(ptr dead_on_unwind noalias writable sret(%"class.P3D::QuaternionRotationTemplate") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3P3D22MatrixRotationTemplateIdEcoEv(ptr dead_on_unwind noalias writable sret(%"class.P3D::MatrixRotationTemplate") align 8, ptr noundef nonnull align 8 dereferenceable(72)) #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { uwtable "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 = { "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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn }

!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"}
!9 = !{!10, !12, i64 8}
!10 = !{!"_ZTS22TolerantAssertComparerIbdE", !11, i64 0, !12, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !14, i64 8}
!18 = !{!"_ZTS13TestInterface", !19, i64 0, !14, i64 8}
!19 = !{!"long", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local void @_Z38rotationImplementationIdenticalInversev() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  ret void
}

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


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