; LLVM IR from mtsamis/box2d-optimized :: src/dynamics (b2_contact)

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

%class.b2Contact = type { ptr, ptr, ptr, ptr, ptr, %struct.b2Manifold, i32, i32, float, float, float, float }
%struct.b2Manifold = type { [2 x %struct.b2ManifoldPoint], %struct.b2Vec2, %struct.b2Vec2, i32, i32 }
%struct.b2ManifoldPoint = type { %struct.b2Vec2, float, float, %union.b2ContactID }
%union.b2ContactID = type { i32 }
%struct.b2Vec2 = type { float, float }
%class.b2Fixture = type <{ float, [4 x i8], ptr, ptr, ptr, %struct.b2AABB, float, float, float, %struct.b2Filter, i8, [5 x i8], %struct.b2FixtureUserData, i32, [4 x i8] }>
%struct.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%struct.b2Filter = type { i16, i16, i16 }
%struct.b2FixtureUserData = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9b2ContactC2EP9b2FixtureS1_PFvP10b2ManifoldPK7b2ShapeRK11b2TransformS6_S9_E(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  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
  %9 = load ptr, ptr %5, align 8
  %10 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 5
  call void @_ZN10b2ManifoldC2Ev(ptr noundef nonnull align 4 dereferenceable(64) %10)
  %11 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 6
  store i32 18, ptr %11, align 8, !tbaa !9
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 3
  store ptr %12, ptr %13, align 8, !tbaa !16
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 4
  store ptr %14, ptr %15, align 8, !tbaa !17
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 0
  store ptr %16, ptr %17, align 8, !tbaa !18
  %18 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 5
  %19 = getelementptr inbounds %struct.b2Manifold, ptr %18, i32 0, i32 4
  store i32 0, ptr %19, align 4, !tbaa !19
  %20 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 1
  store ptr null, ptr %20, align 8, !tbaa !20
  %21 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 2
  store ptr null, ptr %21, align 8, !tbaa !21
  %22 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 7
  store i32 -1, ptr %22, align 4, !tbaa !22
  %23 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 3
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds %class.b2Fixture, ptr %24, i32 0, i32 6
  %26 = load float, ptr %25, align 8, !tbaa !23
  %27 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = getelementptr inbounds %class.b2Fixture, ptr %28, i32 0, i32 6
  %30 = load float, ptr %29, align 8, !tbaa !23
  %31 = call noundef float @_Z13b2MixFrictionff(float noundef %26, float noundef %30)
  %32 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 8
  store float %31, ptr %32, align 8, !tbaa !31
  %33 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 3
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = getelementptr inbounds %class.b2Fixture, ptr %34, i32 0, i32 7
  %36 = load float, ptr %35, align 4, !tbaa !32
  %37 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 4
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds %class.b2Fixture, ptr %38, i32 0, i32 7
  %40 = load float, ptr %39, align 4, !tbaa !32
  %41 = call noundef float @_Z16b2MixRestitutionff(float noundef %36, float noundef %40)
  %42 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 9
  store float %41, ptr %42, align 4, !tbaa !33
  %43 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !16
  %45 = getelementptr inbounds %class.b2Fixture, ptr %44, i32 0, i32 8
  %46 = load float, ptr %45, align 8, !tbaa !34
  %47 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 4
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = getelementptr inbounds %class.b2Fixture, ptr %48, i32 0, i32 8
  %50 = load float, ptr %49, align 8, !tbaa !34
  %51 = call noundef float @_Z25b2MixRestitutionThresholdff(float noundef %46, float noundef %50)
  %52 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 10
  store float %51, ptr %52, align 8, !tbaa !35
  %53 = getelementptr inbounds %class.b2Contact, ptr %9, i32 0, i32 11
  store float 0.000000e+00, ptr %53, align 4, !tbaa !36
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN10b2ManifoldC2Ev(ptr noundef nonnull align 4 dereferenceable(64)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z13b2MixFrictionff(float noundef, float noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z16b2MixRestitutionff(float noundef, float noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z25b2MixRestitutionThresholdff(float noundef, float noundef) #2

attributes #0 = { 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 #1 = { inlinehint 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 = { inlinehint 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, !15, i64 104}
!10 = !{!"_ZTS9b2Contact", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !15, i64 104, !15, i64 108, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124}
!11 = !{!"_ZTS10b2Manifold", !7, i64 0, !12, i64 40, !12, i64 48, !14, i64 56, !15, i64 60}
!12 = !{!"_ZTS6b2Vec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_ZTSN10b2Manifold4TypeE", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !6, i64 32}
!18 = !{!10, !6, i64 0}
!19 = !{!10, !15, i64 100}
!20 = !{!10, !6, i64 8}
!21 = !{!10, !6, i64 16}
!22 = !{!10, !15, i64 108}
!23 = !{!24, !13, i64 48}
!24 = !{!"_ZTS9b2Fixture", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !25, i64 32, !13, i64 48, !13, i64 52, !13, i64 56, !26, i64 60, !28, i64 66, !29, i64 72, !15, i64 80}
!25 = !{!"_ZTS6b2AABB", !12, i64 0, !12, i64 8}
!26 = !{!"_ZTS8b2Filter", !27, i64 0, !27, i64 2, !27, i64 4}
!27 = !{!"short", !7, i64 0}
!28 = !{!"bool", !7, i64 0}
!29 = !{!"_ZTS17b2FixtureUserData", !30, i64 0}
!30 = !{!"long", !7, i64 0}
!31 = !{!10, !13, i64 112}
!32 = !{!24, !13, i64 52}
!33 = !{!10, !13, i64 116}
!34 = !{!24, !13, i64 56}
!35 = !{!10, !13, i64 120}
!36 = !{!10, !13, i64 124}


; 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 uwtable
define dso_local void @_ZN9b2ContactC2EP9b2FixtureS1_PFvP10b2ManifoldPK7b2ShapeRK11b2TransformS6_S9_E(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZN10b2ManifoldC2Ev(ptr noundef nonnull align 4 dereferenceable(64) %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 18, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %1, ptr %7, align 8, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %2, ptr %8, align 8, !tbaa !16
  store ptr %3, ptr %0, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %0, i64 100
  store i32 0, ptr %9, align 4, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = getelementptr inbounds i8, ptr %0, i64 108
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  store i32 -1, ptr %11, align 4, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %1, i64 48
  %13 = load float, ptr %12, align 8, !tbaa !20
  %14 = getelementptr inbounds i8, ptr %2, i64 48
  %15 = load float, ptr %14, align 8, !tbaa !20
  %16 = tail call noundef float @_Z13b2MixFrictionff(float noundef %13, float noundef %15)
  %17 = getelementptr inbounds i8, ptr %0, i64 112
  store float %16, ptr %17, align 8, !tbaa !28
  %18 = load ptr, ptr %7, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %18, i64 52
  %20 = load float, ptr %19, align 4, !tbaa !29
  %21 = load ptr, ptr %8, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %21, i64 52
  %23 = load float, ptr %22, align 4, !tbaa !29
  %24 = tail call noundef float @_Z16b2MixRestitutionff(float noundef %20, float noundef %23)
  %25 = getelementptr inbounds i8, ptr %0, i64 116
  store float %24, ptr %25, align 4, !tbaa !30
  %26 = load ptr, ptr %7, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %26, i64 56
  %28 = load float, ptr %27, align 8, !tbaa !31
  %29 = load ptr, ptr %8, align 8, !tbaa !16
  %30 = getelementptr inbounds i8, ptr %29, i64 56
  %31 = load float, ptr %30, align 8, !tbaa !31
  %32 = tail call noundef float @_Z25b2MixRestitutionThresholdff(float noundef %28, float noundef %31)
  %33 = getelementptr inbounds i8, ptr %0, i64 120
  store float %32, ptr %33, align 8, !tbaa !32
  %34 = getelementptr inbounds i8, ptr %0, i64 124
  store float 0.000000e+00, ptr %34, align 4, !tbaa !33
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN10b2ManifoldC2Ev(ptr noundef nonnull align 4 dereferenceable(64)) unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z13b2MixFrictionff(float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z16b2MixRestitutionff(float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z25b2MixRestitutionThresholdff(float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

!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, !14, i64 104}
!6 = !{!"_ZTS9b2Contact", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !14, i64 104, !14, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS10b2Manifold", !8, i64 0, !11, i64 40, !11, i64 48, !13, i64 56, !14, i64 60}
!11 = !{!"_ZTS6b2Vec2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !8, i64 0}
!13 = !{!"_ZTSN10b2Manifold4TypeE", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !7, i64 32}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !14, i64 100}
!19 = !{!6, !14, i64 108}
!20 = !{!21, !12, i64 48}
!21 = !{!"_ZTS9b2Fixture", !12, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !22, i64 32, !12, i64 48, !12, i64 52, !12, i64 56, !23, i64 60, !25, i64 66, !26, i64 72, !14, i64 80}
!22 = !{!"_ZTS6b2AABB", !11, i64 0, !11, i64 8}
!23 = !{!"_ZTS8b2Filter", !24, i64 0, !24, i64 2, !24, i64 4}
!24 = !{!"short", !8, i64 0}
!25 = !{!"bool", !8, i64 0}
!26 = !{!"_ZTS17b2FixtureUserData", !27, i64 0}
!27 = !{!"long", !8, i64 0}
!28 = !{!6, !12, i64 112}
!29 = !{!21, !12, i64 52}
!30 = !{!6, !12, i64 116}
!31 = !{!21, !12, i64 56}
!32 = !{!6, !12, i64 120}
!33 = !{!6, !12, i64 124}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass