; LLVM IR from jdeokkim/ferox :: src (rigid_body)

; 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.frTransform_ = type { %struct.frVector2_, %struct.anon, float }
%struct.frVector2_ = type { float, float }
%struct.anon = type { float, float }
%struct.frAABB_ = type { float, float, float, float }
%struct.frBody_ = type { %struct.frMotionData_, %struct.frTransform_, ptr, i32, i32, %struct.frAABB_, ptr }
%struct.frMotionData_ = type { float, float, float, float, %struct.frVector2_, float, float, %struct.frVector2_, float }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

declare { <2 x float>, <2 x float> } @frGetShapeAABB(ptr noundef, ptr noundef byval(%struct.frTransform_) align 8) #2

; Function Attrs: nounwind uwtable
declare dso_local void @frSetBodyAngle(ptr noundef, float noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local void @frIntegrateForBodyPosition(ptr noundef %0, float noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca %struct.frAABB_, align 4
  %6 = alloca %struct.frTransform_, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %17, label %9

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.frBody_, ptr %10, i32 0, i32 3
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %17, label %14

14:                                               ; preds = %9
  %15 = load float, ptr %4, align 4, !tbaa !9
  %16 = fcmp ole float %15, 0.000000e+00
  br i1 %16, label %17, label %18

17:                                               ; preds = %14, %9, %2
  br label %73

18:                                               ; preds = %14
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.frBody_, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.frMotionData_, ptr %20, i32 0, i32 4
  %22 = getelementptr inbounds %struct.frVector2_, ptr %21, i32 0, i32 0
  %23 = load float, ptr %22, align 8, !tbaa !19
  %24 = load float, ptr %4, align 4, !tbaa !9
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.frBody_, ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds %struct.frTransform_, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.frVector2_, ptr %27, i32 0, i32 0
  %29 = load float, ptr %28, align 4, !tbaa !20
  %30 = call float @llvm.fmuladd.f32(float %23, float %24, float %29)
  store float %30, ptr %28, align 4, !tbaa !20
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.frBody_, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.frMotionData_, ptr %32, i32 0, i32 4
  %34 = getelementptr inbounds %struct.frVector2_, ptr %33, i32 0, i32 1
  %35 = load float, ptr %34, align 4, !tbaa !21
  %36 = load float, ptr %4, align 4, !tbaa !9
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.frBody_, ptr %37, i32 0, i32 1
  %39 = getelementptr inbounds %struct.frTransform_, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.frVector2_, ptr %39, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !22
  %42 = call float @llvm.fmuladd.f32(float %35, float %36, float %41)
  store float %42, ptr %40, align 4, !tbaa !22
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.frBody_, ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %struct.frMotionData_, ptr %44, i32 0, i32 5
  %46 = load float, ptr %45, align 8, !tbaa !23
  %47 = fcmp une float %46, 0.000000e+00
  br i1 %47, label %48, label %60

48:                                               ; preds = %18
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.frBody_, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds %struct.frTransform_, ptr %51, i32 0, i32 2
  %53 = load float, ptr %52, align 4, !tbaa !24
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.frBody_, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %struct.frMotionData_, ptr %55, i32 0, i32 5
  %57 = load float, ptr %56, align 8, !tbaa !23
  %58 = load float, ptr %4, align 4, !tbaa !9
  %59 = call float @llvm.fmuladd.f32(float %57, float %58, float %53)
  call void @frSetBodyAngle(ptr noundef %49, float noundef %59)
  br label %60

60:                                               ; preds = %48, %18
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.frBody_, ptr %61, i32 0, i32 5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #5
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.frBody_, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !25
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.frBody_, ptr %66, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 20, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 4 %67, i64 20, i1 false), !tbaa.struct !26
  %68 = call { <2 x float>, <2 x float> } @frGetShapeAABB(ptr noundef %65, ptr noundef byval(%struct.frTransform_) align 8 %6)
  %69 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  %70 = extractvalue { <2 x float>, <2 x float> } %68, 0
  store <2 x float> %70, ptr %69, align 4
  %71 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  %72 = extractvalue { <2 x float>, <2 x float> } %68, 1
  store <2 x float> %72, ptr %71, align 4
  call void @llvm.lifetime.end.p0(i64 20, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %62, ptr align 4 %5, i64 16, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #5
  br label %73

73:                                               ; preds = %60, %17
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 uwtable "min-legal-vector-width"="64" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !17, i64 72}
!12 = !{!"frBody_", !13, i64 0, !15, i64 44, !6, i64 64, !17, i64 72, !17, i64 76, !18, i64 80, !6, i64 96}
!13 = !{!"frMotionData_", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !14, i64 16, !10, i64 24, !10, i64 28, !14, i64 32, !10, i64 40}
!14 = !{!"frVector2_", !10, i64 0, !10, i64 4}
!15 = !{!"frTransform_", !14, i64 0, !16, i64 8, !10, i64 16}
!16 = !{!"", !10, i64 0, !10, i64 4}
!17 = !{!"int", !7, i64 0}
!18 = !{!"frAABB_", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!19 = !{!12, !10, i64 16}
!20 = !{!12, !10, i64 44}
!21 = !{!12, !10, i64 20}
!22 = !{!12, !10, i64 48}
!23 = !{!12, !10, i64 24}
!24 = !{!12, !10, i64 60}
!25 = !{!12, !6, i64 64}
!26 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9}
!27 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9}


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

%struct.frTransform_ = type { %struct.frVector2_, %struct.anon, float }
%struct.frVector2_ = type { float, float }
%struct.anon = type { float, float }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

declare { <2 x float>, <2 x float> } @frGetShapeAABB(ptr noundef, ptr noundef byval(%struct.frTransform_) align 8) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @frSetBodyAngle(ptr noundef, float noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local void @frIntegrateForBodyPosition(ptr noundef %0, float noundef %1) local_unnamed_addr #3 {
  %3 = alloca %struct.frTransform_, align 8
  %4 = icmp eq ptr %0, null
  br i1 %4, label %32, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 72
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp eq i32 %7, 1
  %9 = fcmp ole float %1, 0.000000e+00
  %or.cond = or i1 %9, %8
  br i1 %or.cond, label %32, label %10

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = getelementptr inbounds i8, ptr %0, i64 44
  %13 = load <2 x float>, ptr %11, align 8, !tbaa !17
  %14 = load <2 x float>, ptr %12, align 4, !tbaa !17
  %15 = insertelement <2 x float> poison, float %1, i64 0
  %16 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> zeroinitializer
  %17 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %13, <2 x float> %16, <2 x float> %14)
  store <2 x float> %17, ptr %12, align 4, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load float, ptr %18, align 8, !tbaa !18
  %20 = fcmp une float %19, 0.000000e+00
  br i1 %20, label %21, label %25

21:                                               ; preds = %10
  %22 = getelementptr inbounds i8, ptr %0, i64 60
  %23 = load float, ptr %22, align 4, !tbaa !19
  %24 = tail call float @llvm.fmuladd.f32(float %19, float %1, float %23)
  tail call void @frSetBodyAngle(ptr noundef nonnull %0, float noundef %24)
  br label %25

25:                                               ; preds = %21, %10
  %26 = getelementptr inbounds i8, ptr %0, i64 80
  %27 = getelementptr inbounds i8, ptr %0, i64 64
  %28 = load ptr, ptr %27, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %3, ptr noundef nonnull align 4 dereferenceable(20) %12, i64 20, i1 false), !tbaa.struct !21
  %29 = tail call { <2 x float>, <2 x float> } @frGetShapeAABB(ptr noundef %28, ptr noundef nonnull byval(%struct.frTransform_) align 8 %3) #6
  %30 = extractvalue { <2 x float>, <2 x float> } %29, 0
  %31 = extractvalue { <2 x float>, <2 x float> } %29, 1
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %3) #6
  store <2 x float> %30, ptr %26, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 88
  store <2 x float> %31, ptr %.sroa.4.0..sroa_idx, align 8
  br label %32

32:                                               ; preds = %2, %5, %25
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #5

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

!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, !15, i64 72}
!6 = !{!"frBody_", !7, i64 0, !12, i64 44, !14, i64 64, !15, i64 72, !15, i64 76, !16, i64 80, !14, i64 96}
!7 = !{!"frMotionData_", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !11, i64 16, !8, i64 24, !8, i64 28, !11, i64 32, !8, i64 40}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"frVector2_", !8, i64 0, !8, i64 4}
!12 = !{!"frTransform_", !11, i64 0, !13, i64 8, !8, i64 16}
!13 = !{!"", !8, i64 0, !8, i64 4}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"int", !9, i64 0}
!16 = !{!"frAABB_", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!17 = !{!8, !8, i64 0}
!18 = !{!6, !8, i64 24}
!19 = !{!6, !8, i64 60}
!20 = !{!6, !14, i64 64}
!21 = !{i64 0, i64 4, !17, i64 4, i64 4, !17, i64 8, i64 4, !17, i64 12, i64 4, !17, i64 16, i64 4, !17}


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