; LLVM IR from mtsamis/box2d-optimized :: src/dynamics/b2_body.ll (ZN6b2Body10SetEnabledEb)

; 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.b2Body = type { i32, i16, i32, %struct.b2Transform, %struct.b2Transform, %struct.b2Sweep, %struct.b2Vec2, float, %struct.b2Vec2, float, ptr, ptr, ptr, ptr, i32, ptr, ptr, i32, i32, float, float, float, float, float, float, float, float, %struct.b2BodyUserData }
%struct.b2Transform = type { %struct.b2Vec2, %struct.b2Rot }
%struct.b2Rot = type { float, float }
%struct.b2Sweep = type { %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, float, float }
%struct.b2Vec2 = type { float, float }
%struct.b2BodyUserData = type { i64 }
%class.b2World = type { %class.b2BlockAllocator, %class.b2StackAllocator, %class.b2ContactManager, ptr, ptr, ptr, ptr, i32, i32, %struct.b2Vec2, i8, ptr, ptr, float, i8, i8, i8, i8, i8, i8, i8, i8, %struct.b2Profile }
%class.b2BlockAllocator = type { ptr, i32, i32, [14 x ptr] }
%class.b2StackAllocator = type <{ [102400 x i8], i32, i32, i32, [4 x i8], [32 x %struct.b2StackEntry], i32, [4 x i8] }>
%struct.b2StackEntry = type { ptr, i32, i8 }
%class.b2ContactManager = type { %class.b2BroadPhase, i32, ptr, ptr, ptr, ptr }
%class.b2BroadPhase = type <{ ptr, ptr, ptr, ptr, %struct.b2TreeNode, ptr, ptr, ptr, i32, i32, %class.b2IntHashTable, i32, i32, i8, [7 x i8] }>
%struct.b2TreeNode = type { ptr, ptr, ptr, ptr, %struct.b2AABB }
%struct.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%class.b2IntHashTable = type <{ ptr, i32, [4 x i8] }>
%struct.b2Profile = type { float, float, float, float, float }

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [29 x i8], align 1
@__PRETTY_FUNCTION__._ZN6b2Body10SetEnabledEb = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7b2World8IsLockedEv(ptr noundef nonnull align 8 dereferenceable(103352)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6b2Body10SetEnabledEb(ptr noundef nonnull align 8 dereferenceable(208) %0, i1 noundef zeroext %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = zext i1 %1 to i8
  store i8 %5, ptr %4, align 1, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %class.b2Body, ptr %6, i32 0, i32 10
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = call noundef zeroext i1 @_ZNK7b2World8IsLockedEv(ptr noundef nonnull align 8 dereferenceable(103352) %8)
  %10 = zext i1 %9 to i32
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %15

13:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 514, ptr noundef @__PRETTY_FUNCTION__._ZN6b2Body10SetEnabledEb) #3
  unreachable

14:                                               ; No predecessors!
  br label %15

15:                                               ; preds = %14, %12
  %16 = load i8, ptr %4, align 1, !tbaa !9, !range !23, !noundef !24
  %17 = trunc i8 %16 to i1
  %18 = zext i1 %17 to i32
  %19 = call noundef zeroext i1 @_ZNK6b2Body9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(208) %6)
  %20 = zext i1 %19 to i32
  %21 = icmp eq i32 %18, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %15
  br label %41

23:                                               ; preds = %15
  %24 = load i8, ptr %4, align 1, !tbaa !9, !range !23, !noundef !24
  %25 = trunc i8 %24 to i1
  br i1 %25, label %26, label %35

26:                                               ; preds = %23
  %27 = getelementptr inbounds %class.b2Body, ptr %6, i32 0, i32 1
  %28 = load i16, ptr %27, align 4, !tbaa !25
  %29 = zext i16 %28 to i32
  %30 = or i32 %29, 32
  %31 = trunc i32 %30 to i16
  store i16 %31, ptr %27, align 4, !tbaa !25
  %32 = getelementptr inbounds %class.b2Body, ptr %6, i32 0, i32 10
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = getelementptr inbounds %class.b2World, ptr %33, i32 0, i32 14
  store i8 1, ptr %34, align 4, !tbaa !26
  br label %41

35:                                               ; preds = %23
  %36 = getelementptr inbounds %class.b2Body, ptr %6, i32 0, i32 1
  %37 = load i16, ptr %36, align 4, !tbaa !25
  %38 = zext i16 %37 to i32
  %39 = and i32 %38, -33
  %40 = trunc i32 %39 to i16
  store i16 %40, ptr %36, align 4, !tbaa !25
  br label %41

41:                                               ; preds = %35, %26, %22
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6b2Body9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(208)) #1 align 2

attributes #0 = { noreturn 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 #1 = { 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 #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 = { noreturn 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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 104}
!12 = !{!"_ZTS6b2Body", !13, i64 0, !14, i64 4, !15, i64 8, !16, i64 12, !16, i64 28, !20, i64 44, !17, i64 80, !18, i64 88, !17, i64 92, !18, i64 100, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !15, i64 136, !6, i64 144, !6, i64 152, !15, i64 160, !15, i64 164, !18, i64 168, !18, i64 172, !18, i64 176, !18, i64 180, !18, i64 184, !18, i64 188, !18, i64 192, !18, i64 196, !21, i64 200}
!13 = !{!"_ZTS10b2BodyType", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS11b2Transform", !17, i64 0, !19, i64 8}
!17 = !{!"_ZTS6b2Vec2", !18, i64 0, !18, i64 4}
!18 = !{!"float", !7, i64 0}
!19 = !{!"_ZTS5b2Rot", !18, i64 0, !18, i64 4}
!20 = !{!"_ZTS7b2Sweep", !17, i64 0, !17, i64 8, !17, i64 16, !18, i64 24, !18, i64 28, !18, i64 32}
!21 = !{!"_ZTS14b2BodyUserData", !22, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!12, !14, i64 4}
!26 = !{!27, !10, i64 103324}
!27 = !{!"_ZTS7b2World", !28, i64 0, !29, i64 128, !30, i64 103064, !6, i64 103248, !6, i64 103256, !6, i64 103264, !6, i64 103272, !15, i64 103280, !15, i64 103284, !17, i64 103288, !10, i64 103296, !6, i64 103304, !6, i64 103312, !18, i64 103320, !10, i64 103324, !10, i64 103325, !10, i64 103326, !10, i64 103327, !10, i64 103328, !10, i64 103329, !10, i64 103330, !10, i64 103331, !35, i64 103332}
!28 = !{!"_ZTS16b2BlockAllocator", !6, i64 0, !15, i64 8, !15, i64 12, !7, i64 16}
!29 = !{!"_ZTS16b2StackAllocator", !7, i64 0, !15, i64 102400, !15, i64 102404, !15, i64 102408, !7, i64 102416, !15, i64 102928}
!30 = !{!"_ZTS16b2ContactManager", !31, i64 0, !15, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176}
!31 = !{!"_ZTS12b2BroadPhase", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !32, i64 32, !6, i64 80, !6, i64 88, !6, i64 96, !15, i64 104, !15, i64 108, !34, i64 112, !15, i64 128, !15, i64 132, !10, i64 136}
!32 = !{!"_ZTS10b2TreeNode", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !33, i64 32}
!33 = !{!"_ZTS6b2AABB", !17, i64 0, !17, i64 8}
!34 = !{!"_ZTS14b2IntHashTable", !6, i64 0, !15, i64 8}
!35 = !{!"_ZTS9b2Profile", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16}


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

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [29 x i8], align 1
@__PRETTY_FUNCTION__._ZN6b2Body10SetEnabledEb = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7b2World8IsLockedEv(ptr noundef nonnull align 8 dereferenceable(103352)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6b2Body10SetEnabledEb(ptr noundef nonnull align 8 dereferenceable(208) %0, i1 noundef zeroext %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 104
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call noundef zeroext i1 @_ZNK7b2World8IsLockedEv(ptr noundef nonnull align 8 dereferenceable(103352) %4)
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 514, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6b2Body10SetEnabledEb) #3
  unreachable

7:                                                ; preds = %2
  %8 = tail call noundef zeroext i1 @_ZNK6b2Body9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  %9 = xor i1 %8, %1
  br i1 %9, label %10, label %19

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load i16, ptr %11, align 4, !tbaa !20
  br i1 %1, label %13, label %17

13:                                               ; preds = %10
  %14 = or i16 %12, 32
  store i16 %14, ptr %11, align 4, !tbaa !20
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 103324
  store i8 1, ptr %16, align 4, !tbaa !21
  br label %19

17:                                               ; preds = %10
  %18 = and i16 %12, -33
  store i16 %18, ptr %11, align 4, !tbaa !20
  br label %19

19:                                               ; preds = %7, %17, %13
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6b2Body9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #1 align 2

attributes #0 = { noreturn 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 #1 = { 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 #2 = { 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 = { noreturn 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, !17, i64 104}
!6 = !{!"_ZTS6b2Body", !7, i64 0, !10, i64 4, !11, i64 8, !12, i64 12, !12, i64 28, !16, i64 44, !13, i64 80, !14, i64 88, !13, i64 92, !14, i64 100, !17, i64 104, !17, i64 112, !17, i64 120, !17, i64 128, !11, i64 136, !17, i64 144, !17, i64 152, !11, i64 160, !11, i64 164, !14, i64 168, !14, i64 172, !14, i64 176, !14, i64 180, !14, i64 184, !14, i64 188, !14, i64 192, !14, i64 196, !18, i64 200}
!7 = !{!"_ZTS10b2BodyType", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_ZTS11b2Transform", !13, i64 0, !15, i64 8}
!13 = !{!"_ZTS6b2Vec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !8, i64 0}
!15 = !{!"_ZTS5b2Rot", !14, i64 0, !14, i64 4}
!16 = !{!"_ZTS7b2Sweep", !13, i64 0, !13, i64 8, !13, i64 16, !14, i64 24, !14, i64 28, !14, i64 32}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!"_ZTS14b2BodyUserData", !19, i64 0}
!19 = !{!"long", !8, i64 0}
!20 = !{!6, !10, i64 4}
!21 = !{!22, !30, i64 103324}
!22 = !{!"_ZTS7b2World", !23, i64 0, !24, i64 128, !25, i64 103064, !17, i64 103248, !17, i64 103256, !17, i64 103264, !17, i64 103272, !11, i64 103280, !11, i64 103284, !13, i64 103288, !30, i64 103296, !17, i64 103304, !17, i64 103312, !14, i64 103320, !30, i64 103324, !30, i64 103325, !30, i64 103326, !30, i64 103327, !30, i64 103328, !30, i64 103329, !30, i64 103330, !30, i64 103331, !31, i64 103332}
!23 = !{!"_ZTS16b2BlockAllocator", !17, i64 0, !11, i64 8, !11, i64 12, !8, i64 16}
!24 = !{!"_ZTS16b2StackAllocator", !8, i64 0, !11, i64 102400, !11, i64 102404, !11, i64 102408, !8, i64 102416, !11, i64 102928}
!25 = !{!"_ZTS16b2ContactManager", !26, i64 0, !11, i64 144, !17, i64 152, !17, i64 160, !17, i64 168, !17, i64 176}
!26 = !{!"_ZTS12b2BroadPhase", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !27, i64 32, !17, i64 80, !17, i64 88, !17, i64 96, !11, i64 104, !11, i64 108, !29, i64 112, !11, i64 128, !11, i64 132, !30, i64 136}
!27 = !{!"_ZTS10b2TreeNode", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !28, i64 32}
!28 = !{!"_ZTS6b2AABB", !13, i64 0, !13, i64 8}
!29 = !{!"_ZTS14b2IntHashTable", !17, i64 0, !11, i64 8}
!30 = !{!"bool", !8, i64 0}
!31 = !{!"_ZTS9b2Profile", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass