; LLVM IR from yangfengzzz/DigitalVox3 :: vox.render/runtime/animation (local_to_model_job)

; 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::LocalToModelJob" = type { ptr, ptr, i32, i32, i8, %"struct.vox::span", %"struct.vox::span.0" }
%"struct.vox::span" = type { ptr, i64 }
%"struct.vox::span.0" = type { ptr, i64 }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3vox9animation15LocalToModelJob8ValidateEv(ptr noundef nonnull align 8 dereferenceable(64) %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 i64, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %8 = 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
  %9 = getelementptr inbounds %"struct.vox::animation::LocalToModelJob", ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %45

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %14 = getelementptr inbounds %"struct.vox::animation::LocalToModelJob", ptr %8, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = call noundef i32 @_ZNK3vox9animation8Skeleton10num_jointsEv(ptr noundef nonnull align 8 dereferenceable(48) %15)
  %17 = sext i32 %16 to i64
  store i64 %17, ptr %6, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %18 = load i64, ptr %6, align 8, !tbaa !17
  %19 = add i64 %18, 3
  %20 = udiv i64 %19, 4
  store i64 %20, ptr %7, align 8, !tbaa !17
  %21 = getelementptr inbounds %"struct.vox::animation::LocalToModelJob", ptr %8, i32 0, i32 5
  %22 = call noundef i64 @_ZNK3vox4spanIKNS_4math12SoaTransformEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %21)
  %23 = load i64, ptr %7, align 8, !tbaa !17
  %24 = icmp uge i64 %22, %23
  %25 = zext i1 %24 to i32
  %26 = load i8, ptr %4, align 1, !tbaa !9, !range !18, !noundef !19
  %27 = trunc i8 %26 to i1
  %28 = zext i1 %27 to i32
  %29 = and i32 %28, %25
  %30 = icmp ne i32 %29, 0
  %31 = zext i1 %30 to i8
  store i8 %31, ptr %4, align 1, !tbaa !9
  %32 = getelementptr inbounds %"struct.vox::animation::LocalToModelJob", ptr %8, i32 0, i32 6
  %33 = call noundef i64 @_ZNK3vox4spanINS_4math8Float4x4EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %32)
  %34 = load i64, ptr %6, align 8, !tbaa !17
  %35 = icmp uge i64 %33, %34
  %36 = zext i1 %35 to i32
  %37 = load i8, ptr %4, align 1, !tbaa !9, !range !18, !noundef !19
  %38 = trunc i8 %37 to i1
  %39 = zext i1 %38 to i32
  %40 = and i32 %39, %36
  %41 = icmp ne i32 %40, 0
  %42 = zext i1 %41 to i8
  store i8 %42, ptr %4, align 1, !tbaa !9
  %43 = load i8, ptr %4, align 1, !tbaa !9, !range !18, !noundef !19
  %44 = trunc i8 %43 to i1
  store i1 %44, ptr %2, align 1
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %45

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3vox9animation8Skeleton10num_jointsEv(ptr noundef nonnull align 8 dereferenceable(48)) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3vox4spanINS_4math8Float4x4EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #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 0}
!12 = !{!"_ZTSN3vox9animation15LocalToModelJobE", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20, !10, i64 24, !14, i64 32, !16, i64 48}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN3vox4spanIKNS_4math12SoaTransformEEE", !6, i64 0, !15, i64 8}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSN3vox4spanINS_4math8Float4x4EEE", !6, i64 0, !15, i64 8}
!17 = !{!15, !15, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}


; 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 @_ZNK3vox9animation15LocalToModelJob8ValidateEv(ptr noundef nonnull align 8 dereferenceable(64) %0) local_unnamed_addr #0 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %15, label %3

3:                                                ; preds = %1
  %4 = tail call noundef i32 @_ZNK3vox9animation8Skeleton10num_jointsEv(ptr noundef nonnull align 8 dereferenceable(48) %2)
  %5 = sext i32 %4 to i64
  %6 = add nsw i64 %5, 3
  %7 = lshr i64 %6, 2
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = tail call noundef i64 @_ZNK3vox4spanIKNS_4math12SoaTransformEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %10 = icmp uge i64 %9, %7
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = tail call noundef i64 @_ZNK3vox4spanINS_4math8Float4x4EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %13 = icmp uge i64 %12, %5
  %14 = and i1 %13, %10
  br label %15

15:                                               ; preds = %1, %3
  %.0 = phi i1 [ %14, %3 ], [ false, %1 ]
  ret i1 %.0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3vox4spanIKNS_4math12SoaTransformEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3vox4spanINS_4math8Float4x4EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN3vox9animation15LocalToModelJobE", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !11, i64 24, !12, i64 32, !14, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTSN3vox4spanIKNS_4math12SoaTransformEEE", !7, i64 0, !13, i64 8}
!13 = !{!"long", !8, i64 0}
!14 = !{!"_ZTSN3vox4spanINS_4math8Float4x4EEE", !7, i64 0, !13, i64 8}


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