; LLVM IR from erincatto/box2d :: src (prismatic_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 }

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 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 @b2PrismaticJoint_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 87)
  %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
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %18 = load i64, ptr %4, align 4
  %19 = call ptr @b2GetJointSimCheckType(i64 %18, i32 noundef 4)
  store ptr %19, ptr %7, align 8, !tbaa !9
  %20 = load float, ptr %5, align 4, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.b2JointSim, ptr %21, i32 0, i32 10
  %23 = getelementptr inbounds %struct.b2PrismaticJoint, ptr %22, i32 0, i32 11
  %24 = load float, ptr %23, align 4, !tbaa !11
  %25 = fcmp une float %20, %24
  br i1 %25, label %33, label %26

26:                                               ; preds = %17
  %27 = load float, ptr %6, align 4, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.b2JointSim, ptr %28, i32 0, i32 10
  %30 = getelementptr inbounds %struct.b2PrismaticJoint, ptr %29, i32 0, i32 12
  %31 = load float, ptr %30, align 4, !tbaa !11
  %32 = fcmp une float %27, %31
  br i1 %32, label %33, label %52

33:                                               ; preds = %26, %17
  %34 = load float, ptr %5, align 4, !tbaa !5
  %35 = load float, ptr %6, align 4, !tbaa !5
  %36 = call float @b2MinFloat(float noundef %34, float noundef %35)
  %37 = load ptr, ptr %7, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.b2JointSim, ptr %37, i32 0, i32 10
  %39 = getelementptr inbounds %struct.b2PrismaticJoint, ptr %38, i32 0, i32 11
  store float %36, ptr %39, align 4, !tbaa !11
  %40 = load float, ptr %5, align 4, !tbaa !5
  %41 = load float, ptr %6, align 4, !tbaa !5
  %42 = call float @b2MaxFloat(float noundef %40, float noundef %41)
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.b2JointSim, ptr %43, i32 0, i32 10
  %45 = getelementptr inbounds %struct.b2PrismaticJoint, ptr %44, i32 0, i32 12
  store float %42, ptr %45, align 4, !tbaa !11
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.b2JointSim, ptr %46, i32 0, i32 10
  %48 = getelementptr inbounds %struct.b2PrismaticJoint, ptr %47, i32 0, i32 4
  store float 0.000000e+00, ptr %48, align 4, !tbaa !11
  %49 = load ptr, ptr %7, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.b2JointSim, ptr %49, i32 0, i32 10
  %51 = getelementptr inbounds %struct.b2PrismaticJoint, ptr %50, i32 0, i32 5
  store float 0.000000e+00, ptr %51, align 4, !tbaa !11
  br label %52

52:                                               ; preds = %33, %26
  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 [71 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @b2PrismaticJoint_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 87) #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 = %3, %5
  %9 = tail call ptr @b2GetJointSimCheckType(i64 %0, i32 noundef 4) #4
  %10 = getelementptr inbounds i8, ptr %9, i64 100
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = fcmp une float %11, %1
  br i1 %12, label %17, label %13

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %9, i64 104
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = fcmp une float %15, %2
  br i1 %16, label %17, label %22

17:                                               ; preds = %13, %8
  %18 = tail call float @b2MinFloat(float noundef %1, float noundef %2)
  store float %18, ptr %10, align 4, !tbaa !5
  %19 = tail call float @b2MaxFloat(float noundef %1, float noundef %2)
  %20 = getelementptr inbounds i8, ptr %9, i64 104
  store float %19, ptr %20, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %9, i64 72
  store <2 x float> zeroinitializer, ptr %21, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %17, %13
  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