; LLVM IR from yangfengzzz/DigitalVox3 :: vox.render/runtime/animation/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 %56

16:                                               ; preds = %11
  %17 = getelementptr inbounds %"struct.vox::animation::SamplingJob", ptr %7, i32 0, i32 3
  %18 = call noundef zeroext i1 @_ZNK3vox4spanINS_4math12SoaTransformEE5emptyEv(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 3
  %31 = call noundef i64 @_ZNK3vox4spanINS_4math12SoaTransformEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %30)
  %32 = load i32, ptr %6, align 4, !tbaa !19
  %33 = sext i32 %32 to i64
  %34 = icmp uge i64 %31, %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 = getelementptr inbounds %"struct.vox::animation::SamplingJob", ptr %7, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = call noundef i32 @_ZNK3vox9animation13SamplingCache14max_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(104) %43)
  %45 = load i32, ptr %6, align 4, !tbaa !19
  %46 = icmp sge i32 %44, %45
  %47 = zext i1 %46 to i32
  %48 = load i8, ptr %4, align 1, !tbaa !9, !range !17, !noundef !18
  %49 = trunc i8 %48 to i1
  %50 = zext i1 %49 to i32
  %51 = and i32 %50, %47
  %52 = icmp ne i32 %51, 0
  %53 = zext i1 %52 to i8
  store i8 %53, ptr %4, align 1, !tbaa !9
  %54 = load i8, ptr %4, align 1, !tbaa !9, !range !17, !noundef !18
  %55 = trunc i8 %54 to i1
  store i1 %55, ptr %2, align 1
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %56

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

; 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_4math12SoaTransformEE5emptyEv(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 i64 @_ZNK3vox4spanINS_4math12SoaTransformEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3vox9animation13SamplingCache14max_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_4math12SoaTransformEEE", !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 %21, label %4

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

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = tail call noundef zeroext i1 @_ZNK3vox4spanINS_4math12SoaTransformEE5emptyEv(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 = tail call noundef i64 @_ZNK3vox4spanINS_4math12SoaTransformEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %14 = sext i32 %12 to i64
  %15 = icmp uge i64 %13, %14
  %16 = and i1 %15, %10
  %17 = load ptr, ptr %5, align 8, !tbaa !13
  %18 = tail call noundef i32 @_ZNK3vox9animation13SamplingCache14max_soa_tracksEv(ptr noundef nonnull align 8 dereferenceable(104) %17)
  %19 = icmp sge i32 %18, %12
  %20 = and i1 %16, %19
  br label %21

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3vox4spanINS_4math12SoaTransformEE5emptyEv(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 i64 @_ZNK3vox4spanINS_4math12SoaTransformEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3vox9animation13SamplingCache14max_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_4math12SoaTransformEEE", !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