; LLVM IR from mvr/jiggle :: src (Area)

; 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.jgVector2 = type { float, float }
%struct.jgArea = type { ptr, %struct.jgAABB, %struct.jgVector2, ptr, i8, %struct.jgVector2, %struct.jgVector2, float, i8, float, float, i8 }
%struct.jgAABB = type { %struct.jgVector2, %struct.jgVector2, i8 }
%struct.jgList = type { ptr, i32, i32 }
%struct.jgParticle = type { float, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, float, float, i8, i8, ptr }

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @jgListGet(ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Add(<2 x float>, <2 x float>) #2

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Divide(<2 x float>, float noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @jgAreaUpdateCenterOfMass(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca %struct.jgVector2, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.jgVector2, align 4
  %8 = alloca %struct.jgVector2, align 4
  %9 = alloca %struct.jgVector2, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 0.000000e+00, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %10 = call <2 x float> @jgv(float noundef 0.000000e+00, float noundef 0.000000e+00)
  store <2 x float> %10, ptr %4, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.jgArea, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = call ptr @jgListGet(ptr noundef %13, i32 noundef 0)
  store ptr %14, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !16
  br label %15

15:                                               ; preds = %40, %1
  %16 = load i32, ptr %6, align 4, !tbaa !16
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.jgArea, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct.jgList, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !18
  %22 = icmp slt i32 %16, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %48

24:                                               ; preds = %15
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.jgParticle, ptr %25, i32 0, i32 0
  %27 = load float, ptr %26, align 8, !tbaa !20
  %28 = load float, ptr %3, align 4, !tbaa !9
  %29 = fadd float %28, %27
  store float %29, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.jgParticle, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.jgParticle, ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 8, !tbaa !20
  %35 = load <2 x float>, ptr %31, align 4
  %36 = call <2 x float> @jgVector2Multiply(<2 x float> %35, float noundef %34)
  store <2 x float> %36, ptr %8, align 4
  %37 = load <2 x float>, ptr %4, align 4
  %38 = load <2 x float>, ptr %8, align 4
  %39 = call <2 x float> @jgVector2Add(<2 x float> %37, <2 x float> %38)
  store <2 x float> %39, ptr %7, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %40

40:                                               ; preds = %24
  %41 = load i32, ptr %6, align 4, !tbaa !16
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %6, align 4, !tbaa !16
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.jgArea, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = load i32, ptr %6, align 4, !tbaa !16
  %47 = call ptr @jgListGet(ptr noundef %45, i32 noundef %46)
  store ptr %47, ptr %5, align 8, !tbaa !5
  br label %15, !llvm.loop !23

48:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %49 = load float, ptr %3, align 4, !tbaa !9
  %50 = load <2 x float>, ptr %4, align 4
  %51 = call <2 x float> @jgVector2Divide(<2 x float> %50, float noundef %49)
  store <2 x float> %51, ptr %9, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.jgArea, ptr %52, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %53, ptr align 4 %4, i64 8, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Multiply(<2 x float>, float noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgv(float noundef, float noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { inlinehint 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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, !6, i64 0}
!12 = !{!"jgArea", !6, i64 0, !13, i64 8, !14, i64 28, !6, i64 40, !15, i64 48, !14, i64 52, !14, i64 60, !10, i64 68, !15, i64 72, !10, i64 76, !10, i64 80, !15, i64 84}
!13 = !{!"jgAABB", !14, i64 0, !14, i64 8, !15, i64 16}
!14 = !{!"jgVector2", !10, i64 0, !10, i64 4}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!19, !17, i64 8}
!19 = !{!"jgList", !6, i64 0, !17, i64 8, !17, i64 12}
!20 = !{!21, !10, i64 0}
!21 = !{!"jgParticle", !10, i64 0, !14, i64 4, !14, i64 12, !14, i64 20, !14, i64 28, !14, i64 36, !10, i64 44, !10, i64 48, !15, i64 52, !15, i64 53, !6, i64 56}
!22 = !{i64 0, i64 4, !9, i64 4, i64 4, !9}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; 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: inlinehint nounwind uwtable
declare hidden ptr @jgListGet(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Add(<2 x float>, <2 x float>) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Divide(<2 x float>, float noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @jgAreaUpdateCenterOfMass(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %2 = tail call <2 x float> @jgv(float noundef 0.000000e+00, float noundef 0.000000e+00)
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = tail call ptr @jgListGet(ptr noundef %3, i32 noundef 0)
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !14
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.sroa.07.0.lcssa = phi <2 x float> [ %2, %1 ], [ %16, %.lr.ph ]
  %.0.lcssa = phi float [ 0.000000e+00, %1 ], [ %12, %.lr.ph ]
  %9 = tail call <2 x float> @jgVector2Divide(<2 x float> %.sroa.07.0.lcssa, float noundef %.0.lcssa)
  %10 = getelementptr inbounds i8, ptr %0, i64 28
  store <2 x float> %9, ptr %10, align 4
  ret void

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.020 = phi float [ %12, %.lr.ph ], [ 0.000000e+00, %1 ]
  %.sroa.07.019 = phi <2 x float> [ %16, %.lr.ph ], [ %2, %1 ]
  %.01518 = phi ptr [ %19, %.lr.ph ], [ %4, %1 ]
  %.01617 = phi i32 [ %17, %.lr.ph ], [ 0, %1 ]
  %11 = load float, ptr %.01518, align 8, !tbaa !17
  %12 = fadd float %.020, %11
  %13 = getelementptr inbounds i8, ptr %.01518, i64 4
  %14 = load <2 x float>, ptr %13, align 4
  %15 = tail call <2 x float> @jgVector2Multiply(<2 x float> %14, float noundef %11)
  %16 = tail call <2 x float> @jgVector2Add(<2 x float> %.sroa.07.019, <2 x float> %15)
  %17 = add nuw nsw i32 %.01617, 1
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = tail call ptr @jgListGet(ptr noundef %18, i32 noundef %17)
  %20 = load ptr, ptr %0, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = icmp slt i32 %17, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !19
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgVector2Multiply(<2 x float>, float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @jgv(float noundef, float noundef) local_unnamed_addr #1

attributes #0 = { inlinehint 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 = { inlinehint 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 #2 = { 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, !7, i64 0}
!6 = !{!"jgArea", !7, i64 0, !10, i64 8, !11, i64 28, !7, i64 40, !13, i64 48, !11, i64 52, !11, i64 60, !12, i64 68, !13, i64 72, !12, i64 76, !12, i64 80, !13, i64 84}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"jgAABB", !11, i64 0, !11, i64 8, !13, i64 16}
!11 = !{!"jgVector2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!15, !16, i64 8}
!15 = !{!"jgList", !7, i64 0, !16, i64 8, !16, i64 12}
!16 = !{!"int", !8, i64 0}
!17 = !{!18, !12, i64 0}
!18 = !{!"jgParticle", !12, i64 0, !11, i64 4, !11, i64 12, !11, i64 20, !11, i64 28, !11, i64 36, !12, i64 44, !12, i64 48, !13, i64 52, !13, i64 53, !7, i64 56}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass