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

; 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::SamplingJob" = type { float, ptr, ptr, %"struct.vox::span" }
%"struct.vox::span" = type { ptr, i64 }

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

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

15:                                               ; preds = %11, %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %44

16:                                               ; preds = %11
  %17 = getelementptr inbounds %"struct.vox::animation::SamplingJob", ptr %7, i32 0, i32 3
  %18 = call noundef zeroext i1 @_ZNK3vox4spanINS_9simd_math12SoaTransformEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %17)
  %19 = xor i1 %18, true
  %20 = zext i1 %19 to i32
  %21 = load i8, ptr %4, align 1, !tbaa !9, !range !17, !noundef !18
  %22 = trunc i8 %21 to i1
  %23 = zext i1 %22 to i32
  %24 = and i32 %23, %20
  %25 = icmp ne i32 %24, 0
  %26 = zext i1 %25 to i8
  store i8 %26, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %27 = getelementptr inbounds %"struct.vox::animation::SamplingJob", ptr %7, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = call noundef i32 @_ZNK3vox9animation9Animation14num_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(64) %28)
  store i32 %29, ptr %6, align 4, !tbaa !19
  %30 = getelementptr inbounds %"struct.vox::animation::SamplingJob", ptr %7, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = call noundef i32 @_ZNK3vox9animation11SamplingJob7Context14max_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(104) %31)
  %33 = load i32, ptr %6, align 4, !tbaa !19
  %34 = icmp sge i32 %32, %33
  %35 = zext i1 %34 to i32
  %36 = load i8, ptr %4, align 1, !tbaa !9, !range !17, !noundef !18
  %37 = trunc i8 %36 to i1
  %38 = zext i1 %37 to i32
  %39 = and i32 %38, %35
  %40 = icmp ne i32 %39, 0
  %41 = zext i1 %40 to i8
  store i8 %41, ptr %4, align 1, !tbaa !9
  %42 = load i8, ptr %4, align 1, !tbaa !9, !range !17, !noundef !18
  %43 = trunc i8 %42 to i1
  store i1 %43, ptr %2, align 1
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %44

44:                                               ; preds = %16, %15
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  %45 = load i1, ptr %2, align 1
  ret i1 %45
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3vox4spanINS_9simd_math12SoaTransformEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3vox9animation9Animation14num_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(64)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3vox9animation11SamplingJob7Context14max_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(104)) #2 align 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"="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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = { 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 8}
!12 = !{!"_ZTSN3vox9animation11SamplingJobE", !13, i64 0, !6, i64 8, !6, i64 16, !14, i64 24}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_ZTSN3vox4spanINS_9simd_math12SoaTransformEEE", !6, i64 0, !15, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!12, !6, i64 16}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!20, !20, i64 0}
!20 = !{!"int", !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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3vox9animation11SamplingJob8ValidateEv(ptr noundef nonnull align 8 dereferenceable(40) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %17, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %.not5 = icmp eq ptr %6, null
  br i1 %.not5, label %17, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = tail call noundef zeroext i1 @_ZNK3vox4spanINS_9simd_math12SoaTransformEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %10 = xor i1 %9, true
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = tail call noundef i32 @_ZNK3vox9animation9Animation14num_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(64) %11)
  %13 = load ptr, ptr %5, align 8, !tbaa !13
  %14 = tail call noundef i32 @_ZNK3vox9animation11SamplingJob7Context14max_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(104) %13)
  %15 = icmp sge i32 %14, %12
  %16 = and i1 %15, %10
  br label %17

17:                                               ; preds = %1, %4, %7
  %.0 = phi i1 [ %16, %7 ], [ false, %4 ], [ false, %1 ]
  ret i1 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3vox4spanINS_9simd_math12SoaTransformEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3vox9animation9Animation14num_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3vox9animation11SamplingJob7Context14max_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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" }

!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, !10, i64 8}
!6 = !{!"_ZTSN3vox9animation11SamplingJobE", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSN3vox4spanINS_9simd_math12SoaTransformEEE", !10, i64 0, !12, i64 8}
!12 = !{!"long", !8, i64 0}
!13 = !{!6, !10, i64 16}


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