; LLVM IR from erincatto/box2d-lite :: src/Arbiter.ll (ZN7ArbiterC2EP4BodyS1_)

; 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.Arbiter = type <{ [2 x %struct.Contact], i32, [4 x i8], ptr, ptr, float, [4 x i8] }>
%struct.Contact = type { %struct.Vec2, %struct.Vec2, %struct.Vec2, %struct.Vec2, float, float, float, float, float, float, float, %union.FeaturePair }
%struct.Vec2 = type { float, float }
%union.FeaturePair = type { i32 }
%struct.Body = type { %struct.Vec2, float, %struct.Vec2, float, %struct.Vec2, float, %struct.Vec2, float, float, float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ArbiterC2EP4BodyS1_(ptr noundef nonnull align 8 dereferenceable(156) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds [2 x %struct.Contact], ptr %8, i32 0, i32 0
  %10 = getelementptr inbounds %struct.Contact, ptr %9, i64 2
  br label %11

11:                                               ; preds = %11, %3
  %12 = phi ptr [ %9, %3 ], [ %13, %11 ]
  call void @_ZN7ContactC2Ev(ptr noundef nonnull align 4 dereferenceable(64) %12)
  %13 = getelementptr inbounds %struct.Contact, ptr %12, i64 1
  %14 = icmp eq ptr %13, %10
  br i1 %14, label %15, label %11

15:                                               ; preds = %11
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp ult ptr %16, %17
  br i1 %18, label %19, label %24

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 3
  store ptr %20, ptr %21, align 8, !tbaa !9
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 4
  store ptr %22, ptr %23, align 8, !tbaa !13
  br label %29

24:                                               ; preds = %15
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 3
  store ptr %25, ptr %26, align 8, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 4
  store ptr %27, ptr %28, align 8, !tbaa !13
  br label %29

29:                                               ; preds = %24, %19
  %30 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 0
  %31 = getelementptr inbounds [2 x %struct.Contact], ptr %30, i64 0, i64 0
  %32 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 3
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = call noundef i32 @_Z7CollideP7ContactP4BodyS2_(ptr noundef %31, ptr noundef %33, ptr noundef %35)
  %37 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 1
  store i32 %36, ptr %37, align 8, !tbaa !14
  %38 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.Body, ptr %39, i32 0, i32 7
  %41 = load float, ptr %40, align 4, !tbaa !15
  %42 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = getelementptr inbounds %struct.Body, ptr %43, i32 0, i32 7
  %45 = load float, ptr %44, align 4, !tbaa !15
  %46 = fmul float %41, %45
  %47 = call float @sqrtf(float noundef %46) #3
  %48 = getelementptr inbounds %struct.Arbiter, ptr %7, i32 0, i32 5
  store float %47, ptr %48, align 8, !tbaa !18
  ret void
}

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

declare noundef i32 @_Z7CollideP7ContactP4BodyS2_(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare float @sqrtf(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 = { "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 "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 }

!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, !6, i64 136}
!10 = !{!"_ZTS7Arbiter", !7, i64 0, !11, i64 128, !6, i64 136, !6, i64 144, !12, i64 152}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !6, i64 144}
!14 = !{!10, !11, i64 128}
!15 = !{!16, !12, i64 44}
!16 = !{!"_ZTS4Body", !17, i64 0, !12, i64 8, !17, i64 12, !12, i64 20, !17, i64 24, !12, i64 32, !17, i64 36, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60}
!17 = !{!"_ZTS4Vec2", !12, i64 0, !12, i64 4}
!18 = !{!10, !12, i64 152}


; 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 @_ZN7ArbiterC2EP4BodyS1_(ptr noundef nonnull align 8 dereferenceable(156) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #0 align 2 {
  tail call void @_ZN7ContactC2Ev(ptr noundef nonnull align 4 dereferenceable(64) %0)
  %.ptr.1 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @_ZN7ContactC2Ev(ptr noundef nonnull align 4 dereferenceable(64) %.ptr.1)
  %4 = icmp ult ptr %1, %2
  %spec.select = select i1 %4, ptr %1, ptr %2
  %spec.select12 = select i1 %4, ptr %2, ptr %1
  %5 = getelementptr inbounds i8, ptr %0, i64 136
  store ptr %spec.select, ptr %5, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 144
  store ptr %spec.select12, ptr %6, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 128
  %8 = tail call noundef i32 @_Z7CollideP7ContactP4BodyS2_(ptr noundef nonnull %0, ptr noundef %spec.select, ptr noundef %spec.select12)
  store i32 %8, ptr %7, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %9, i64 44
  %11 = load float, ptr %10, align 4, !tbaa !13
  %12 = load ptr, ptr %6, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %12, i64 44
  %14 = load float, ptr %13, align 4, !tbaa !13
  %15 = fmul float %11, %14
  %16 = tail call float @sqrtf(float noundef %15) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 152
  store float %16, ptr %17, align 8, !tbaa !17
  ret void
}

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

declare noundef i32 @_Z7CollideP7ContactP4BodyS2_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #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 = { "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 nofree nounwind willreturn memory(write) "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 }

!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, !9, i64 128}
!6 = !{!"_ZTS7Arbiter", !7, i64 0, !9, i64 128, !10, i64 136, !10, i64 144, !11, i64 152}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!6, !10, i64 136}
!13 = !{!14, !11, i64 44}
!14 = !{!"_ZTS4Body", !15, i64 0, !11, i64 8, !15, i64 12, !11, i64 20, !15, i64 24, !11, i64 32, !15, i64 36, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60}
!15 = !{!"_ZTS4Vec2", !11, i64 0, !11, i64 4}
!16 = !{!6, !10, i64 144}
!17 = !{!6, !11, i64 152}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass