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

; 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.b2Vec2 = type { float, float }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f32(float, i32 immarg) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @b2IsValidVec2(<2 x float> %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca %struct.b2Vec2, align 4
  store <2 x float> %0, ptr %3, align 4
  %4 = getelementptr inbounds %struct.b2Vec2, ptr %3, i32 0, i32 0
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = call i1 @llvm.is.fpclass.f32(float %5, i32 3)
  br i1 %6, label %11, label %7

7:                                                ; preds = %1
  %8 = getelementptr inbounds %struct.b2Vec2, ptr %3, i32 0, i32 1
  %9 = load float, ptr %8, align 4, !tbaa !10
  %10 = call i1 @llvm.is.fpclass.f32(float %9, i32 3)
  br i1 %10, label %11, label %12

11:                                               ; preds = %7, %1
  store i1 false, ptr %2, align 1
  br label %34

12:                                               ; preds = %7
  %13 = getelementptr inbounds %struct.b2Vec2, ptr %3, i32 0, i32 0
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = call float @llvm.fabs.f32(float %14) #2
  %16 = fcmp oeq float %15, 0x7FF0000000000000
  %17 = bitcast float %14 to i32
  %18 = icmp slt i32 %17, 0
  %19 = select i1 %18, i32 -1, i32 1
  %20 = select i1 %16, i32 %19, i32 0
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %32, label %22

22:                                               ; preds = %12
  %23 = getelementptr inbounds %struct.b2Vec2, ptr %3, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !10
  %25 = call float @llvm.fabs.f32(float %24) #2
  %26 = fcmp oeq float %25, 0x7FF0000000000000
  %27 = bitcast float %24 to i32
  %28 = icmp slt i32 %27, 0
  %29 = select i1 %28, i32 -1, i32 1
  %30 = select i1 %26, i32 %29, i32 0
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %22, %12
  store i1 false, ptr %2, align 1
  br label %34

33:                                               ; preds = %22
  store i1 true, ptr %2, align 1
  br label %34

34:                                               ; preds = %33, %32, %11
  %35 = load i1, ptr %2, align 1
  ret i1 %35
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { memory(none) }

!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, !7, i64 0}
!6 = !{!"b2Vec2", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local zeroext i1 @b2IsValidVec2(<2 x float> %0) local_unnamed_addr #1 {
  %.sroa.0.0.vec.extract = extractelement <2 x float> %0, i64 0
  %2 = fcmp uno float %.sroa.0.0.vec.extract, 0.000000e+00
  br i1 %2, label %10, label %3

3:                                                ; preds = %1
  %.sroa.0.4.vec.extract = extractelement <2 x float> %0, i64 1
  %4 = fcmp uno float %.sroa.0.4.vec.extract, 0.000000e+00
  br i1 %4, label %10, label %5

5:                                                ; preds = %3
  %6 = tail call float @llvm.fabs.f32(float %.sroa.0.0.vec.extract) #2
  %7 = fcmp une float %6, 0x7FF0000000000000
  %8 = tail call float @llvm.fabs.f32(float %.sroa.0.4.vec.extract) #2
  %9 = fcmp une float %8, 0x7FF0000000000000
  %or.cond.not = and i1 %7, %9
  br label %10

10:                                               ; preds = %5, %1, %3
  %.0 = phi i1 [ false, %3 ], [ false, %1 ], [ %or.cond.not, %5 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="64" "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 = { memory(none) }

!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)"}


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