; LLVM IR from yangfengzzz/DigitalVox3 :: vox.render/geometry/skinning_job.ll (ZNK3vox8geometry11SkinningJob3RunEv)

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

@.str.1 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3vox8geometry11SkinningJob3RunEv = external hidden unnamed_addr constant [45 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [41 x i8], align 1
@_ZN3vox8geometryL12kSkinningFctE = external hidden constant [2 x [5 x [3 x ptr]]], align 16

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3vox8geometry11SkinningJob8ValidateEv(ptr noundef nonnull align 8 dereferenceable(232)) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3vox4spanIKfE5emptyEv(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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3vox8geometry11SkinningJob3RunEv(ptr noundef nonnull align 8 dereferenceable(232) %0) #0 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = call noundef zeroext i1 @_ZNK3vox8geometry11SkinningJob8ValidateEv(ptr noundef nonnull align 8 dereferenceable(232) %7)
  br i1 %8, label %10, label %9

9:                                                ; preds = %1
  store i1 false, ptr %2, align 1
  br label %67

10:                                               ; preds = %1
  %11 = getelementptr inbounds %"struct.vox::geometry::SkinningJob", ptr %7, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %10
  store i1 true, ptr %2, align 1
  br label %67

15:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %16 = getelementptr inbounds %"struct.vox::geometry::SkinningJob", ptr %7, i32 0, i32 3
  %17 = call noundef zeroext i1 @_ZNK3vox4spanIKNS_4math8Float4x4EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %16)
  %18 = xor i1 %17, true
  %19 = zext i1 %18 to i64
  store i64 %19, ptr %4, align 8, !tbaa !17
  %20 = load i64, ptr %4, align 8, !tbaa !17
  %21 = icmp ult i64 %20, 2
  br i1 %21, label %22, label %23

22:                                               ; preds = %15
  br label %25

23:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 485, ptr noundef @__PRETTY_FUNCTION__._ZNK3vox8geometry11SkinningJob3RunEv) #5
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %26 = getelementptr inbounds %"struct.vox::geometry::SkinningJob", ptr %7, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !18
  %28 = sext i32 %27 to i64
  %29 = icmp ugt i64 %28, 5
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  br label %36

31:                                               ; preds = %25
  %32 = getelementptr inbounds %"struct.vox::geometry::SkinningJob", ptr %7, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !18
  %34 = sub nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  br label %36

36:                                               ; preds = %31, %30
  %37 = phi i64 [ 4, %30 ], [ %35, %31 ]
  store i64 %37, ptr %5, align 8, !tbaa !17
  %38 = load i64, ptr %5, align 8, !tbaa !17
  %39 = icmp ult i64 %38, 5
  br i1 %39, label %40, label %41

40:                                               ; preds = %36
  br label %43

41:                                               ; preds = %36
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 490, ptr noundef @__PRETTY_FUNCTION__._ZNK3vox8geometry11SkinningJob3RunEv) #5
  unreachable

42:                                               ; No predecessors!
  br label %43

43:                                               ; preds = %42, %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %44 = getelementptr inbounds %"struct.vox::geometry::SkinningJob", ptr %7, i32 0, i32 10
  %45 = call noundef zeroext i1 @_ZNK3vox4spanIKfE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %44)
  %46 = xor i1 %45, true
  %47 = zext i1 %46 to i32
  %48 = getelementptr inbounds %"struct.vox::geometry::SkinningJob", ptr %7, i32 0, i32 12
  %49 = call noundef zeroext i1 @_ZNK3vox4spanIKfE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %48)
  %50 = xor i1 %49, true
  %51 = zext i1 %50 to i32
  %52 = add nsw i32 %47, %51
  %53 = sext i32 %52 to i64
  store i64 %53, ptr %6, align 8, !tbaa !17
  %54 = load i64, ptr %6, align 8, !tbaa !17
  %55 = icmp ult i64 %54, 3
  br i1 %55, label %56, label %57

56:                                               ; preds = %43
  br label %59

57:                                               ; preds = %43
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 492, ptr noundef @__PRETTY_FUNCTION__._ZNK3vox8geometry11SkinningJob3RunEv) #5
  unreachable

58:                                               ; No predecessors!
  br label %59

59:                                               ; preds = %58, %56
  %60 = load i64, ptr %4, align 8, !tbaa !17
  %61 = getelementptr inbounds [2 x [5 x [3 x ptr]]], ptr @_ZN3vox8geometryL12kSkinningFctE, i64 0, i64 %60
  %62 = load i64, ptr %5, align 8, !tbaa !17
  %63 = getelementptr inbounds [5 x [3 x ptr]], ptr %61, i64 0, i64 %62
  %64 = load i64, ptr %6, align 8, !tbaa !17
  %65 = getelementptr inbounds [3 x ptr], ptr %63, i64 0, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  call void %66(ptr noundef nonnull align 8 dereferenceable(232) %7)
  store i1 true, ptr %2, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %67

67:                                               ; preds = %59, %14, %9
  %68 = load i1, ptr %2, align 1
  ret i1 %68
}

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 = { noreturn nounwind "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 #4 = { nounwind }
attributes #5 = { noreturn 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, !11, i64 0}
!10 = !{!"_ZTSN3vox8geometry11SkinningJobE", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 24, !14, i64 40, !13, i64 56, !15, i64 64, !13, i64 80, !15, i64 88, !13, i64 104, !15, i64 112, !13, i64 128, !15, i64 136, !13, i64 152, !16, i64 160, !13, i64 176, !16, i64 184, !13, i64 200, !16, i64 208, !13, i64 224}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN3vox4spanIKNS_4math8Float4x4EEE", !6, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSN3vox4spanIKtEE", !6, i64 0, !13, i64 8}
!15 = !{!"_ZTSN3vox4spanIKfEE", !6, i64 0, !13, i64 8}
!16 = !{!"_ZTSN3vox4spanIfEE", !6, i64 0, !13, i64 8}
!17 = !{!13, !13, i64 0}
!18 = !{!10, !11, i64 4}


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

@.str.1 = external hidden unnamed_addr constant [93 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3vox8geometry11SkinningJob3RunEv = external hidden unnamed_addr constant [45 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [38 x i8], align 1
@_ZN3vox8geometryL12kSkinningFctE = external hidden local_unnamed_addr constant [2 x [5 x [3 x ptr]]], align 16

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

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3vox8geometry11SkinningJob3RunEv(ptr noundef nonnull align 8 dereferenceable(232) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef zeroext i1 @_ZNK3vox8geometry11SkinningJob8ValidateEv(ptr noundef nonnull align 8 dereferenceable(232) %0)
  %3 = load i32, ptr %0, align 8
  %4 = icmp ne i32 %3, 0
  %or.cond.not = select i1 %2, i1 %4, i1 false
  br i1 %or.cond.not, label %5, label %29

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = tail call noundef zeroext i1 @_ZNK3vox4spanIKNS_4math8Float4x4EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp ugt i32 %9, 5
  %11 = add nsw i32 %9, -1
  %narrow = select i1 %10, i32 4, i32 %11
  %12 = icmp ult i32 %narrow, 5
  br i1 %12, label %14, label %13

13:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 490, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3vox8geometry11SkinningJob3RunEv) #3
  unreachable

14:                                               ; preds = %5
  %15 = zext nneg i32 %narrow to i64
  %16 = xor i1 %7, true
  %17 = zext i1 %16 to i64
  %18 = getelementptr inbounds i8, ptr %0, i64 112
  %19 = tail call noundef zeroext i1 @_ZNK3vox4spanIKfE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %18)
  %20 = getelementptr inbounds i8, ptr %0, i64 136
  %21 = tail call noundef zeroext i1 @_ZNK3vox4spanIKfE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %20)
  %22 = xor i1 %21, true
  %23 = xor i1 %19, true
  %24 = zext i1 %23 to i64
  %25 = zext i1 %22 to i64
  %26 = add nuw nsw i64 %25, %24
  %27 = getelementptr inbounds [2 x [5 x [3 x ptr]]], ptr @_ZN3vox8geometryL12kSkinningFctE, i64 0, i64 %17, i64 %15, i64 %26
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  tail call void %28(ptr noundef nonnull align 8 dereferenceable(232) %0)
  br label %29

29:                                               ; preds = %1, %14
  ret i1 %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" }
attributes #2 = { noreturn nounwind "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 = { noreturn 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, !7, i64 4}
!6 = !{!"_ZTSN3vox8geometry11SkinningJobE", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 24, !13, i64 40, !12, i64 56, !14, i64 64, !12, i64 80, !14, i64 88, !12, i64 104, !14, i64 112, !12, i64 128, !14, i64 136, !12, i64 152, !15, i64 160, !12, i64 176, !15, i64 184, !12, i64 200, !15, i64 208, !12, i64 224}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN3vox4spanIKNS_4math8Float4x4EEE", !11, i64 0, !12, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_ZTSN3vox4spanIKtEE", !11, i64 0, !12, i64 8}
!14 = !{!"_ZTSN3vox4spanIKfEE", !11, i64 0, !12, i64 8}
!15 = !{!"_ZTSN3vox4spanIfEE", !11, i64 0, !12, i64 8}
!16 = !{!11, !11, i64 0}


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