; LLVM IR from nubot-nudt/simatch :: src/auto_referee/src/Quaternion.ll (ZN6gazebo4math10Quaternion6GetYawEv)

; 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.gazebo::math::Quaternion" = type { double, double, double, double }

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6gazebo4math10Quaternion9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN6gazebo4math10Quaternion6GetYawEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.gazebo::math::Quaternion", align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %11 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #4
  call void @_ZN6gazebo4math10QuaternionC1ERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) %11)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  invoke void @_ZN6gazebo4math10Quaternion9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(32) %3)
          to label %12 unwind label %53

12:                                               ; preds = %1
  %13 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 0
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 0
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = fmul double %14, %16
  store double %17, ptr %4, align 8, !tbaa !12
  %18 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 1
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 1
  %21 = load double, ptr %20, align 8, !tbaa !13
  %22 = fmul double %19, %21
  store double %22, ptr %5, align 8, !tbaa !12
  %23 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 2
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 2
  %26 = load double, ptr %25, align 8, !tbaa !14
  %27 = fmul double %24, %26
  store double %27, ptr %6, align 8, !tbaa !12
  %28 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 3
  %29 = load double, ptr %28, align 8, !tbaa !15
  %30 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 3
  %31 = load double, ptr %30, align 8, !tbaa !15
  %32 = fmul double %29, %31
  store double %32, ptr %7, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %33 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 1
  %34 = load double, ptr %33, align 8, !tbaa !13
  %35 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 2
  %36 = load double, ptr %35, align 8, !tbaa !14
  %37 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 0
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds %"class.gazebo::math::Quaternion", ptr %3, i32 0, i32 3
  %40 = load double, ptr %39, align 8, !tbaa !15
  %41 = fmul double %38, %40
  %42 = call double @llvm.fmuladd.f64(double %34, double %36, double %41)
  %43 = fmul double 2.000000e+00, %42
  %44 = load double, ptr %4, align 8, !tbaa !12
  %45 = load double, ptr %5, align 8, !tbaa !12
  %46 = fadd double %44, %45
  %47 = load double, ptr %6, align 8, !tbaa !12
  %48 = fsub double %46, %47
  %49 = load double, ptr %7, align 8, !tbaa !12
  %50 = fsub double %48, %49
  %51 = call double @atan2(double noundef %43, double noundef %50) #4
  store double %51, ptr %10, align 8, !tbaa !12
  %52 = load double, ptr %10, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @_ZN6gazebo4math10QuaternionD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #4
  ret double %52

53:                                               ; preds = %1
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %8, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @_ZN6gazebo4math10QuaternionD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #4
  br label %57

57:                                               ; preds = %53
  %58 = load ptr, ptr %8, align 8
  %59 = load i32, ptr %9, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61
}

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare double @atan2(double noundef, double noundef) #3

declare void @_ZN6gazebo4math10QuaternionC1ERKS1_(ptr, ptr)

declare void @_ZN6gazebo4math10QuaternionD1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { nounwind "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, !11, i64 0}
!10 = !{!"_ZTSN6gazebo4math10QuaternionE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!11 = !{!"double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !11, i64 16}
!15 = !{!10, !11, i64 24}


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

%"class.gazebo::math::Quaternion" = type { double, double, double, double }

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6gazebo4math10Quaternion9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN6gazebo4math10Quaternion6GetYawEv(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.gazebo::math::Quaternion", align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #4
  call void @_ZN6gazebo4math10QuaternionC1ERKS1_(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %0)
  invoke void @_ZN6gazebo4math10Quaternion9NormalizeEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
          to label %3 unwind label %20

3:                                                ; preds = %1
  %4 = load <2 x double>, ptr %2, align 16, !tbaa !5
  %5 = fmul <2 x double> %4, %4
  %6 = getelementptr inbounds i8, ptr %2, i64 16
  %7 = load <2 x double>, ptr %6, align 16, !tbaa !5
  %8 = fmul <2 x double> %7, %7
  %shift = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %9 = fmul <2 x double> %4, %shift
  %10 = extractelement <2 x double> %9, i64 0
  %11 = extractelement <2 x double> %7, i64 0
  %12 = extractelement <2 x double> %4, i64 1
  %13 = call double @llvm.fmuladd.f64(double %12, double %11, double %10)
  %14 = fmul double %13, 2.000000e+00
  %shift7 = shufflevector <2 x double> %5, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %15 = fadd <2 x double> %5, %shift7
  %16 = fsub <2 x double> %15, %8
  %shift8 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %17 = fsub <2 x double> %16, %shift8
  %18 = extractelement <2 x double> %17, i64 0
  %19 = call double @atan2(double noundef %14, double noundef %18) #4
  call void @_ZN6gazebo4math10QuaternionD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %2) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #4
  ret double %19

20:                                               ; preds = %1
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN6gazebo4math10QuaternionD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %2) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #4
  resume { ptr, i32 } %21
}

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #3

declare void @_ZN6gazebo4math10QuaternionC1ERKS1_(ptr, ptr) local_unnamed_addr

declare void @_ZN6gazebo4math10QuaternionD1Ev(ptr) local_unnamed_addr

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,VectorCombinePass