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

; 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.b2PrismaticJoint = type <{ %class.b2Joint, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, %struct.b2Vec2, float, float, float, float, float, float, float, i8, i8, [2 x i8], i32, i32, %struct.b2Vec2, %struct.b2Vec2, float, float, float, float, %struct.b2Vec2, %struct.b2Vec2, float, float, float, float, %struct.b2Mat22, float, float, [4 x i8] }>
%class.b2Joint = type { ptr, i32, ptr, ptr, %struct.b2JointEdge, %struct.b2JointEdge, ptr, ptr, i32, i8, i8, %struct.b2JointUserData }
%struct.b2JointEdge = type { ptr, ptr, ptr, ptr }
%struct.b2JointUserData = type { i64 }
%struct.b2Vec2 = type { float, float }
%struct.b2Mat22 = type { %struct.b2Vec2, %struct.b2Vec2 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16b2PrismaticJoint11EnableLimitEb(ptr noundef nonnull align 8 dereferenceable(300) %0, i1 noundef zeroext %1) #0 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 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %8 = trunc i8 %7 to i1
  %9 = zext i1 %8 to i32
  %10 = getelementptr inbounds %class.b2PrismaticJoint, ptr %6, i32 0, i32 14
  %11 = load i8, ptr %10, align 8, !tbaa !13, !range !11, !noundef !12
  %12 = trunc i8 %11 to i1
  %13 = zext i1 %12 to i32
  %14 = icmp ne i32 %9, %13
  br i1 %14, label %15, label %26

15:                                               ; preds = %2
  %16 = getelementptr inbounds %class.b2Joint, ptr %6, i32 0, i32 6
  %17 = load ptr, ptr %16, align 8, !tbaa !24
  call void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208) %17, i1 noundef zeroext true)
  %18 = getelementptr inbounds %class.b2Joint, ptr %6, i32 0, i32 7
  %19 = load ptr, ptr %18, align 8, !tbaa !25
  call void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208) %19, i1 noundef zeroext true)
  %20 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %21 = trunc i8 %20 to i1
  %22 = getelementptr inbounds %class.b2PrismaticJoint, ptr %6, i32 0, i32 14
  %23 = zext i1 %21 to i8
  store i8 %23, ptr %22, align 8, !tbaa !13
  %24 = getelementptr inbounds %class.b2PrismaticJoint, ptr %6, i32 0, i32 8
  store float 0.000000e+00, ptr %24, align 8, !tbaa !26
  %25 = getelementptr inbounds %class.b2PrismaticJoint, ptr %6, i32 0, i32 9
  store float 0.000000e+00, ptr %25, align 4, !tbaa !27
  br label %26

26:                                               ; preds = %15, %2
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208), i1 noundef zeroext) #1 align 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 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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !10, i64 200}
!14 = !{!"_ZTS16b2PrismaticJoint", !15, i64 0, !21, i64 128, !21, i64 136, !21, i64 144, !21, i64 152, !22, i64 160, !21, i64 164, !22, i64 172, !22, i64 176, !22, i64 180, !22, i64 184, !22, i64 188, !22, i64 192, !22, i64 196, !10, i64 200, !10, i64 201, !18, i64 204, !18, i64 208, !21, i64 212, !21, i64 220, !22, i64 228, !22, i64 232, !22, i64 236, !22, i64 240, !21, i64 244, !21, i64 252, !22, i64 260, !22, i64 264, !22, i64 268, !22, i64 272, !23, i64 276, !22, i64 292, !22, i64 296}
!15 = !{!"_ZTS7b2Joint", !16, i64 8, !6, i64 16, !6, i64 24, !17, i64 32, !17, i64 64, !6, i64 96, !6, i64 104, !18, i64 112, !10, i64 116, !10, i64 117, !19, i64 120}
!16 = !{!"_ZTS11b2JointType", !7, i64 0}
!17 = !{!"_ZTS11b2JointEdge", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTS15b2JointUserData", !20, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTS6b2Vec2", !22, i64 0, !22, i64 4}
!22 = !{!"float", !7, i64 0}
!23 = !{!"_ZTS7b2Mat22", !21, i64 0, !21, i64 8}
!24 = !{!15, !6, i64 96}
!25 = !{!15, !6, i64 104}
!26 = !{!14, !22, i64 176}
!27 = !{!14, !22, i64 180}


; 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 nounwind uwtable
define dso_local void @_ZN16b2PrismaticJoint11EnableLimitEb(ptr nocapture noundef nonnull align 8 dereferenceable(300) %0, i1 noundef zeroext %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 200
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !20, !noundef !21
  %5 = zext i1 %1 to i8
  %.not = icmp eq i8 %4, %5
  br i1 %.not, label %12, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  %8 = load ptr, ptr %7, align 8, !tbaa !22
  tail call void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208) %8, i1 noundef zeroext true)
  %9 = getelementptr inbounds i8, ptr %0, i64 104
  %10 = load ptr, ptr %9, align 8, !tbaa !23
  tail call void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208) %10, i1 noundef zeroext true)
  store i8 %5, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 176
  store <2 x float> zeroinitializer, ptr %11, align 8, !tbaa !24
  br label %12

12:                                               ; preds = %6, %2
  ret void
}

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

attributes #0 = { 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 #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" }

!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 200}
!6 = !{!"_ZTS16b2PrismaticJoint", !7, i64 0, !17, i64 128, !17, i64 136, !17, i64 144, !17, i64 152, !18, i64 160, !17, i64 164, !18, i64 172, !18, i64 176, !18, i64 180, !18, i64 184, !18, i64 188, !18, i64 192, !18, i64 196, !14, i64 200, !14, i64 201, !13, i64 204, !13, i64 208, !17, i64 212, !17, i64 220, !18, i64 228, !18, i64 232, !18, i64 236, !18, i64 240, !17, i64 244, !17, i64 252, !18, i64 260, !18, i64 264, !18, i64 268, !18, i64 272, !19, i64 276, !18, i64 292, !18, i64 296}
!7 = !{!"_ZTS7b2Joint", !8, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !12, i64 64, !11, i64 96, !11, i64 104, !13, i64 112, !14, i64 116, !14, i64 117, !15, i64 120}
!8 = !{!"_ZTS11b2JointType", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTS11b2JointEdge", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!13 = !{!"int", !9, i64 0}
!14 = !{!"bool", !9, i64 0}
!15 = !{!"_ZTS15b2JointUserData", !16, i64 0}
!16 = !{!"long", !9, i64 0}
!17 = !{!"_ZTS6b2Vec2", !18, i64 0, !18, i64 4}
!18 = !{!"float", !9, i64 0}
!19 = !{!"_ZTS7b2Mat22", !17, i64 0, !17, i64 8}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!7, !11, i64 96}
!23 = !{!7, !11, i64 104}
!24 = !{!18, !18, i64 0}


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