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

; 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.b2RevoluteJoint = type { %class.b2Joint, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, float, float, i8, float, float, i8, float, float, float, i32, i32, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, float, float, float, %struct.b2Mat22, float, float }
%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 }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__._ZN15b2RevoluteJoint9SetLimitsEff = external hidden unnamed_addr constant [46 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15b2RevoluteJoint9SetLimitsEff(ptr noundef nonnull align 8 dereferenceable(272) %0, float noundef %1, float noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = load float, ptr %5, align 4, !tbaa !9
  %9 = load float, ptr %6, align 4, !tbaa !9
  %10 = fcmp ole float %8, %9
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  br label %14

12:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 427, ptr noundef @__PRETTY_FUNCTION__._ZN15b2RevoluteJoint9SetLimitsEff) #3
  unreachable

13:                                               ; No predecessors!
  br label %14

14:                                               ; preds = %13, %11
  %15 = load float, ptr %5, align 4, !tbaa !9
  %16 = getelementptr inbounds %class.b2RevoluteJoint, ptr %7, i32 0, i32 12
  %17 = load float, ptr %16, align 8, !tbaa !11
  %18 = fcmp une float %15, %17
  br i1 %18, label %24, label %19

19:                                               ; preds = %14
  %20 = load float, ptr %6, align 4, !tbaa !9
  %21 = getelementptr inbounds %class.b2RevoluteJoint, ptr %7, i32 0, i32 13
  %22 = load float, ptr %21, align 4, !tbaa !22
  %23 = fcmp une float %20, %22
  br i1 %23, label %24, label %35

24:                                               ; preds = %19, %14
  %25 = getelementptr inbounds %class.b2Joint, ptr %7, i32 0, i32 6
  %26 = load ptr, ptr %25, align 8, !tbaa !23
  call void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208) %26, i1 noundef zeroext true)
  %27 = getelementptr inbounds %class.b2Joint, ptr %7, i32 0, i32 7
  %28 = load ptr, ptr %27, align 8, !tbaa !24
  call void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208) %28, i1 noundef zeroext true)
  %29 = getelementptr inbounds %class.b2RevoluteJoint, ptr %7, i32 0, i32 5
  store float 0.000000e+00, ptr %29, align 4, !tbaa !25
  %30 = getelementptr inbounds %class.b2RevoluteJoint, ptr %7, i32 0, i32 6
  store float 0.000000e+00, ptr %30, align 8, !tbaa !26
  %31 = load float, ptr %5, align 4, !tbaa !9
  %32 = getelementptr inbounds %class.b2RevoluteJoint, ptr %7, i32 0, i32 12
  store float %31, ptr %32, align 8, !tbaa !11
  %33 = load float, ptr %6, align 4, !tbaa !9
  %34 = getelementptr inbounds %class.b2RevoluteJoint, ptr %7, i32 0, i32 13
  store float %33, ptr %34, align 4, !tbaa !22
  br label %35

35:                                               ; preds = %24, %19
  ret void
}

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

attributes #0 = { 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 #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 = { 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 #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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 184}
!12 = !{!"_ZTS15b2RevoluteJoint", !13, i64 0, !20, i64 128, !20, i64 136, !20, i64 144, !10, i64 152, !10, i64 156, !10, i64 160, !17, i64 164, !10, i64 168, !10, i64 172, !17, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !16, i64 192, !16, i64 196, !20, i64 200, !20, i64 208, !20, i64 216, !20, i64 224, !10, i64 232, !10, i64 236, !10, i64 240, !10, i64 244, !21, i64 248, !10, i64 264, !10, i64 268}
!13 = !{!"_ZTS7b2Joint", !14, i64 8, !6, i64 16, !6, i64 24, !15, i64 32, !15, i64 64, !6, i64 96, !6, i64 104, !16, i64 112, !17, i64 116, !17, i64 117, !18, i64 120}
!14 = !{!"_ZTS11b2JointType", !7, i64 0}
!15 = !{!"_ZTS11b2JointEdge", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!"int", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTS15b2JointUserData", !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTS6b2Vec2", !10, i64 0, !10, i64 4}
!21 = !{!"_ZTS7b2Mat22", !20, i64 0, !20, i64 8}
!22 = !{!12, !10, i64 188}
!23 = !{!13, !6, i64 96}
!24 = !{!13, !6, i64 104}
!25 = !{!12, !10, i64 156}
!26 = !{!12, !10, i64 160}


; 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 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__._ZN15b2RevoluteJoint9SetLimitsEff = external hidden unnamed_addr constant [46 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN15b2RevoluteJoint9SetLimitsEff(ptr nocapture noundef nonnull align 8 dereferenceable(272) %0, float noundef %1, float noundef %2) local_unnamed_addr #1 align 2 {
  %4 = fcmp ugt float %1, %2
  br i1 %4, label %5, label %6

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 427, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN15b2RevoluteJoint9SetLimitsEff) #3
  unreachable

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 184
  %8 = load float, ptr %7, align 8, !tbaa !5
  %9 = fcmp une float %8, %1
  %10 = getelementptr inbounds i8, ptr %0, i64 188
  %11 = load float, ptr %10, align 4
  %12 = fcmp une float %11, %2
  %or.cond = select i1 %9, i1 true, i1 %12
  br i1 %or.cond, label %13, label %19

13:                                               ; preds = %6
  %14 = getelementptr inbounds i8, ptr %0, i64 96
  %15 = load ptr, ptr %14, align 8, !tbaa !20
  tail call void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208) %15, i1 noundef zeroext true)
  %16 = getelementptr inbounds i8, ptr %0, i64 104
  %17 = load ptr, ptr %16, align 8, !tbaa !21
  tail call void @_ZN6b2Body8SetAwakeEb(ptr noundef nonnull align 8 dereferenceable(208) %17, i1 noundef zeroext true)
  %18 = getelementptr inbounds i8, ptr %0, i64 156
  store <2 x float> zeroinitializer, ptr %18, align 4, !tbaa !22
  store float %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %10, align 4, !tbaa !23
  br label %19

19:                                               ; preds = %6, %13
  ret void
}

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

attributes #0 = { 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 #1 = { 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 = { 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 #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, !18, i64 184}
!6 = !{!"_ZTS15b2RevoluteJoint", !7, i64 0, !17, i64 128, !17, i64 136, !17, i64 144, !18, i64 152, !18, i64 156, !18, i64 160, !14, i64 164, !18, i64 168, !18, i64 172, !14, i64 176, !18, i64 180, !18, i64 184, !18, i64 188, !13, i64 192, !13, i64 196, !17, i64 200, !17, i64 208, !17, i64 216, !17, i64 224, !18, i64 232, !18, i64 236, !18, i64 240, !18, i64 244, !19, i64 248, !18, i64 264, !18, i64 268}
!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 = !{!7, !11, i64 96}
!21 = !{!7, !11, i64 104}
!22 = !{!18, !18, i64 0}
!23 = !{!6, !18, i64 188}


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