; LLVM IR from mtsamis/box2d-optimized :: src/particle (b2_particle_system)

; 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.b2ParticleDef = type { i32, %struct.b2Vec2, %struct.b2Vec2, %class.b2ParticleColor, float, ptr, ptr }
%struct.b2Vec2 = type { float, float }
%class.b2ParticleColor = type { i8, i8, i8, i8 }
%struct.b2ParticleGroupDef = type { i32, i32, %struct.b2Vec2, float, %struct.b2Vec2, float, %class.b2ParticleColor, float, ptr, ptr, i32, float, i32, ptr, float, ptr, ptr }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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: mustprogress uwtable
declare dso_local noundef i32 @_ZN16b2ParticleSystem14CreateParticleERK13b2ParticleDef(ptr noundef nonnull align 8 dereferenceable(632), ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN16b2ParticleSystem22CreateParticleForGroupERK18b2ParticleGroupDefRK11b2TransformRK6b2Vec2(ptr noundef nonnull align 8 dereferenceable(632) %0, ptr noundef nonnull align 8 dereferenceable(104) %1, ptr noundef nonnull align 4 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(8) %3) #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.b2ParticleDef, align 8
  %10 = alloca %struct.b2Vec2, align 4
  %11 = alloca %struct.b2Vec2, align 4
  %12 = alloca %struct.b2Vec2, align 4
  %13 = alloca %struct.b2Vec2, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr %9) #5
  call void @_ZN13b2ParticleDefC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %9)
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.b2ParticleGroupDef, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.b2ParticleDef, ptr %9, i32 0, i32 0
  store i32 %17, ptr %18, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = call <2 x float> @_Z5b2MulRK11b2TransformRK6b2Vec2(ptr noundef nonnull align 4 dereferenceable(16) %19, ptr noundef nonnull align 4 dereferenceable(8) %20)
  store <2 x float> %21, ptr %10, align 4
  %22 = getelementptr inbounds %struct.b2ParticleDef, ptr %9, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.b2ParticleGroupDef, ptr %23, i32 0, i32 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.b2ParticleGroupDef, ptr %25, i32 0, i32 5
  %27 = load float, ptr %26, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %28 = getelementptr inbounds %struct.b2ParticleDef, ptr %9, i32 0, i32 1
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.b2ParticleGroupDef, ptr %29, i32 0, i32 2
  %31 = call <2 x float> @_ZmiRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %28, ptr noundef nonnull align 4 dereferenceable(8) %30)
  store <2 x float> %31, ptr %13, align 4
  %32 = call <2 x float> @_Z7b2CrossfRK6b2Vec2(float noundef %27, ptr noundef nonnull align 4 dereferenceable(8) %13)
  store <2 x float> %32, ptr %12, align 4
  %33 = call <2 x float> @_ZplRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %24, ptr noundef nonnull align 4 dereferenceable(8) %12)
  store <2 x float> %33, ptr %11, align 4
  %34 = getelementptr inbounds %struct.b2ParticleDef, ptr %9, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.b2ParticleGroupDef, ptr %35, i32 0, i32 6
  %37 = getelementptr inbounds %struct.b2ParticleDef, ptr %9, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %37, ptr align 8 %36, i64 4, i1 false), !tbaa.struct !20
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.b2ParticleGroupDef, ptr %38, i32 0, i32 14
  %40 = load float, ptr %39, align 8, !tbaa !22
  %41 = getelementptr inbounds %struct.b2ParticleDef, ptr %9, i32 0, i32 4
  store float %40, ptr %41, align 8, !tbaa !23
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.b2ParticleGroupDef, ptr %42, i32 0, i32 15
  %44 = load ptr, ptr %43, align 8, !tbaa !24
  %45 = getelementptr inbounds %struct.b2ParticleDef, ptr %9, i32 0, i32 5
  store ptr %44, ptr %45, align 8, !tbaa !25
  %46 = call noundef i32 @_ZN16b2ParticleSystem14CreateParticleERK13b2ParticleDef(ptr noundef nonnull align 8 dereferenceable(632) %14, ptr noundef nonnull align 8 dereferenceable(48) %9)
  call void @llvm.lifetime.end.p0(i64 48, ptr %9) #5
  ret i32 %46
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13b2ParticleDefC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Z5b2MulRK11b2TransformRK6b2Vec2(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(8)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZplRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Z7b2CrossfRK6b2Vec2(float noundef, ptr noundef nonnull align 4 dereferenceable(8)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZmiRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress 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 = { inlinehint mustprogress 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++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS18b2ParticleGroupDef", !11, i64 0, !11, i64 4, !12, i64 8, !13, i64 16, !12, i64 20, !13, i64 28, !14, i64 32, !13, i64 36, !6, i64 40, !6, i64 48, !11, i64 56, !13, i64 60, !11, i64 64, !6, i64 72, !13, i64 80, !6, i64 88, !6, i64 96}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS6b2Vec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_ZTS15b2ParticleColor", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!15 = !{!16, !11, i64 0}
!16 = !{!"_ZTS13b2ParticleDef", !11, i64 0, !12, i64 4, !12, i64 12, !14, i64 20, !13, i64 24, !6, i64 32, !6, i64 40}
!17 = !{i64 0, i64 4, !18, i64 4, i64 4, !18}
!18 = !{!13, !13, i64 0}
!19 = !{!10, !13, i64 28}
!20 = !{i64 0, i64 1, !21, i64 1, i64 1, !21, i64 2, i64 1, !21, i64 3, i64 1, !21}
!21 = !{!7, !7, i64 0}
!22 = !{!10, !13, i64 80}
!23 = !{!16, !13, i64 24}
!24 = !{!10, !6, i64 88}
!25 = !{!16, !6, i64 32}


; 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.b2ParticleDef = type { i32, %struct.b2Vec2, %struct.b2Vec2, %class.b2ParticleColor, float, ptr, ptr }
%struct.b2Vec2 = type { float, float }
%class.b2ParticleColor = type { i8, i8, i8, i8 }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN16b2ParticleSystem14CreateParticleERK13b2ParticleDef(ptr noundef nonnull align 8 dereferenceable(632), ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN16b2ParticleSystem22CreateParticleForGroupERK18b2ParticleGroupDefRK11b2TransformRK6b2Vec2(ptr noundef nonnull align 8 dereferenceable(632) %0, ptr noundef nonnull align 8 dereferenceable(104) %1, ptr noundef nonnull align 4 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(8) %3) local_unnamed_addr #2 align 2 {
  %5 = alloca %struct.b2ParticleDef, align 8
  %6 = alloca %struct.b2Vec2, align 8
  %7 = alloca %struct.b2Vec2, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #4
  call void @_ZN13b2ParticleDefC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5)
  %8 = load i32, ptr %1, align 8, !tbaa !5
  store i32 %8, ptr %5, align 8, !tbaa !14
  %9 = call <2 x float> @_Z5b2MulRK11b2TransformRK6b2Vec2(ptr noundef nonnull align 4 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %10 = getelementptr inbounds i8, ptr %5, i64 4
  store <2 x float> %9, ptr %10, align 4
  %11 = getelementptr inbounds i8, ptr %1, i64 20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %12 = getelementptr inbounds i8, ptr %1, i64 28
  %13 = load float, ptr %12, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = call <2 x float> @_ZmiRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %10, ptr noundef nonnull align 4 dereferenceable(8) %14)
  store <2 x float> %15, ptr %7, align 8
  %16 = call <2 x float> @_Z7b2CrossfRK6b2Vec2(float noundef %13, ptr noundef nonnull align 4 dereferenceable(8) %7)
  store <2 x float> %16, ptr %6, align 8
  %17 = call <2 x float> @_ZplRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %11, ptr noundef nonnull align 4 dereferenceable(8) %6)
  %18 = getelementptr inbounds i8, ptr %5, i64 12
  store <2 x float> %17, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  %19 = getelementptr inbounds i8, ptr %1, i64 32
  %20 = getelementptr inbounds i8, ptr %5, i64 20
  %21 = load i32, ptr %19, align 8
  store i32 %21, ptr %20, align 4
  %22 = getelementptr inbounds i8, ptr %1, i64 80
  %23 = load float, ptr %22, align 8, !tbaa !17
  %24 = getelementptr inbounds i8, ptr %5, i64 24
  store float %23, ptr %24, align 8, !tbaa !18
  %25 = getelementptr inbounds i8, ptr %1, i64 88
  %26 = load ptr, ptr %25, align 8, !tbaa !19
  %27 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %26, ptr %27, align 8, !tbaa !20
  %28 = call noundef i32 @_ZN16b2ParticleSystem14CreateParticleERK13b2ParticleDef(ptr noundef nonnull align 8 dereferenceable(632) %0, ptr noundef nonnull align 8 dereferenceable(48) %5)
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #4
  ret i32 %28
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13b2ParticleDefC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Z5b2MulRK11b2TransformRK6b2Vec2(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZplRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Z7b2CrossfRK6b2Vec2(float noundef, ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZmiRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 = { inlinehint mustprogress 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 = { 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, !7, i64 0}
!6 = !{!"_ZTS18b2ParticleGroupDef", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !10, i64 20, !11, i64 28, !12, i64 32, !11, i64 36, !13, i64 40, !13, i64 48, !7, i64 56, !11, i64 60, !7, i64 64, !13, i64 72, !11, i64 80, !13, i64 88, !13, i64 96}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS6b2Vec2", !11, i64 0, !11, i64 4}
!11 = !{!"float", !8, i64 0}
!12 = !{!"_ZTS15b2ParticleColor", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"_ZTS13b2ParticleDef", !7, i64 0, !10, i64 4, !10, i64 12, !12, i64 20, !11, i64 24, !13, i64 32, !13, i64 40}
!16 = !{!6, !11, i64 28}
!17 = !{!6, !11, i64 80}
!18 = !{!15, !11, i64 24}
!19 = !{!6, !13, i64 88}
!20 = !{!15, !13, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass