; LLVM IR from jonpena/Cirobb :: cirobb/Shape.ll (ZN3OBB20CalculateMassInertiaERKf)

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

%struct.Shape = type { ptr, float, %struct.Vec2, i32, ptr }
%struct.Vec2 = type { float, float }
%struct.RigidBody = type { %struct.Vec2, %struct.Vec2, %struct.Vec2, float, float, float, float, float, float, float, float, float, float, float, float, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3OBB20CalculateMassInertiaERKf(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i64, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr %5, i64 %8
  %10 = getelementptr inbounds %struct.Shape, ptr %9, i32 0, i32 2
  %11 = getelementptr inbounds %struct.Vec2, ptr %10, i32 0, i32 0
  %12 = load float, ptr %11, align 4, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr %5, i64 %15
  %17 = getelementptr inbounds %struct.Shape, ptr %16, i32 0, i32 2
  %18 = getelementptr inbounds %struct.Vec2, ptr %17, i32 0, i32 1
  %19 = load float, ptr %18, align 4, !tbaa !16
  %20 = fmul float %12, %19
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load float, ptr %21, align 4, !tbaa !17
  %23 = fmul float %20, %22
  %24 = load ptr, ptr %5, align 8, !tbaa !9
  %25 = getelementptr i8, ptr %24, i64 -24
  %26 = load i64, ptr %25, align 8
  %27 = getelementptr inbounds i8, ptr %5, i64 %26
  %28 = getelementptr inbounds %struct.Shape, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %30 = getelementptr inbounds %struct.RigidBody, ptr %29, i32 0, i32 6
  store float %23, ptr %30, align 4, !tbaa !19
  %31 = load ptr, ptr %5, align 8, !tbaa !9
  %32 = getelementptr i8, ptr %31, i64 -24
  %33 = load i64, ptr %32, align 8
  %34 = getelementptr inbounds i8, ptr %5, i64 %33
  %35 = getelementptr inbounds %struct.Shape, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = getelementptr inbounds %struct.RigidBody, ptr %36, i32 0, i32 6
  %38 = load float, ptr %37, align 4, !tbaa !19
  %39 = fcmp une float %38, 0.000000e+00
  br i1 %39, label %40, label %50

40:                                               ; preds = %2
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = getelementptr i8, ptr %41, i64 -24
  %43 = load i64, ptr %42, align 8
  %44 = getelementptr inbounds i8, ptr %5, i64 %43
  %45 = getelementptr inbounds %struct.Shape, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = getelementptr inbounds %struct.RigidBody, ptr %46, i32 0, i32 6
  %48 = load float, ptr %47, align 4, !tbaa !19
  %49 = fdiv float 1.000000e+00, %48
  br label %51

50:                                               ; preds = %2
  br label %51

51:                                               ; preds = %50, %40
  %52 = phi float [ %49, %40 ], [ 0.000000e+00, %50 ]
  %53 = load ptr, ptr %5, align 8, !tbaa !9
  %54 = getelementptr i8, ptr %53, i64 -24
  %55 = load i64, ptr %54, align 8
  %56 = getelementptr inbounds i8, ptr %5, i64 %55
  %57 = getelementptr inbounds %struct.Shape, ptr %56, i32 0, i32 4
  %58 = load ptr, ptr %57, align 8, !tbaa !18
  %59 = getelementptr inbounds %struct.RigidBody, ptr %58, i32 0, i32 7
  store float %52, ptr %59, align 8, !tbaa !21
  %60 = load ptr, ptr %5, align 8, !tbaa !9
  %61 = getelementptr i8, ptr %60, i64 -24
  %62 = load i64, ptr %61, align 8
  %63 = getelementptr inbounds i8, ptr %5, i64 %62
  %64 = getelementptr inbounds %struct.Shape, ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !18
  %66 = getelementptr inbounds %struct.RigidBody, ptr %65, i32 0, i32 6
  %67 = load float, ptr %66, align 4, !tbaa !19
  %68 = load ptr, ptr %5, align 8, !tbaa !9
  %69 = getelementptr i8, ptr %68, i64 -24
  %70 = load i64, ptr %69, align 8
  %71 = getelementptr inbounds i8, ptr %5, i64 %70
  %72 = getelementptr inbounds %struct.Shape, ptr %71, i32 0, i32 2
  %73 = call noundef float @_ZN4Vec215SquareMagnitudeEv(ptr noundef nonnull align 4 dereferenceable(8) %72)
  %74 = fmul float %67, %73
  %75 = fdiv float %74, 1.200000e+01
  %76 = load ptr, ptr %5, align 8, !tbaa !9
  %77 = getelementptr i8, ptr %76, i64 -24
  %78 = load i64, ptr %77, align 8
  %79 = getelementptr inbounds i8, ptr %5, i64 %78
  %80 = getelementptr inbounds %struct.Shape, ptr %79, i32 0, i32 4
  %81 = load ptr, ptr %80, align 8, !tbaa !18
  %82 = getelementptr inbounds %struct.RigidBody, ptr %81, i32 0, i32 8
  store float %75, ptr %82, align 4, !tbaa !22
  %83 = load ptr, ptr %5, align 8, !tbaa !9
  %84 = getelementptr i8, ptr %83, i64 -24
  %85 = load i64, ptr %84, align 8
  %86 = getelementptr inbounds i8, ptr %5, i64 %85
  %87 = getelementptr inbounds %struct.Shape, ptr %86, i32 0, i32 4
  %88 = load ptr, ptr %87, align 8, !tbaa !18
  %89 = getelementptr inbounds %struct.RigidBody, ptr %88, i32 0, i32 8
  %90 = load float, ptr %89, align 4, !tbaa !22
  %91 = fcmp une float %90, 0.000000e+00
  br i1 %91, label %92, label %102

92:                                               ; preds = %51
  %93 = load ptr, ptr %5, align 8, !tbaa !9
  %94 = getelementptr i8, ptr %93, i64 -24
  %95 = load i64, ptr %94, align 8
  %96 = getelementptr inbounds i8, ptr %5, i64 %95
  %97 = getelementptr inbounds %struct.Shape, ptr %96, i32 0, i32 4
  %98 = load ptr, ptr %97, align 8, !tbaa !18
  %99 = getelementptr inbounds %struct.RigidBody, ptr %98, i32 0, i32 8
  %100 = load float, ptr %99, align 4, !tbaa !22
  %101 = fdiv float 1.000000e+00, %100
  br label %103

102:                                              ; preds = %51
  br label %103

103:                                              ; preds = %102, %92
  %104 = phi float [ %101, %92 ], [ 0.000000e+00, %102 ]
  %105 = load ptr, ptr %5, align 8, !tbaa !9
  %106 = getelementptr i8, ptr %105, i64 -24
  %107 = load i64, ptr %106, align 8
  %108 = getelementptr inbounds i8, ptr %5, i64 %107
  %109 = getelementptr inbounds %struct.Shape, ptr %108, i32 0, i32 4
  %110 = load ptr, ptr %109, align 8, !tbaa !18
  %111 = getelementptr inbounds %struct.RigidBody, ptr %110, i32 0, i32 9
  store float %104, ptr %111, align 8, !tbaa !23
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN4Vec215SquareMagnitudeEv(ptr noundef nonnull align 4 dereferenceable(8)) #1 align 2

attributes #0 = { mustprogress 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 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" }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !13, i64 12}
!12 = !{!"_ZTS5Shape", !13, i64 8, !14, i64 12, !15, i64 20, !6, i64 24}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_ZTS4Vec2", !13, i64 0, !13, i64 4}
!15 = !{!"_ZTS9typeShape", !7, i64 0}
!16 = !{!12, !13, i64 16}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !6, i64 24}
!19 = !{!20, !13, i64 36}
!20 = !{!"_ZTS9RigidBody", !14, i64 0, !14, i64 8, !14, i64 16, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !6, i64 72}
!21 = !{!20, !13, i64 40}
!22 = !{!20, !13, i64 44}
!23 = !{!20, !13, i64 48}


; 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 nounwind uwtable
define dso_local void @_ZN3OBB20CalculateMassInertiaERKf(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(4) %1) unnamed_addr #0 align 2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr i8, ptr %3, i64 -24
  %5 = load i64, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 %5
  %7 = getelementptr inbounds i8, ptr %6, i64 12
  %8 = load float, ptr %7, align 4, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %6, i64 16
  %10 = load float, ptr %9, align 4, !tbaa !15
  %11 = fmul float %8, %10
  %12 = load float, ptr %1, align 4, !tbaa !16
  %13 = fmul float %11, %12
  %14 = getelementptr inbounds i8, ptr %6, i64 24
  %15 = load ptr, ptr %14, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %15, i64 36
  store float %13, ptr %16, align 4, !tbaa !18
  %17 = load i64, ptr %4, align 8
  %18 = getelementptr inbounds i8, ptr %0, i64 %17
  %19 = getelementptr inbounds i8, ptr %18, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %20, i64 36
  %22 = load float, ptr %21, align 4, !tbaa !18
  %23 = fcmp une float %22, 0.000000e+00
  %24 = fdiv float 1.000000e+00, %22
  %25 = select i1 %23, float %24, float 0.000000e+00
  %26 = getelementptr inbounds i8, ptr %20, i64 40
  store float %25, ptr %26, align 8, !tbaa !20
  %27 = load i64, ptr %4, align 8
  %28 = getelementptr inbounds i8, ptr %0, i64 %27
  %29 = getelementptr inbounds i8, ptr %28, i64 24
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = getelementptr inbounds i8, ptr %30, i64 36
  %32 = load float, ptr %31, align 4, !tbaa !18
  %33 = getelementptr inbounds i8, ptr %28, i64 12
  %34 = tail call noundef float @_ZN4Vec215SquareMagnitudeEv(ptr noundef nonnull align 4 dereferenceable(8) %33)
  %35 = fmul float %32, %34
  %36 = fdiv float %35, 1.200000e+01
  %37 = load ptr, ptr %0, align 8, !tbaa !5
  %38 = getelementptr i8, ptr %37, i64 -24
  %39 = load i64, ptr %38, align 8
  %40 = getelementptr inbounds i8, ptr %0, i64 %39
  %41 = getelementptr inbounds i8, ptr %40, i64 24
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %42, i64 44
  store float %36, ptr %43, align 4, !tbaa !21
  %44 = load i64, ptr %38, align 8
  %45 = getelementptr inbounds i8, ptr %0, i64 %44
  %46 = getelementptr inbounds i8, ptr %45, i64 24
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = getelementptr inbounds i8, ptr %47, i64 44
  %49 = load float, ptr %48, align 4, !tbaa !21
  %50 = fcmp une float %49, 0.000000e+00
  %51 = fdiv float 1.000000e+00, %49
  %52 = select i1 %50, float %51, float 0.000000e+00
  %53 = getelementptr inbounds i8, ptr %47, i64 48
  store float %52, ptr %53, align 8, !tbaa !22
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN4Vec215SquareMagnitudeEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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" }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 12}
!9 = !{!"_ZTS5Shape", !10, i64 8, !12, i64 12, !13, i64 20, !14, i64 24}
!10 = !{!"float", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"_ZTS4Vec2", !10, i64 0, !10, i64 4}
!13 = !{!"_ZTS9typeShape", !11, i64 0}
!14 = !{!"any pointer", !11, i64 0}
!15 = !{!9, !10, i64 16}
!16 = !{!10, !10, i64 0}
!17 = !{!9, !14, i64 24}
!18 = !{!19, !10, i64 36}
!19 = !{!"_ZTS9RigidBody", !12, i64 0, !12, i64 8, !12, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !14, i64 72}
!20 = !{!19, !10, i64 40}
!21 = !{!19, !10, i64 44}
!22 = !{!19, !10, i64 48}


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