; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_Vec3d)

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

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_set(ptr noundef, double noundef, double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_getPolarAxis(ptr noundef, double noundef, double noundef) #1

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

30:                                               ; preds = %3
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds double, ptr %31, i64 0
  store double 0.000000e+00, ptr %32, align 8, !tbaa !9
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds double, ptr %33, i64 1
  store double 0.000000e+00, ptr %34, align 8, !tbaa !9
  store i32 1, ptr %10, align 4
  br label %68

35:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 72, ptr %11) #3
  %36 = getelementptr inbounds [3 x [3 x double]], ptr %11, i64 0, i64 2
  %37 = getelementptr inbounds [3 x double], ptr %36, i64 0, i64 0
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  call void @Vec3d_copy(ptr noundef %37, ptr noundef %38)
  %39 = getelementptr inbounds [3 x [3 x double]], ptr %11, i64 0, i64 1
  %40 = getelementptr inbounds [3 x double], ptr %39, i64 0, i64 0
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds [3 x double], ptr %8, i64 0, i64 0
  call void @Vec3d_crossProduct(ptr noundef %40, ptr noundef %41, ptr noundef %42)
  %43 = getelementptr inbounds [3 x [3 x double]], ptr %11, i64 0, i64 1
  %44 = getelementptr inbounds [3 x double], ptr %43, i64 0, i64 0
  %45 = call double @Vec3d_normalizeSelf(ptr noundef %44)
  %46 = getelementptr inbounds [3 x [3 x double]], ptr %11, i64 0, i64 0
  %47 = getelementptr inbounds [3 x double], ptr %46, i64 0, i64 0
  %48 = getelementptr inbounds [3 x [3 x double]], ptr %11, i64 0, i64 1
  %49 = getelementptr inbounds [3 x double], ptr %48, i64 0, i64 0
  %50 = getelementptr inbounds [3 x [3 x double]], ptr %11, i64 0, i64 2
  %51 = getelementptr inbounds [3 x double], ptr %50, i64 0, i64 0
  call void @Vec3d_crossProduct(ptr noundef %47, ptr noundef %49, ptr noundef %51)
  call void @llvm.lifetime.start.p0(i64 72, ptr %12) #3
  %52 = getelementptr inbounds [3 x [3 x double]], ptr %12, i64 0, i64 0
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds [3 x [3 x double]], ptr %11, i64 0, i64 0
  call void @Mat3d_mulTranspose(ptr noundef %52, ptr noundef %53, ptr noundef %54)
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  %55 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %56 = load double, ptr %7, align 8, !tbaa !9
  call void @Vec3d_set(ptr noundef %55, double noundef 0.000000e+00, double noundef %56, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #3
  %57 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %58 = getelementptr inbounds [3 x [3 x double]], ptr %12, i64 0, i64 0
  %59 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  call void @Vec3d_rotate(ptr noundef %57, ptr noundef %58, ptr noundef %59)
  %60 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 0
  %61 = load double, ptr %60, align 16, !tbaa !9
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds double, ptr %62, i64 0
  store double %61, ptr %63, align 8, !tbaa !9
  %64 = getelementptr inbounds [3 x double], ptr %14, i64 0, i64 1
  %65 = load double, ptr %64, align 8, !tbaa !9
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds double, ptr %66, i64 1
  store double %65, ptr %67, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr %11) #3
  store i32 0, ptr %10, align 4
  br label %68

68:                                               ; preds = %35, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %69 = load i32, ptr %10, align 4
  switch i32 %69, label %71 [
    i32 0, label %70
    i32 1, label %70
  ]

70:                                               ; preds = %68, %68
  ret void

71:                                               ; preds = %68
  unreachable
}

; Function Attrs: nounwind uwtable
declare dso_local double @Vec3d_diffAngle(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_copy(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_crossProduct(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local double @Vec3d_normalizeSelf(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_rotate(ptr noundef, ptr noundef, ptr noundef) #1

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

!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: 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: nounwind uwtable
declare dso_local void @Vec3d_set(ptr noundef, double noundef, double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_getPolarAxis(ptr noundef, double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @Vec3d_getPolarError(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca [3 x double], align 16
  %5 = alloca [3 x [3 x double]], align 16
  %6 = alloca [3 x [3 x double]], align 16
  %7 = alloca [3 x double], align 16
  %8 = alloca [3 x double], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  %9 = getelementptr inbounds i8, ptr %2, i64 48
  %10 = load double, ptr %1, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !5
  call void @Vec3d_getPolarAxis(ptr noundef nonnull %4, double noundef %10, double noundef %12)
  %13 = call double @Vec3d_diffAngle(ptr noundef nonnull %9, ptr noundef nonnull %4)
  %14 = fcmp oeq double %13, 0.000000e+00
  br i1 %14, label %20, label %15

15:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %5) #3
  %16 = getelementptr inbounds i8, ptr %5, i64 48
  call void @Vec3d_copy(ptr noundef nonnull %16, ptr noundef nonnull %9)
  %17 = getelementptr inbounds i8, ptr %5, i64 24
  call void @Vec3d_crossProduct(ptr noundef nonnull %17, ptr noundef nonnull %9, ptr noundef nonnull %4)
  %18 = call double @Vec3d_normalizeSelf(ptr noundef nonnull %17)
  call void @Vec3d_crossProduct(ptr noundef nonnull %5, ptr noundef nonnull %17, ptr noundef nonnull %16)
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %6) #3
  call void @Mat3d_mulTranspose(ptr noundef nonnull %6, ptr noundef %2, ptr noundef nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  call void @Vec3d_set(ptr noundef nonnull %7, double noundef 0.000000e+00, double noundef %13, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #3
  call void @Vec3d_rotate(ptr noundef nonnull %8, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %19 = load <2 x double>, ptr %8, align 16, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %5) #3
  br label %20

20:                                               ; preds = %3, %15
  %21 = phi <2 x double> [ %19, %15 ], [ zeroinitializer, %3 ]
  store <2 x double> %21, ptr %0, align 8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local double @Vec3d_diffAngle(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_copy(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_crossProduct(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local double @Vec3d_normalizeSelf(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @Vec3d_rotate(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 }

!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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass