; LLVM IR from erincatto/box2d :: src (revolute_joint)

; 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.b2JointId = type { i32, i16, i16 }
%struct.b2JointSim = type { i32, i32, i32, i32, %struct.b2Vec2, %struct.b2Vec2, float, float, float, float, %union.anon }
%struct.b2Vec2 = type { float, float }
%union.anon = type { %struct.b2PrismaticJoint }
%struct.b2PrismaticJoint = type { %struct.b2Vec2, %struct.b2Vec2, float, float, float, float, float, float, float, float, float, float, float, i32, i32, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, float, %struct.b2Softness, i8, i8, i8 }
%struct.b2Softness = type { float, float, float }
%struct.b2RevoluteJoint = type { %struct.b2Vec2, float, float, float, float, float, float, float, float, float, float, float, i32, i32, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, float, %struct.b2Softness, i8, i8, i8 }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @b2GetJointSimCheckType(i64, i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @b2RevoluteJoint_SetLimits(i64 %0, float noundef %1, float noundef %2) #2 {
  %4 = alloca %struct.b2JointId, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  store i64 %0, ptr %4, align 4
  store float %1, ptr %5, align 4, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %3
  %9 = load float, ptr %5, align 4, !tbaa !5
  %10 = load float, ptr %6, align 4, !tbaa !5
  %11 = fcmp ole float %9, %10
  br i1 %11, label %16, label %12

12:                                               ; preds = %8
  %13 = call i32 @b2InternalAssertFcn(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 103)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  call void @llvm.trap()
  br label %16

16:                                               ; preds = %15, %12, %8
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = load float, ptr %5, align 4, !tbaa !5
  %20 = fcmp oge float %19, 0xC007E04860000000
  br i1 %20, label %25, label %21

21:                                               ; preds = %18
  %22 = call i32 @b2InternalAssertFcn(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 104)
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  call void @llvm.trap()
  br label %25

25:                                               ; preds = %24, %21, %18
  br label %26

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26
  %28 = load float, ptr %6, align 4, !tbaa !5
  %29 = fcmp ole float %28, 0x4007E04860000000
  br i1 %29, label %34, label %30

30:                                               ; preds = %27
  %31 = call i32 @b2InternalAssertFcn(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 105)
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  call void @llvm.trap()
  br label %34

34:                                               ; preds = %33, %30, %27
  br label %35

35:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %36 = load i64, ptr %4, align 4
  %37 = call ptr @b2GetJointSimCheckType(i64 %36, i32 noundef 5)
  store ptr %37, ptr %7, align 8, !tbaa !9
  %38 = load float, ptr %5, align 4, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.b2JointSim, ptr %39, i32 0, i32 10
  %41 = getelementptr inbounds %struct.b2RevoluteJoint, ptr %40, i32 0, i32 10
  %42 = load float, ptr %41, align 4, !tbaa !11
  %43 = fcmp une float %38, %42
  br i1 %43, label %51, label %44

44:                                               ; preds = %35
  %45 = load float, ptr %6, align 4, !tbaa !5
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.b2JointSim, ptr %46, i32 0, i32 10
  %48 = getelementptr inbounds %struct.b2RevoluteJoint, ptr %47, i32 0, i32 11
  %49 = load float, ptr %48, align 4, !tbaa !11
  %50 = fcmp une float %45, %49
  br i1 %50, label %51, label %70

51:                                               ; preds = %44, %35
  %52 = load float, ptr %5, align 4, !tbaa !5
  %53 = load float, ptr %6, align 4, !tbaa !5
  %54 = call float @b2MinFloat(float noundef %52, float noundef %53)
  %55 = load ptr, ptr %7, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.b2JointSim, ptr %55, i32 0, i32 10
  %57 = getelementptr inbounds %struct.b2RevoluteJoint, ptr %56, i32 0, i32 10
  store float %54, ptr %57, align 4, !tbaa !11
  %58 = load float, ptr %5, align 4, !tbaa !5
  %59 = load float, ptr %6, align 4, !tbaa !5
  %60 = call float @b2MaxFloat(float noundef %58, float noundef %59)
  %61 = load ptr, ptr %7, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.b2JointSim, ptr %61, i32 0, i32 10
  %63 = getelementptr inbounds %struct.b2RevoluteJoint, ptr %62, i32 0, i32 11
  store float %60, ptr %63, align 4, !tbaa !11
  %64 = load ptr, ptr %7, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.b2JointSim, ptr %64, i32 0, i32 10
  %66 = getelementptr inbounds %struct.b2RevoluteJoint, ptr %65, i32 0, i32 3
  store float 0.000000e+00, ptr %66, align 4, !tbaa !11
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.b2JointSim, ptr %67, i32 0, i32 10
  %69 = getelementptr inbounds %struct.b2RevoluteJoint, ptr %68, i32 0, i32 4
  store float 0.000000e+00, ptr %69, align 4, !tbaa !11
  br label %70

70:                                               ; preds = %51, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

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

; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
declare void @llvm.trap() #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @b2MinFloat(float noundef, float noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @b2MaxFloat(float noundef, float noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #4 = { inlinehint 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 #5 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}


; 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 [70 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1

declare ptr @b2GetJointSimCheckType(i64, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @b2RevoluteJoint_SetLimits(i64 %0, float noundef %1, float noundef %2) local_unnamed_addr #1 {
  %4 = fcmp ugt float %1, %2
  br i1 %4, label %5, label %8

5:                                                ; preds = %3
  %6 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 103) #4
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %8, label %7

7:                                                ; preds = %5
  tail call void @llvm.trap()
  unreachable

8:                                                ; preds = %5, %3
  %9 = fcmp ult float %1, 0xC007E04860000000
  br i1 %9, label %10, label %13

10:                                               ; preds = %8
  %11 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 104) #4
  %.not16 = icmp eq i32 %11, 0
  br i1 %.not16, label %13, label %12

12:                                               ; preds = %10
  tail call void @llvm.trap()
  unreachable

13:                                               ; preds = %10, %8
  %14 = fcmp ugt float %2, 0x4007E04860000000
  br i1 %14, label %15, label %18

15:                                               ; preds = %13
  %16 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 105) #4
  %.not17 = icmp eq i32 %16, 0
  br i1 %.not17, label %18, label %17

17:                                               ; preds = %15
  tail call void @llvm.trap()
  unreachable

18:                                               ; preds = %13, %15
  %19 = tail call ptr @b2GetJointSimCheckType(i64 %0, i32 noundef 5) #4
  %20 = getelementptr inbounds i8, ptr %19, i64 92
  %21 = load float, ptr %20, align 4, !tbaa !5
  %22 = fcmp une float %21, %1
  br i1 %22, label %27, label %23

23:                                               ; preds = %18
  %24 = getelementptr inbounds i8, ptr %19, i64 96
  %25 = load float, ptr %24, align 4, !tbaa !5
  %26 = fcmp une float %25, %2
  br i1 %26, label %27, label %32

27:                                               ; preds = %23, %18
  %28 = tail call float @b2MinFloat(float noundef %1, float noundef %2)
  store float %28, ptr %20, align 4, !tbaa !5
  %29 = tail call float @b2MaxFloat(float noundef %1, float noundef %2)
  %30 = getelementptr inbounds i8, ptr %19, i64 96
  store float %29, ptr %30, align 4, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %19, i64 64
  store <2 x float> zeroinitializer, ptr %31, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %27, %23
  ret void
}

declare i32 @b2InternalAssertFcn(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
declare void @llvm.trap() #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @b2MinFloat(float noundef, float noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @b2MaxFloat(float noundef, float noundef) local_unnamed_addr #3

attributes #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 = { 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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #3 = { inlinehint 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 #4 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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