; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z11quat_equals4QuatS_f)

; 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"

%union.Quat = type { [4 x float] }
%struct.anon.17 = type { float, float, float, float }

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z11quat_equals4QuatS_f(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3, float noundef %4) #2 {
  %6 = alloca %union.Quat, align 4
  %7 = alloca %union.Quat, align 4
  %8 = alloca float, align 4
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  %13 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %6, i32 0, i32 0
  store <2 x float> %0, ptr %13, align 4
  %14 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %6, i32 0, i32 1
  store <2 x float> %1, ptr %14, align 4
  %15 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 0
  store <2 x float> %2, ptr %15, align 4
  %16 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 1
  store <2 x float> %3, ptr %16, align 4
  store float %4, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  %17 = getelementptr inbounds %struct.anon.17, ptr %6, i32 0, i32 0
  %18 = load float, ptr %17, align 4, !tbaa !9
  %19 = getelementptr inbounds %struct.anon.17, ptr %7, i32 0, i32 0
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = fsub float %18, %20
  %22 = call float @llvm.fabs.f32(float %21)
  %23 = load float, ptr %8, align 4, !tbaa !5
  %24 = fcmp olt float %22, %23
  %25 = zext i1 %24 to i8
  store i8 %25, ptr %9, align 1, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  %26 = getelementptr inbounds %struct.anon.17, ptr %6, i32 0, i32 1
  %27 = load float, ptr %26, align 4, !tbaa !9
  %28 = getelementptr inbounds %struct.anon.17, ptr %7, i32 0, i32 1
  %29 = load float, ptr %28, align 4, !tbaa !9
  %30 = fsub float %27, %29
  %31 = call float @llvm.fabs.f32(float %30)
  %32 = load float, ptr %8, align 4, !tbaa !5
  %33 = fcmp olt float %31, %32
  %34 = zext i1 %33 to i8
  store i8 %34, ptr %10, align 1, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  %35 = getelementptr inbounds %struct.anon.17, ptr %6, i32 0, i32 2
  %36 = load float, ptr %35, align 4, !tbaa !9
  %37 = getelementptr inbounds %struct.anon.17, ptr %7, i32 0, i32 2
  %38 = load float, ptr %37, align 4, !tbaa !9
  %39 = fsub float %36, %38
  %40 = call float @llvm.fabs.f32(float %39)
  %41 = load float, ptr %8, align 4, !tbaa !5
  %42 = fcmp olt float %40, %41
  %43 = zext i1 %42 to i8
  store i8 %43, ptr %11, align 1, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  %44 = getelementptr inbounds %struct.anon.17, ptr %6, i32 0, i32 3
  %45 = load float, ptr %44, align 4, !tbaa !9
  %46 = getelementptr inbounds %struct.anon.17, ptr %7, i32 0, i32 3
  %47 = load float, ptr %46, align 4, !tbaa !9
  %48 = fsub float %45, %47
  %49 = call float @llvm.fabs.f32(float %48)
  %50 = load float, ptr %8, align 4, !tbaa !5
  %51 = fcmp olt float %49, %50
  %52 = zext i1 %51 to i8
  store i8 %52, ptr %12, align 1, !tbaa !10
  %53 = load i8, ptr %9, align 1, !tbaa !10, !range !12, !noundef !13
  %54 = trunc i8 %53 to i1
  br i1 %54, label %55, label %64

55:                                               ; preds = %5
  %56 = load i8, ptr %10, align 1, !tbaa !10, !range !12, !noundef !13
  %57 = trunc i8 %56 to i1
  br i1 %57, label %58, label %64

58:                                               ; preds = %55
  %59 = load i8, ptr %11, align 1, !tbaa !10, !range !12, !noundef !13
  %60 = trunc i8 %59 to i1
  br i1 %60, label %61, label %64

61:                                               ; preds = %58
  %62 = load i8, ptr %12, align 1, !tbaa !10, !range !12, !noundef !13
  %63 = trunc i8 %62 to i1
  br label %64

64:                                               ; preds = %61, %58, %55, %5
  %65 = phi i1 [ false, %58 ], [ false, %55 ], [ false, %5 ], [ %63, %61 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  ret i1 %65
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress 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 #3 = { 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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"bool", !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}


; 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 noundef zeroext i1 @_Z11quat_equals4QuatS_f(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3, float noundef %4) local_unnamed_addr #1 {
  %6 = fsub <2 x float> %0, %2
  %7 = extractelement <2 x float> %6, i64 0
  %8 = tail call float @llvm.fabs.f32(float %7)
  %9 = fcmp olt float %8, %4
  br i1 %9, label %10, label %22

10:                                               ; preds = %5
  %11 = fsub <2 x float> %1, %3
  %12 = tail call <2 x float> @llvm.fabs.v2f32(<2 x float> %11)
  %13 = insertelement <2 x float> poison, float %4, i64 0
  %14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> zeroinitializer
  %15 = fcmp olt <2 x float> %12, %14
  %16 = fsub <2 x float> %0, %2
  %17 = extractelement <2 x float> %16, i64 1
  %18 = tail call float @llvm.fabs.f32(float %17)
  %19 = fcmp olt float %18, %4
  %20 = extractelement <2 x i1> %15, i64 0
  %brmerge.not = select i1 %19, i1 %20, i1 false
  %21 = extractelement <2 x i1> %15, i64 1
  %spec.select = select i1 %brmerge.not, i1 %21, i1 false
  br label %22

22:                                               ; preds = %10, %5
  %23 = phi i1 [ false, %5 ], [ %spec.select, %10 ]
  ret i1 %23
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fabs.v2f32(<2 x float>) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn 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,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass