; 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_rotate(ptr noundef, ptr noundef, ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Vec3d_computePlaneLineIntersection(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca [3 x [3 x double]], align 16
  %15 = alloca [3 x [3 x double]], align 16
  %16 = alloca [3 x double], align 16
  %17 = alloca [3 x double], align 16
  %18 = alloca [3 x [3 x double]], align 16
  %19 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 72, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 72, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 72, ptr %18) #3
  %20 = getelementptr inbounds [3 x [3 x double]], ptr %18, i64 0, i64 0
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  call void @Mat3d_fromVec(ptr noundef %20, ptr noundef %21, i32 noundef 2)
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %54, %5
  %23 = load i32, ptr %12, align 4, !tbaa !9
  %24 = icmp slt i32 %23, 3
  br i1 %24, label %25, label %57

25:                                               ; preds = %22
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds double, ptr %26, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = fneg double %30
  %32 = load i32, ptr %12, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [3 x [3 x double]], ptr %14, i64 0, i64 %33
  %35 = getelementptr inbounds [3 x double], ptr %34, i64 0, i64 0
  store double %31, ptr %35, align 8, !tbaa !11
  %36 = getelementptr inbounds [3 x [3 x double]], ptr %18, i64 0, i64 0
  %37 = load i32, ptr %12, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [3 x double], ptr %36, i64 0, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [3 x [3 x double]], ptr %14, i64 0, i64 %42
  %44 = getelementptr inbounds [3 x double], ptr %43, i64 0, i64 1
  store double %40, ptr %44, align 8, !tbaa !11
  %45 = getelementptr inbounds [3 x [3 x double]], ptr %18, i64 0, i64 1
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [3 x double], ptr %45, i64 0, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = load i32, ptr %12, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [3 x [3 x double]], ptr %14, i64 0, i64 %51
  %53 = getelementptr inbounds [3 x double], ptr %52, i64 0, i64 2
  store double %49, ptr %53, align 8, !tbaa !11
  br label %54

54:                                               ; preds = %25
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %12, align 4, !tbaa !9
  br label %22, !llvm.loop !13

57:                                               ; preds = %22
  %58 = getelementptr inbounds [3 x [3 x double]], ptr %15, i64 0, i64 0
  %59 = getelementptr inbounds [3 x [3 x double]], ptr %14, i64 0, i64 0
  %60 = call double @Mat3d_inverse(ptr noundef %58, ptr noundef %59)
  store double %60, ptr %13, align 8, !tbaa !11
  %61 = load double, ptr %13, align 8, !tbaa !11
  %62 = fcmp oeq double %61, 0.000000e+00
  br i1 %62, label %63, label %64

63:                                               ; preds = %57
  store i1 false, ptr %6, align 1
  store i32 1, ptr %19, align 4
  br label %76

64:                                               ; preds = %57
  %65 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 0
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  call void @Vec3d_sub(ptr noundef %65, ptr noundef %66, ptr noundef %67)
  %68 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 0
  %69 = getelementptr inbounds [3 x [3 x double]], ptr %15, i64 0, i64 0
  %70 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 0
  call void @Vec3d_rotate(ptr noundef %68, ptr noundef %69, ptr noundef %70)
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds [3 x double], ptr %16, i64 0, i64 0
  %75 = load double, ptr %74, align 16, !tbaa !11
  call void @Vec3d_constMulAndAdd(ptr noundef %71, ptr noundef %72, ptr noundef %73, double noundef %75)
  store i1 true, ptr %6, align 1
  store i32 1, ptr %19, align 4
  br label %76

76:                                               ; preds = %64, %63
  call void @llvm.lifetime.end.p0(i64 72, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %77 = load i1, ptr %6, align 1
  ret i1 %77
}

declare void @Mat3d_fromVec(ptr noundef, ptr noundef, i32 noundef) #2

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

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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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_rotate(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @Vec3d_computePlaneLineIntersection(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = alloca [3 x [3 x double]], align 16
  %7 = alloca [3 x [3 x double]], align 16
  %8 = alloca [3 x double], align 16
  %9 = alloca [3 x double], align 16
  %10 = alloca [3 x [3 x double]], align 16
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %10) #3
  call void @Mat3d_fromVec(ptr noundef nonnull %10, ptr noundef %4, i32 noundef 2) #3
  %11 = getelementptr inbounds i8, ptr %10, i64 24
  %12 = load double, ptr %2, align 8, !tbaa !5
  %13 = fneg double %12
  store double %13, ptr %6, align 16, !tbaa !5
  %14 = load double, ptr %10, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %6, i64 8
  store double %14, ptr %15, align 8, !tbaa !5
  %16 = load double, ptr %11, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %6, i64 16
  store double %16, ptr %17, align 16, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %2, i64 8
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = fneg double %19
  %21 = getelementptr inbounds i8, ptr %6, i64 24
  store double %20, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %10, i64 8
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %6, i64 32
  store double %23, ptr %24, align 16, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %10, i64 32
  %26 = load double, ptr %25, align 16, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %6, i64 40
  store double %26, ptr %27, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %2, i64 16
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = fneg double %29
  %31 = getelementptr inbounds i8, ptr %6, i64 48
  store double %30, ptr %31, align 16, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %10, i64 16
  %33 = load double, ptr %32, align 16, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %6, i64 56
  store double %33, ptr %34, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %10, i64 40
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %6, i64 64
  store double %36, ptr %37, align 16, !tbaa !5
  %38 = call double @Mat3d_inverse(ptr noundef nonnull %7, ptr noundef nonnull %6) #3
  %39 = fcmp une double %38, 0.000000e+00
  br i1 %39, label %40, label %42

40:                                               ; preds = %5
  call void @Vec3d_sub(ptr noundef nonnull %9, ptr noundef %1, ptr noundef %3)
  call void @Vec3d_rotate(ptr noundef nonnull %8, ptr noundef nonnull %7, ptr noundef nonnull %9)
  %41 = load double, ptr %8, align 16, !tbaa !5
  call void @Vec3d_constMulAndAdd(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %2, double noundef %41)
  br label %42

42:                                               ; preds = %5, %40
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %6) #3
  ret i1 %39
}

declare void @Mat3d_fromVec(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass