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

; 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 nounwind uwtable
define dso_local void @_ZN6Circle20CalculateMassInertiaERKf(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 1
  %11 = load float, ptr %10, align 8, !tbaa !11
  %12 = fmul float 0x400921FB60000000, %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 1
  %18 = load float, ptr %17, align 8, !tbaa !11
  %19 = fmul float %12, %18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load float, ptr %20, align 4, !tbaa !16
  %22 = fmul float %19, %21
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = getelementptr i8, ptr %23, i64 -24
  %25 = load i64, ptr %24, align 8
  %26 = getelementptr inbounds i8, ptr %5, i64 %25
  %27 = getelementptr inbounds %struct.Shape, ptr %26, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = getelementptr inbounds %struct.RigidBody, ptr %28, i32 0, i32 6
  store float %22, ptr %29, align 4, !tbaa !18
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = getelementptr i8, ptr %30, i64 -24
  %32 = load i64, ptr %31, align 8
  %33 = getelementptr inbounds i8, ptr %5, i64 %32
  %34 = getelementptr inbounds %struct.Shape, ptr %33, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = getelementptr inbounds %struct.RigidBody, ptr %35, i32 0, i32 6
  %37 = load float, ptr %36, align 4, !tbaa !18
  %38 = fcmp une float %37, 0.000000e+00
  br i1 %38, label %39, label %49

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

49:                                               ; preds = %2
  br label %50

50:                                               ; preds = %49, %39
  %51 = phi float [ %48, %39 ], [ 0.000000e+00, %49 ]
  %52 = load ptr, ptr %5, align 8, !tbaa !9
  %53 = getelementptr i8, ptr %52, i64 -24
  %54 = load i64, ptr %53, align 8
  %55 = getelementptr inbounds i8, ptr %5, i64 %54
  %56 = getelementptr inbounds %struct.Shape, ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  %58 = getelementptr inbounds %struct.RigidBody, ptr %57, i32 0, i32 7
  store float %51, ptr %58, align 8, !tbaa !20
  %59 = load ptr, ptr %5, align 8, !tbaa !9
  %60 = getelementptr i8, ptr %59, i64 -24
  %61 = load i64, ptr %60, align 8
  %62 = getelementptr inbounds i8, ptr %5, i64 %61
  %63 = getelementptr inbounds %struct.Shape, ptr %62, i32 0, i32 4
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  %65 = getelementptr inbounds %struct.RigidBody, ptr %64, i32 0, i32 6
  %66 = load float, ptr %65, align 4, !tbaa !18
  %67 = load ptr, ptr %5, align 8, !tbaa !9
  %68 = getelementptr i8, ptr %67, i64 -24
  %69 = load i64, ptr %68, align 8
  %70 = getelementptr inbounds i8, ptr %5, i64 %69
  %71 = getelementptr inbounds %struct.Shape, ptr %70, i32 0, i32 1
  %72 = load float, ptr %71, align 8, !tbaa !11
  %73 = fmul float %66, %72
  %74 = load ptr, ptr %5, align 8, !tbaa !9
  %75 = getelementptr i8, ptr %74, i64 -24
  %76 = load i64, ptr %75, align 8
  %77 = getelementptr inbounds i8, ptr %5, i64 %76
  %78 = getelementptr inbounds %struct.Shape, ptr %77, i32 0, i32 1
  %79 = load float, ptr %78, align 8, !tbaa !11
  %80 = fmul float %73, %79
  %81 = fmul float %80, 5.000000e-01
  %82 = load ptr, ptr %5, align 8, !tbaa !9
  %83 = getelementptr i8, ptr %82, i64 -24
  %84 = load i64, ptr %83, align 8
  %85 = getelementptr inbounds i8, ptr %5, i64 %84
  %86 = getelementptr inbounds %struct.Shape, ptr %85, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !17
  %88 = getelementptr inbounds %struct.RigidBody, ptr %87, i32 0, i32 8
  store float %81, ptr %88, align 4, !tbaa !21
  %89 = load ptr, ptr %5, align 8, !tbaa !9
  %90 = getelementptr i8, ptr %89, i64 -24
  %91 = load i64, ptr %90, align 8
  %92 = getelementptr inbounds i8, ptr %5, i64 %91
  %93 = getelementptr inbounds %struct.Shape, ptr %92, i32 0, i32 4
  %94 = load ptr, ptr %93, align 8, !tbaa !17
  %95 = getelementptr inbounds %struct.RigidBody, ptr %94, i32 0, i32 8
  %96 = load float, ptr %95, align 4, !tbaa !21
  %97 = fcmp une float %96, 0.000000e+00
  br i1 %97, label %98, label %108

98:                                               ; preds = %50
  %99 = load ptr, ptr %5, align 8, !tbaa !9
  %100 = getelementptr i8, ptr %99, i64 -24
  %101 = load i64, ptr %100, align 8
  %102 = getelementptr inbounds i8, ptr %5, i64 %101
  %103 = getelementptr inbounds %struct.Shape, ptr %102, i32 0, i32 4
  %104 = load ptr, ptr %103, align 8, !tbaa !17
  %105 = getelementptr inbounds %struct.RigidBody, ptr %104, i32 0, i32 8
  %106 = load float, ptr %105, align 4, !tbaa !21
  %107 = fdiv float 1.000000e+00, %106
  br label %109

108:                                              ; preds = %50
  br label %109

109:                                              ; preds = %108, %98
  %110 = phi float [ %107, %98 ], [ 0.000000e+00, %108 ]
  %111 = load ptr, ptr %5, align 8, !tbaa !9
  %112 = getelementptr i8, ptr %111, i64 -24
  %113 = load i64, ptr %112, align 8
  %114 = getelementptr inbounds i8, ptr %5, i64 %113
  %115 = getelementptr inbounds %struct.Shape, ptr %114, i32 0, i32 4
  %116 = load ptr, ptr %115, align 8, !tbaa !17
  %117 = getelementptr inbounds %struct.RigidBody, ptr %116, i32 0, i32 9
  store float %110, ptr %117, align 8, !tbaa !22
  ret void
}

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 = !{!"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 8}
!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 = !{!13, !13, i64 0}
!17 = !{!12, !6, i64 24}
!18 = !{!19, !13, i64 36}
!19 = !{!"_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}
!20 = !{!19, !13, i64 40}
!21 = !{!19, !13, i64 44}
!22 = !{!19, !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 nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN6Circle20CalculateMassInertiaERKf(ptr nocapture noundef nonnull readonly 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 8
  %8 = load float, ptr %7, align 8, !tbaa !8
  %9 = fmul float %8, 0x400921FB60000000
  %10 = fmul float %8, %9
  %11 = load float, ptr %1, align 4, !tbaa !15
  %12 = fmul float %11, %10
  %13 = getelementptr inbounds i8, ptr %6, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %14, i64 36
  store float %12, ptr %15, align 4, !tbaa !17
  %16 = load i64, ptr %4, align 8
  %17 = getelementptr inbounds i8, ptr %0, i64 %16
  %18 = getelementptr inbounds i8, ptr %17, i64 24
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %19, i64 36
  %21 = load float, ptr %20, align 4, !tbaa !17
  %22 = fcmp une float %21, 0.000000e+00
  %23 = fdiv float 1.000000e+00, %21
  %24 = select i1 %22, float %23, float 0.000000e+00
  %25 = getelementptr inbounds i8, ptr %19, i64 40
  store float %24, ptr %25, align 8, !tbaa !19
  %26 = load i64, ptr %4, align 8
  %27 = getelementptr inbounds i8, ptr %0, i64 %26
  %28 = getelementptr inbounds i8, ptr %27, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %30 = getelementptr inbounds i8, ptr %29, i64 36
  %31 = load float, ptr %30, align 4, !tbaa !17
  %32 = getelementptr inbounds i8, ptr %27, i64 8
  %33 = load float, ptr %32, align 8, !tbaa !8
  %34 = fmul float %31, %33
  %35 = fmul float %33, %34
  %36 = fmul float %35, 5.000000e-01
  %37 = getelementptr inbounds i8, ptr %29, i64 44
  store float %36, ptr %37, align 4, !tbaa !20
  %38 = load i64, ptr %4, align 8
  %39 = getelementptr inbounds i8, ptr %0, i64 %38
  %40 = getelementptr inbounds i8, ptr %39, i64 24
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %41, i64 44
  %43 = load float, ptr %42, align 4, !tbaa !20
  %44 = fcmp une float %43, 0.000000e+00
  %45 = fdiv float 1.000000e+00, %43
  %46 = select i1 %44, float %45, float 0.000000e+00
  %47 = getelementptr inbounds i8, ptr %41, i64 48
  store float %46, ptr %47, align 8, !tbaa !21
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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 8}
!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 = !{!10, !10, i64 0}
!16 = !{!9, !14, i64 24}
!17 = !{!18, !10, i64 36}
!18 = !{!"_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}
!19 = !{!18, !10, i64 40}
!20 = !{!18, !10, i64 44}
!21 = !{!18, !10, i64 48}


; Effective O3 passes: EarlyCSEPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass