; LLVM IR from HRI-EU/Rcs :: external (Rcs_thirdPartyMath)

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

; Function Attrs: nounwind uwtable
define dso_local void @Mat3d_setRandomRotation(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca [3 x double], align 16
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store double 0x401921FB54442D18, ptr %7, align 8, !tbaa !9
  %16 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  call void @Vec3d_setRandom(ptr noundef %16, double noundef 0.000000e+00, double noundef 1.000000e+00)
  %17 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  %18 = load double, ptr %17, align 16, !tbaa !9
  %19 = fmul double %18, 0x401921FB54442D18
  store double %19, ptr %4, align 8, !tbaa !9
  %20 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 1
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = fmul double %21, 0x401921FB54442D18
  store double %22, ptr %3, align 8, !tbaa !9
  %23 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 2
  %24 = load double, ptr %23, align 16, !tbaa !9
  %25 = fmul double %24, 2.000000e+00
  store double %25, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = call double @sqrt(double noundef %26) #5
  store double %27, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %28 = load double, ptr %3, align 8, !tbaa !9
  %29 = call double @sin(double noundef %28) #5
  %30 = load double, ptr %8, align 8, !tbaa !9
  %31 = fmul double %29, %30
  store double %31, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %32 = load double, ptr %3, align 8, !tbaa !9
  %33 = call double @cos(double noundef %32) #5
  %34 = load double, ptr %8, align 8, !tbaa !9
  %35 = fmul double %33, %34
  store double %35, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %36 = load double, ptr %5, align 8, !tbaa !9
  %37 = fsub double 2.000000e+00, %36
  %38 = call double @sqrt(double noundef %37) #5
  store double %38, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %39 = load double, ptr %4, align 8, !tbaa !9
  %40 = call double @sin(double noundef %39) #5
  store double %40, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %41 = load double, ptr %4, align 8, !tbaa !9
  %42 = call double @cos(double noundef %41) #5
  store double %42, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %43 = load double, ptr %9, align 8, !tbaa !9
  %44 = load double, ptr %13, align 8, !tbaa !9
  %45 = load double, ptr %10, align 8, !tbaa !9
  %46 = load double, ptr %12, align 8, !tbaa !9
  %47 = fmul double %45, %46
  %48 = fneg double %47
  %49 = call double @llvm.fmuladd.f64(double %43, double %44, double %48)
  store double %49, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %50 = load double, ptr %9, align 8, !tbaa !9
  %51 = load double, ptr %12, align 8, !tbaa !9
  %52 = load double, ptr %10, align 8, !tbaa !9
  %53 = load double, ptr %13, align 8, !tbaa !9
  %54 = fmul double %52, %53
  %55 = call double @llvm.fmuladd.f64(double %50, double %51, double %54)
  store double %55, ptr %15, align 8, !tbaa !9
  %56 = load double, ptr %9, align 8, !tbaa !9
  %57 = load double, ptr %14, align 8, !tbaa !9
  %58 = load double, ptr %13, align 8, !tbaa !9
  %59 = fneg double %58
  %60 = call double @llvm.fmuladd.f64(double %56, double %57, double %59)
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds [3 x double], ptr %61, i64 0
  %63 = getelementptr inbounds [3 x double], ptr %62, i64 0, i64 0
  store double %60, ptr %63, align 8, !tbaa !9
  %64 = load double, ptr %9, align 8, !tbaa !9
  %65 = load double, ptr %15, align 8, !tbaa !9
  %66 = load double, ptr %12, align 8, !tbaa !9
  %67 = fneg double %66
  %68 = call double @llvm.fmuladd.f64(double %64, double %65, double %67)
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds [3 x double], ptr %69, i64 0
  %71 = getelementptr inbounds [3 x double], ptr %70, i64 0, i64 1
  store double %68, ptr %71, align 8, !tbaa !9
  %72 = load double, ptr %9, align 8, !tbaa !9
  %73 = load double, ptr %11, align 8, !tbaa !9
  %74 = fmul double %72, %73
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds [3 x double], ptr %75, i64 0
  %77 = getelementptr inbounds [3 x double], ptr %76, i64 0, i64 2
  store double %74, ptr %77, align 8, !tbaa !9
  %78 = load double, ptr %10, align 8, !tbaa !9
  %79 = load double, ptr %14, align 8, !tbaa !9
  %80 = load double, ptr %12, align 8, !tbaa !9
  %81 = call double @llvm.fmuladd.f64(double %78, double %79, double %80)
  %82 = load ptr, ptr %2, align 8, !tbaa !5
  %83 = getelementptr inbounds [3 x double], ptr %82, i64 1
  %84 = getelementptr inbounds [3 x double], ptr %83, i64 0, i64 0
  store double %81, ptr %84, align 8, !tbaa !9
  %85 = load double, ptr %10, align 8, !tbaa !9
  %86 = load double, ptr %15, align 8, !tbaa !9
  %87 = load double, ptr %13, align 8, !tbaa !9
  %88 = fneg double %87
  %89 = call double @llvm.fmuladd.f64(double %85, double %86, double %88)
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds [3 x double], ptr %90, i64 1
  %92 = getelementptr inbounds [3 x double], ptr %91, i64 0, i64 1
  store double %89, ptr %92, align 8, !tbaa !9
  %93 = load double, ptr %10, align 8, !tbaa !9
  %94 = load double, ptr %11, align 8, !tbaa !9
  %95 = fmul double %93, %94
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds [3 x double], ptr %96, i64 1
  %98 = getelementptr inbounds [3 x double], ptr %97, i64 0, i64 2
  store double %95, ptr %98, align 8, !tbaa !9
  %99 = load double, ptr %11, align 8, !tbaa !9
  %100 = load double, ptr %14, align 8, !tbaa !9
  %101 = fmul double %99, %100
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  %103 = getelementptr inbounds [3 x double], ptr %102, i64 2
  %104 = getelementptr inbounds [3 x double], ptr %103, i64 0, i64 0
  store double %101, ptr %104, align 8, !tbaa !9
  %105 = load double, ptr %11, align 8, !tbaa !9
  %106 = load double, ptr %15, align 8, !tbaa !9
  %107 = fmul double %105, %106
  %108 = load ptr, ptr %2, align 8, !tbaa !5
  %109 = getelementptr inbounds [3 x double], ptr %108, i64 2
  %110 = getelementptr inbounds [3 x double], ptr %109, i64 0, i64 1
  store double %107, ptr %110, align 8, !tbaa !9
  %111 = load double, ptr %5, align 8, !tbaa !9
  %112 = fsub double 1.000000e+00, %111
  %113 = load ptr, ptr %2, align 8, !tbaa !5
  %114 = getelementptr inbounds [3 x double], ptr %113, i64 2
  %115 = getelementptr inbounds [3 x double], ptr %114, i64 0, i64 2
  store double %112, ptr %115, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

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

declare void @Vec3d_setRandom(ptr noundef, double noundef, double noundef) #2

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

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

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

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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/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: nounwind uwtable
define dso_local void @Mat3d_setRandomRotation(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
  %2 = alloca [3 x double], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #5
  call void @Vec3d_setRandom(ptr noundef nonnull %2, double noundef 0.000000e+00, double noundef 1.000000e+00) #5
  %3 = load double, ptr %2, align 16, !tbaa !5
  %4 = fmul double %3, 0x401921FB54442D18
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fmul double %6, 0x401921FB54442D18
  %8 = getelementptr inbounds i8, ptr %2, i64 16
  %9 = load double, ptr %8, align 16, !tbaa !5
  %10 = fmul double %9, 2.000000e+00
  %11 = call double @sqrt(double noundef %10) #5
  %12 = call double @sin(double noundef %7) #5
  %13 = fmul double %11, %12
  %14 = call double @cos(double noundef %7) #5
  %15 = fmul double %11, %14
  %16 = fsub double 2.000000e+00, %10
  %17 = call double @sqrt(double noundef %16) #5
  %18 = call double @sin(double noundef %4) #5
  %19 = call double @cos(double noundef %4) #5
  %20 = fneg double %15
  %21 = insertelement <2 x double> poison, double %18, i64 0
  %22 = insertelement <2 x double> %21, double %15, i64 1
  %23 = insertelement <2 x double> poison, double %20, i64 0
  %24 = insertelement <2 x double> %23, double %19, i64 1
  %25 = fmul <2 x double> %22, %24
  %26 = insertelement <2 x double> poison, double %13, i64 0
  %27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
  %28 = shufflevector <2 x double> %24, <2 x double> %21, <2 x i32> <i32 1, i32 2>
  %29 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %28, <2 x double> %25)
  %30 = fneg <2 x double> %28
  %31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %29, <2 x double> %30)
  store <2 x double> %31, ptr %0, align 8, !tbaa !5
  %32 = fmul double %13, %17
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  store double %32, ptr %33, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %0, i64 24
  %35 = insertelement <2 x double> poison, double %15, i64 0
  %36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> zeroinitializer
  %37 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> <i32 poison, i32 0>
  %38 = insertelement <2 x double> %37, double %18, i64 0
  %39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %29, <2 x double> %38)
  store <2 x double> %39, ptr %34, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %0, i64 40
  %41 = shufflevector <2 x double> %35, <2 x double> %29, <2 x i32> <i32 0, i32 2>
  %42 = insertelement <2 x double> poison, double %17, i64 0
  %43 = shufflevector <2 x double> %42, <2 x double> poison, <2 x i32> zeroinitializer
  %44 = fmul <2 x double> %41, %43
  store <2 x double> %44, ptr %40, align 8, !tbaa !5
  %45 = extractelement <2 x double> %29, i64 1
  %46 = fmul double %17, %45
  %47 = getelementptr inbounds i8, ptr %0, i64 56
  store double %46, ptr %47, align 8, !tbaa !5
  %48 = fsub double 1.000000e+00, %10
  %49 = getelementptr inbounds i8, ptr %0, i64 64
  store double %48, ptr %49, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  ret void
}

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

declare void @Vec3d_setRandom(ptr noundef, double noundef, double noundef) local_unnamed_addr #2

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

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

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

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass