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

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.Mat3d_fromVec = external hidden unnamed_addr constant [14 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @Mat3d_setIdentity(ptr noundef) #0

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare void @print_trace() #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

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

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

declare void @Vec3d_crossProduct(ptr noundef, ptr noundef, ptr noundef) #3

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

32:                                               ; preds = %3
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  call void @Mat3d_setIdentity(ptr noundef %33)
  store i32 1, ptr %8, align 4
  br label %117

34:                                               ; preds = %3
  %35 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %35, label %105 [
    i32 0, label %36
    i32 1, label %59
    i32 2, label %82
  ]

36:                                               ; preds = %34
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds [3 x double], ptr %37, i64 0
  %39 = getelementptr inbounds [3 x double], ptr %38, i64 0, i64 0
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load double, ptr %7, align 8, !tbaa !11
  %42 = call double @sqrt(double noundef %41) #6
  %43 = fdiv double 1.000000e+00, %42
  call void @Vec3d_constMul(ptr noundef %39, ptr noundef %40, double noundef %43)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds [3 x double], ptr %44, i64 1
  %46 = getelementptr inbounds [3 x double], ptr %45, i64 0, i64 0
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds [3 x double], ptr %47, i64 0
  %49 = getelementptr inbounds [3 x double], ptr %48, i64 0, i64 0
  call void @Vec3d_orthonormalVec(ptr noundef %46, ptr noundef %49)
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds [3 x double], ptr %50, i64 2
  %52 = getelementptr inbounds [3 x double], ptr %51, i64 0, i64 0
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds [3 x double], ptr %53, i64 0
  %55 = getelementptr inbounds [3 x double], ptr %54, i64 0, i64 0
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds [3 x double], ptr %56, i64 1
  %58 = getelementptr inbounds [3 x double], ptr %57, i64 0, i64 0
  call void @Vec3d_crossProduct(ptr noundef %52, ptr noundef %55, ptr noundef %58)
  br label %116

59:                                               ; preds = %34
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds [3 x double], ptr %60, i64 1
  %62 = getelementptr inbounds [3 x double], ptr %61, i64 0, i64 0
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load double, ptr %7, align 8, !tbaa !11
  %65 = call double @sqrt(double noundef %64) #6
  %66 = fdiv double 1.000000e+00, %65
  call void @Vec3d_constMul(ptr noundef %62, ptr noundef %63, double noundef %66)
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds [3 x double], ptr %67, i64 2
  %69 = getelementptr inbounds [3 x double], ptr %68, i64 0, i64 0
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds [3 x double], ptr %70, i64 1
  %72 = getelementptr inbounds [3 x double], ptr %71, i64 0, i64 0
  call void @Vec3d_orthonormalVec(ptr noundef %69, ptr noundef %72)
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds [3 x double], ptr %73, i64 0
  %75 = getelementptr inbounds [3 x double], ptr %74, i64 0, i64 0
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds [3 x double], ptr %76, i64 1
  %78 = getelementptr inbounds [3 x double], ptr %77, i64 0, i64 0
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds [3 x double], ptr %79, i64 2
  %81 = getelementptr inbounds [3 x double], ptr %80, i64 0, i64 0
  call void @Vec3d_crossProduct(ptr noundef %75, ptr noundef %78, ptr noundef %81)
  br label %116

82:                                               ; preds = %34
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds [3 x double], ptr %83, i64 2
  %85 = getelementptr inbounds [3 x double], ptr %84, i64 0, i64 0
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = load double, ptr %7, align 8, !tbaa !11
  %88 = call double @sqrt(double noundef %87) #6
  %89 = fdiv double 1.000000e+00, %88
  call void @Vec3d_constMul(ptr noundef %85, ptr noundef %86, double noundef %89)
  %90 = load ptr, ptr %4, 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 0
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds [3 x double], ptr %93, i64 2
  %95 = getelementptr inbounds [3 x double], ptr %94, i64 0, i64 0
  call void @Vec3d_orthonormalVec(ptr noundef %92, ptr noundef %95)
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds [3 x double], ptr %96, i64 0
  %98 = getelementptr inbounds [3 x double], ptr %97, i64 0, i64 0
  %99 = load ptr, ptr %4, 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 = load ptr, ptr %4, 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
  call void @Vec3d_crossProduct(ptr noundef %98, ptr noundef %101, ptr noundef %104)
  br label %116

105:                                              ; preds = %34
  br label %106

106:                                              ; preds = %105
  %107 = load ptr, ptr @stderr, align 8, !tbaa !5
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @__func__.Mat3d_fromVec, i32 noundef 1740) #6
  %109 = load ptr, ptr @stderr, align 8, !tbaa !5
  %110 = load i32, ptr %6, align 4, !tbaa !9
  %111 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %109, ptr noundef @.str.18, i32 noundef %110) #6
  %112 = load ptr, ptr @stderr, align 8, !tbaa !5
  %113 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %112, ptr noundef @.str.3) #6
  call void @print_trace()
  call void @exit(i32 noundef 1) #7
  unreachable

114:                                              ; No predecessors!
  br label %115

115:                                              ; preds = %114
  br label %116

116:                                              ; preds = %115, %82, %59, %36
  store i32 0, ptr %8, align 4
  br label %117

117:                                              ; preds = %116, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %118 = load i32, ptr %8, align 4
  switch i32 %118, label %120 [
    i32 0, label %119
    i32 1, label %119
  ]

119:                                              ; preds = %117, %117
  ret void

120:                                              ; preds = %117
  unreachable
}

declare void @Vec3d_constMul(ptr noundef, ptr noundef, double noundef) #3

declare void @Vec3d_orthonormalVec(ptr noundef, ptr noundef) #3

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 = { 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 #3 = { "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 = { noreturn 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { noreturn 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}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@__func__.Mat3d_fromVec = external hidden unnamed_addr constant [14 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [43 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @Mat3d_setIdentity(ptr noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare void @print_trace() local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

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

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

; Function Attrs: nounwind uwtable
define dso_local void @Mat3d_fromVec(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fmul double %6, %6
  %8 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %7)
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %8)
  %12 = fcmp oeq double %11, 0.000000e+00
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  tail call void @Mat3d_setIdentity(ptr noundef %0)
  br label %34

14:                                               ; preds = %3
  switch i32 %2, label %27 [
    i32 0, label %15
    i32 1, label %19
    i32 2, label %23
  ]

15:                                               ; preds = %14
  %sqrt = tail call double @llvm.sqrt.f64(double %11)
  %16 = fdiv double 1.000000e+00, %sqrt
  tail call void @Vec3d_constMul(ptr noundef %0, ptr noundef nonnull %1, double noundef %16) #6
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @Vec3d_orthonormalVec(ptr noundef nonnull %17, ptr noundef %0) #6
  %18 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @Vec3d_crossProduct(ptr noundef nonnull %18, ptr noundef %0, ptr noundef nonnull %17) #6
  br label %34

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %sqrt33 = tail call double @llvm.sqrt.f64(double %11)
  %21 = fdiv double 1.000000e+00, %sqrt33
  tail call void @Vec3d_constMul(ptr noundef nonnull %20, ptr noundef nonnull %1, double noundef %21) #6
  %22 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @Vec3d_orthonormalVec(ptr noundef nonnull %22, ptr noundef nonnull %20) #6
  tail call void @Vec3d_crossProduct(ptr noundef %0, ptr noundef nonnull %20, ptr noundef nonnull %22) #6
  br label %34

23:                                               ; preds = %14
  %24 = getelementptr inbounds i8, ptr %0, i64 48
  %sqrt34 = tail call double @llvm.sqrt.f64(double %11)
  %25 = fdiv double 1.000000e+00, %sqrt34
  tail call void @Vec3d_constMul(ptr noundef nonnull %24, ptr noundef nonnull %1, double noundef %25) #6
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @Vec3d_orthonormalVec(ptr noundef nonnull %26, ptr noundef nonnull %24) #6
  tail call void @Vec3d_crossProduct(ptr noundef %0, ptr noundef nonnull %26, ptr noundef nonnull %24) #6
  br label %34

27:                                               ; preds = %14
  %28 = load ptr, ptr @stderr, align 8, !tbaa !9
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Mat3d_fromVec, i32 noundef 1740) #7
  %30 = load ptr, ptr @stderr, align 8, !tbaa !9
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.18, i32 noundef %2) #7
  %32 = load ptr, ptr @stderr, align 8, !tbaa !9
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.3) #7
  tail call void @print_trace() #6
  tail call void @exit(i32 noundef 1) #8
  unreachable

34:                                               ; preds = %15, %19, %23, %13
  ret void
}

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

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

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

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 = { nofree 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 #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 = { noreturn 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { noreturn 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass