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

; 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) #0

; Function Attrs: nounwind uwtable
define dso_local void @frSetBodyPosition(ptr noundef %0, <2 x float> %1) #1 {
  %3 = alloca %struct.frVector2_, align 4
  %4 = alloca ptr, align 8
  store <2 x float> %1, ptr %3, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %2
  br label %26

8:                                                ; preds = %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.frBody_, ptr %9, i32 0, i32 1
  %11 = getelementptr inbounds %struct.frTransform_, ptr %10, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %3, i64 8, i1 false), !tbaa.struct !9
  %12 = getelementptr inbounds %struct.frVector2_, ptr %3, i32 0, i32 0
  %13 = load float, ptr %12, align 4, !tbaa !12
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.frBody_, ptr %14, i32 0, i32 5
  %16 = getelementptr inbounds %struct.frAABB_, ptr %15, i32 0, i32 0
  %17 = load float, ptr %16, align 8, !tbaa !14
  %18 = fadd float %17, %13
  store float %18, ptr %16, align 8, !tbaa !14
  %19 = getelementptr inbounds %struct.frVector2_, ptr %3, i32 0, i32 1
  %20 = load float, ptr %19, align 4, !tbaa !21
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.frBody_, ptr %21, i32 0, i32 5
  %23 = getelementptr inbounds %struct.frAABB_, ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !22
  %25 = fadd float %24, %20
  store float %25, ptr %23, align 4, !tbaa !22
  br label %26

26:                                               ; preds = %8, %7
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }

!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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"frVector2_", !11, i64 0, !11, i64 4}
!14 = !{!15, !11, i64 80}
!15 = !{!"frBody_", !16, i64 0, !17, i64 44, !6, i64 64, !19, i64 72, !19, i64 76, !20, i64 80, !6, i64 96}
!16 = !{!"frMotionData_", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !13, i64 16, !11, i64 24, !11, i64 28, !13, i64 32, !11, i64 40}
!17 = !{!"frTransform_", !13, i64 0, !18, i64 8, !11, i64 16}
!18 = !{!"", !11, i64 0, !11, i64 4}
!19 = !{!"int", !7, i64 0}
!20 = !{!"frAABB_", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!21 = !{!13, !11, i64 4}
!22 = !{!15, !11, i64 84}


; 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(argmem: readwrite) uwtable
define dso_local void @frSetBodyPosition(ptr noundef %0, <2 x float> %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %9, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 44
  store <2 x float> %1, ptr %5, align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  %7 = load <2 x float>, ptr %6, align 8, !tbaa !5
  %8 = fadd <2 x float> %7, %1
  store <2 x float> %8, ptr %6, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %2, %4
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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