; LLVM IR from yangfengzzz/Arche-webgpu :: vox.animation/runtime/ik_two_bone_job.ll (ZNK3vox9animation12IKTwoBoneJob8ValidateEv)

; 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.vox::animation::IKTwoBoneJob" = type { <4 x float>, <4 x float>, <4 x float>, float, float, float, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3vox9animation12IKTwoBoneJob8ValidateEv(ptr noundef nonnull align 16 dereferenceable(112) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  store i8 1, ptr %3, align 1, !tbaa !9
  %5 = getelementptr inbounds %"struct.vox::animation::IKTwoBoneJob", ptr %4, i32 0, i32 6
  %6 = load ptr, ptr %5, align 16, !tbaa !11
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %16

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"struct.vox::animation::IKTwoBoneJob", ptr %4, i32 0, i32 7
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %16

12:                                               ; preds = %8
  %13 = getelementptr inbounds %"struct.vox::animation::IKTwoBoneJob", ptr %4, i32 0, i32 8
  %14 = load ptr, ptr %13, align 16, !tbaa !15
  %15 = icmp ne ptr %14, null
  br label %16

16:                                               ; preds = %12, %8, %1
  %17 = phi i1 [ false, %8 ], [ false, %1 ], [ %15, %12 ]
  %18 = zext i1 %17 to i32
  %19 = load i8, ptr %3, align 1, !tbaa !9, !range !16, !noundef !17
  %20 = trunc i8 %19 to i1
  %21 = zext i1 %20 to i32
  %22 = and i32 %21, %18
  %23 = icmp ne i32 %22, 0
  %24 = zext i1 %23 to i8
  store i8 %24, ptr %3, align 1, !tbaa !9
  %25 = getelementptr inbounds %"struct.vox::animation::IKTwoBoneJob", ptr %4, i32 0, i32 9
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %32

28:                                               ; preds = %16
  %29 = getelementptr inbounds %"struct.vox::animation::IKTwoBoneJob", ptr %4, i32 0, i32 10
  %30 = load ptr, ptr %29, align 16, !tbaa !19
  %31 = icmp ne ptr %30, null
  br label %32

32:                                               ; preds = %28, %16
  %33 = phi i1 [ false, %16 ], [ %31, %28 ]
  %34 = zext i1 %33 to i32
  %35 = load i8, ptr %3, align 1, !tbaa !9, !range !16, !noundef !17
  %36 = trunc i8 %35 to i1
  %37 = zext i1 %36 to i32
  %38 = and i32 %37, %34
  %39 = icmp ne i32 %38, 0
  %40 = zext i1 %39 to i8
  store i8 %40, ptr %3, align 1, !tbaa !9
  %41 = getelementptr inbounds %"struct.vox::animation::IKTwoBoneJob", ptr %4, i32 0, i32 1
  %42 = load <4 x float>, ptr %41, align 16, !tbaa !20
  %43 = call noundef <2 x i64> @_ZN3vox9simd_math16IsNormalizedEst3EDv4_f(<4 x float> noundef %42)
  %44 = call noundef zeroext i1 @_ZN3vox9simd_math11AreAllTrue1EDv2_x(<2 x i64> noundef %43)
  %45 = zext i1 %44 to i32
  %46 = load i8, ptr %3, align 1, !tbaa !9, !range !16, !noundef !17
  %47 = trunc i8 %46 to i1
  %48 = zext i1 %47 to i32
  %49 = and i32 %48, %45
  %50 = icmp ne i32 %49, 0
  %51 = zext i1 %50 to i8
  store i8 %51, ptr %3, align 1, !tbaa !9
  %52 = load i8, ptr %3, align 1, !tbaa !9, !range !16, !noundef !17
  %53 = trunc i8 %52 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret i1 %53
}

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3vox9simd_math11AreAllTrue1EDv2_x(<2 x i64> noundef) #2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef <2 x i64> @_ZN3vox9simd_math16IsNormalizedEst3EDv4_f(<4 x float> noundef) #2

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="128" "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 64}
!12 = !{!"_ZTSN3vox9animation12IKTwoBoneJobE", !7, i64 0, !7, i64 16, !7, i64 32, !13, i64 48, !13, i64 52, !13, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !6, i64 72}
!15 = !{!12, !6, i64 80}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!12, !6, i64 88}
!19 = !{!12, !6, i64 96}
!20 = !{!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"

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3vox9animation12IKTwoBoneJob8ValidateEv(ptr nocapture noundef nonnull readonly align 16 dereferenceable(112) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load <4 x ptr>, ptr %2, align 16
  %.fr = freeze <4 x ptr> %3
  %4 = getelementptr inbounds i8, ptr %0, i64 96
  %5 = load ptr, ptr %4, align 16
  %6 = icmp ne ptr %5, null
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load <4 x float>, ptr %7, align 16, !tbaa !5
  %9 = tail call noundef <2 x i64> @_ZN3vox9simd_math16IsNormalizedEst3EDv4_f(<4 x float> noundef %8)
  %10 = tail call noundef zeroext i1 @_ZN3vox9simd_math11AreAllTrue1EDv2_x(<2 x i64> noundef %9)
  %11 = icmp eq <4 x ptr> %.fr, zeroinitializer
  %12 = bitcast <4 x i1> %11 to i4
  %13 = icmp eq i4 %12, 0
  %14 = and i1 %10, %13
  %op.rdx8 = select i1 %14, i1 %6, i1 false
  ret i1 %op.rdx8
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3vox9simd_math11AreAllTrue1EDv2_x(<2 x i64> noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef <2 x i64> @_ZN3vox9simd_math16IsNormalizedEst3EDv4_f(<4 x float> noundef) local_unnamed_addr #1

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="128" "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 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="128" "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" }

!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++ TBAA"}


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