; 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: 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

declare double @Vec3d_normalizeSelf(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Mat3d_orthonormalizeSelf(ptr noundef %0) #3 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca [3 x double], align 16
  %6 = alloca [3 x double], align 16
  %7 = alloca [3 x double], align 16
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %12 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds [3 x double], ptr %13, i64 0
  %15 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  call void @Vec3d_copy(ptr noundef %12, ptr noundef %15)
  %16 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds [3 x double], ptr %17, i64 1
  %19 = getelementptr inbounds [3 x double], ptr %18, i64 0, i64 0
  call void @Vec3d_copy(ptr noundef %16, ptr noundef %19)
  %20 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 0
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds [3 x double], ptr %21, i64 2
  %23 = getelementptr inbounds [3 x double], ptr %22, i64 0, i64 0
  call void @Vec3d_copy(ptr noundef %20, ptr noundef %23)
  %24 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %25 = call double @Vec3d_normalizeSelf(ptr noundef %24)
  store double %25, ptr %10, align 8, !tbaa !9
  %26 = load double, ptr %10, align 8, !tbaa !9
  %27 = fcmp oeq double %26, 0.000000e+00
  br i1 %27, label %28, label %29

28:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %11, align 4
  br label %107

29:                                               ; preds = %1
  %30 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %31 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  %32 = call double @Vec3d_innerProduct(ptr noundef %30, ptr noundef %31)
  store double %32, ptr %8, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %33

33:                                               ; preds = %48, %29
  %34 = load i32, ptr %4, align 4, !tbaa !11
  %35 = icmp slt i32 %34, 3
  br i1 %35, label %36, label %51

36:                                               ; preds = %33
  %37 = load double, ptr %8, align 8, !tbaa !9
  %38 = load i32, ptr %4, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = load i32, ptr %4, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = fneg double %37
  %47 = call double @llvm.fmuladd.f64(double %46, double %41, double %45)
  store double %47, ptr %44, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %36
  %49 = load i32, ptr %4, align 4, !tbaa !11
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %4, align 4, !tbaa !11
  br label %33, !llvm.loop !13

51:                                               ; preds = %33
  %52 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  %53 = call double @Vec3d_normalizeSelf(ptr noundef %52)
  store double %53, ptr %10, align 8, !tbaa !9
  %54 = load double, ptr %10, align 8, !tbaa !9
  %55 = fcmp oeq double %54, 0.000000e+00
  br i1 %55, label %56, label %57

56:                                               ; preds = %51
  store i1 false, ptr %2, align 1
  store i32 1, ptr %11, align 4
  br label %107

57:                                               ; preds = %51
  %58 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  %59 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 0
  %60 = call double @Vec3d_innerProduct(ptr noundef %58, ptr noundef %59)
  store double %60, ptr %9, align 8, !tbaa !9
  %61 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  %62 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 0
  %63 = call double @Vec3d_innerProduct(ptr noundef %61, ptr noundef %62)
  store double %63, ptr %8, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %64

64:                                               ; preds = %85, %57
  %65 = load i32, ptr %4, align 4, !tbaa !11
  %66 = icmp slt i32 %65, 3
  br i1 %66, label %67, label %88

67:                                               ; preds = %64
  %68 = load double, ptr %8, align 8, !tbaa !9
  %69 = load i32, ptr %4, align 4, !tbaa !11
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !9
  %73 = load double, ptr %9, align 8, !tbaa !9
  %74 = load i32, ptr %4, align 4, !tbaa !11
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = fmul double %73, %77
  %79 = call double @llvm.fmuladd.f64(double %68, double %72, double %78)
  %80 = load i32, ptr %4, align 4, !tbaa !11
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 %81
  %83 = load double, ptr %82, align 8, !tbaa !9
  %84 = fsub double %83, %79
  store double %84, ptr %82, align 8, !tbaa !9
  br label %85

85:                                               ; preds = %67
  %86 = load i32, ptr %4, align 4, !tbaa !11
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %4, align 4, !tbaa !11
  br label %64, !llvm.loop !15

88:                                               ; preds = %64
  %89 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 0
  %90 = call double @Vec3d_normalizeSelf(ptr noundef %89)
  store double %90, ptr %10, align 8, !tbaa !9
  %91 = load double, ptr %10, align 8, !tbaa !9
  %92 = fcmp oeq double %91, 0.000000e+00
  br i1 %92, label %93, label %94

93:                                               ; preds = %88
  store i1 false, ptr %2, align 1
  store i32 1, ptr %11, align 4
  br label %107

94:                                               ; preds = %88
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds [3 x double], ptr %95, i64 0
  %97 = getelementptr inbounds [3 x double], ptr %96, i64 0, i64 0
  %98 = getelementptr inbounds [3 x double], ptr %5, i64 0, i64 0
  call void @Vec3d_copy(ptr noundef %97, ptr noundef %98)
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds [3 x double], ptr %99, i64 1
  %101 = getelementptr inbounds [3 x double], ptr %100, i64 0, i64 0
  %102 = getelementptr inbounds [3 x double], ptr %6, i64 0, i64 0
  call void @Vec3d_copy(ptr noundef %101, ptr noundef %102)
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds [3 x double], ptr %103, i64 2
  %105 = getelementptr inbounds [3 x double], ptr %104, i64 0, i64 0
  %106 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 0
  call void @Vec3d_copy(ptr noundef %105, ptr noundef %106)
  store i1 true, ptr %2, align 1
  store i32 1, ptr %11, align 4
  br label %107

107:                                              ; preds = %94, %93, %56, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %108 = load i1, ptr %2, align 1
  ret i1 %108
}

declare void @Vec3d_copy(ptr noundef, ptr noundef) #2

declare double @Vec3d_innerProduct(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare double @Vec3d_normalizeSelf(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @Mat3d_orthonormalizeSelf(ptr noundef %0) local_unnamed_addr #3 {
  %2 = alloca [3 x double], align 16
  %3 = alloca [3 x double], align 16
  %4 = alloca [3 x double], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  call void @Vec3d_copy(ptr noundef nonnull %2, ptr noundef %0) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  call void @Vec3d_copy(ptr noundef nonnull %3, ptr noundef nonnull %5) #5
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  call void @Vec3d_copy(ptr noundef nonnull %4, ptr noundef nonnull %6) #5
  %7 = call double @Vec3d_normalizeSelf(ptr noundef nonnull %2) #5
  %8 = fcmp oeq double %7, 0.000000e+00
  br i1 %8, label %47, label %9

9:                                                ; preds = %1
  %10 = call double @Vec3d_innerProduct(ptr noundef nonnull %2, ptr noundef nonnull %3) #5
  %11 = fneg double %10
  %12 = load <2 x double>, ptr %2, align 16, !tbaa !5
  %13 = load <2 x double>, ptr %3, align 16, !tbaa !5
  %14 = insertelement <2 x double> poison, double %11, i64 0
  %15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
  %16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %12, <2 x double> %13)
  store <2 x double> %16, ptr %3, align 16, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %2, i64 16
  %18 = load double, ptr %17, align 16, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %3, i64 16
  %20 = load double, ptr %19, align 16, !tbaa !5
  %21 = call double @llvm.fmuladd.f64(double %11, double %18, double %20)
  store double %21, ptr %19, align 16, !tbaa !5
  %22 = call double @Vec3d_normalizeSelf(ptr noundef nonnull %3) #5
  %23 = fcmp oeq double %22, 0.000000e+00
  br i1 %23, label %47, label %24

24:                                               ; preds = %9
  %25 = call double @Vec3d_innerProduct(ptr noundef nonnull %3, ptr noundef nonnull %4) #5
  %26 = call double @Vec3d_innerProduct(ptr noundef nonnull %2, ptr noundef nonnull %4) #5
  %27 = load <2 x double>, ptr %2, align 16, !tbaa !5
  %28 = load <2 x double>, ptr %3, align 16, !tbaa !5
  %29 = insertelement <2 x double> poison, double %25, i64 0
  %30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
  %31 = fmul <2 x double> %30, %28
  %32 = insertelement <2 x double> poison, double %26, i64 0
  %33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
  %34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %27, <2 x double> %31)
  %35 = load <2 x double>, ptr %4, align 16, !tbaa !5
  %36 = fsub <2 x double> %35, %34
  store <2 x double> %36, ptr %4, align 16, !tbaa !5
  %37 = load double, ptr %17, align 16, !tbaa !5
  %38 = load double, ptr %19, align 16, !tbaa !5
  %39 = fmul double %25, %38
  %40 = call double @llvm.fmuladd.f64(double %26, double %37, double %39)
  %41 = getelementptr inbounds i8, ptr %4, i64 16
  %42 = load double, ptr %41, align 16, !tbaa !5
  %43 = fsub double %42, %40
  store double %43, ptr %41, align 16, !tbaa !5
  %44 = call double @Vec3d_normalizeSelf(ptr noundef nonnull %4) #5
  %45 = fcmp oeq double %44, 0.000000e+00
  br i1 %45, label %47, label %46

46:                                               ; preds = %24
  call void @Vec3d_copy(ptr noundef %0, ptr noundef nonnull %2) #5
  call void @Vec3d_copy(ptr noundef nonnull %5, ptr noundef nonnull %3) #5
  call void @Vec3d_copy(ptr noundef nonnull %6, ptr noundef nonnull %4) #5
  br label %47

47:                                               ; preds = %24, %9, %1, %46
  %.0 = phi i1 [ true, %46 ], [ false, %1 ], [ false, %9 ], [ false, %24 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  ret i1 %.0
}

declare void @Vec3d_copy(ptr noundef, ptr noundef) local_unnamed_addr #2

declare double @Vec3d_innerProduct(ptr noundef, ptr noundef) local_unnamed_addr #2

; 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 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 #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,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass