; LLVM IR from wmcnamara/crynn :: lib/thirdparty/assimp/contrib/Open3DGC (o3dgcDynamicVectorDecoder)

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

%"class.o3dgc::DynamicVectorDecoder" = type <{ i64, i64, i64, i64, i64, ptr, %"class.o3dgc::DVEncodeParams", i32, [4 x i8] }>
%"class.o3dgc::DVEncodeParams" = type { i64, i32, i32 }

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5o3dgc20DynamicVectorDecoder12DecodeHeaderERNS_13DynamicVectorERKNS_12BinaryStreamE(ptr noundef nonnull align 8 dereferenceable(68) %0, ptr noundef nonnull align 8 dereferenceable(48) %1, ptr noundef nonnull align 8 dereferenceable(28) %2) #1 align 2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %12 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  %13 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %13, ptr %8, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  %16 = call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %14, ptr noundef nonnull align 8 dereferenceable(8) %15, i32 noundef 2)
  store i64 %16, ptr %9, align 8, !tbaa !15
  %17 = load i64, ptr %9, align 8, !tbaa !15
  %18 = icmp ne i64 %17, 498
  br i1 %18, label %19, label %31

19:                                               ; preds = %3
  %20 = load i64, ptr %8, align 8, !tbaa !15
  %21 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  store i64 %20, ptr %21, align 8, !tbaa !9
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  %24 = call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %22, ptr noundef nonnull align 8 dereferenceable(8) %23, i32 noundef 1)
  store i64 %24, ptr %9, align 8, !tbaa !15
  %25 = load i64, ptr %9, align 8, !tbaa !15
  %26 = icmp ne i64 %25, 498
  br i1 %26, label %27, label %28

27:                                               ; preds = %19
  store i32 5, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %71

28:                                               ; preds = %19
  %29 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 7
  store i32 1, ptr %29, align 8, !tbaa !16
  br label %30

30:                                               ; preds = %28
  br label %33

31:                                               ; preds = %3
  %32 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 7
  store i32 2, ptr %32, align 8, !tbaa !16
  br label %33

33:                                               ; preds = %31, %30
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  %36 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 7
  %37 = load i32, ptr %36, align 8, !tbaa !16
  %38 = call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %34, ptr noundef nonnull align 8 dereferenceable(8) %35, i32 noundef %37)
  %39 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 0
  store i64 %38, ptr %39, align 8, !tbaa !17
  %40 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 6
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  %43 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 7
  %44 = load i32, ptr %43, align 8, !tbaa !16
  %45 = call noundef zeroext i8 @_ZNK5o3dgc12BinaryStream9ReadUCharERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %41, ptr noundef nonnull align 8 dereferenceable(8) %42, i32 noundef %44)
  %46 = zext i8 %45 to i32
  call void @_ZN5o3dgc14DVEncodeParams13SetEncodeModeENS_19O3DGCDVEncodingModeE(ptr noundef nonnull align 8 dereferenceable(16) %40, i32 noundef %46)
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  %50 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 7
  %51 = load i32, ptr %50, align 8, !tbaa !16
  %52 = call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %48, ptr noundef nonnull align 8 dereferenceable(8) %49, i32 noundef %51)
  call void @_ZN5o3dgc13DynamicVector10SetNVectorEm(ptr noundef nonnull align 8 dereferenceable(48) %47, i64 noundef %52)
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = call noundef i64 @_ZNK5o3dgc13DynamicVector10GetNVectorEv(ptr noundef nonnull align 8 dereferenceable(48) %53)
  %55 = icmp ugt i64 %54, 0
  br i1 %55, label %56, label %70

56:                                               ; preds = %33
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  %60 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 7
  %61 = load i32, ptr %60, align 8, !tbaa !16
  %62 = call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %58, ptr noundef nonnull align 8 dereferenceable(8) %59, i32 noundef %61)
  call void @_ZN5o3dgc13DynamicVector12SetDimVectorEm(ptr noundef nonnull align 8 dereferenceable(48) %57, i64 noundef %62)
  %63 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 6
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 4
  %66 = getelementptr inbounds %"class.o3dgc::DynamicVectorDecoder", ptr %11, i32 0, i32 7
  %67 = load i32, ptr %66, align 8, !tbaa !16
  %68 = call noundef zeroext i8 @_ZNK5o3dgc12BinaryStream9ReadUCharERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %64, ptr noundef nonnull align 8 dereferenceable(8) %65, i32 noundef %67)
  %69 = zext i8 %68 to i64
  call void @_ZN5o3dgc14DVEncodeParams12SetQuantBitsEm(ptr noundef nonnull align 8 dereferenceable(16) %63, i64 noundef %69)
  br label %70

70:                                               ; preds = %56, %33
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %71

71:                                               ; preds = %70, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %72 = load i32, ptr %4, align 4
  ret i32 %72
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5o3dgc14DVEncodeParams13SetEncodeModeENS_19O3DGCDVEncodingModeE(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZNK5o3dgc12BinaryStream9ReadUCharERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5o3dgc13DynamicVector10SetNVectorEm(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5o3dgc13DynamicVector12SetDimVectorEm(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef) #2 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !11, i64 32}
!10 = !{!"_ZTSN5o3dgc20DynamicVectorDecoderE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !6, i64 40, !12, i64 48, !13, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTSN5o3dgc14DVEncodeParamsE", !11, i64 0, !13, i64 8, !14, i64 12}
!13 = !{!"_ZTSN5o3dgc15O3DGCStreamTypeE", !7, i64 0}
!14 = !{!"_ZTSN5o3dgc19O3DGCDVEncodingModeE", !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !13, i64 64}
!17 = !{!10, !11, 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 range(i32 0, 6) i32 @_ZN5o3dgc20DynamicVectorDecoder12DecodeHeaderERNS_13DynamicVectorERKNS_12BinaryStreamE(ptr noundef nonnull align 8 dereferenceable(68) %0, ptr noundef nonnull align 8 dereferenceable(48) %1, ptr noundef nonnull align 8 dereferenceable(28) %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %2, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef 2)
  %.not = icmp eq i64 %6, 498
  br i1 %.not, label %9, label %7

7:                                                ; preds = %3
  store i64 %5, ptr %4, align 8, !tbaa !5
  %8 = tail call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %2, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef 1)
  %.not14 = icmp eq i64 %8, 498
  br i1 %.not14, label %9, label %26

9:                                                ; preds = %3, %7
  %.sink = phi i32 [ 1, %7 ], [ 2, %3 ]
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 %.sink, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = tail call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %2, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %.sink)
  store i64 %12, ptr %0, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = load i32, ptr %11, align 8, !tbaa !14
  %15 = tail call noundef zeroext i8 @_ZNK5o3dgc12BinaryStream9ReadUCharERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %2, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %14)
  %16 = zext i8 %15 to i32
  tail call void @_ZN5o3dgc14DVEncodeParams13SetEncodeModeENS_19O3DGCDVEncodingModeE(ptr noundef nonnull align 8 dereferenceable(16) %13, i32 noundef %16)
  %17 = load i32, ptr %11, align 8, !tbaa !14
  %18 = tail call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %2, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %17)
  tail call void @_ZN5o3dgc13DynamicVector10SetNVectorEm(ptr noundef nonnull align 8 dereferenceable(48) %1, i64 noundef %18)
  %19 = tail call noundef i64 @_ZNK5o3dgc13DynamicVector10GetNVectorEv(ptr noundef nonnull align 8 dereferenceable(48) %1)
  %.not15 = icmp eq i64 %19, 0
  br i1 %.not15, label %26, label %20

20:                                               ; preds = %9
  %21 = load i32, ptr %11, align 8, !tbaa !14
  %22 = tail call noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %2, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %21)
  tail call void @_ZN5o3dgc13DynamicVector12SetDimVectorEm(ptr noundef nonnull align 8 dereferenceable(48) %1, i64 noundef %22)
  %23 = load i32, ptr %11, align 8, !tbaa !14
  %24 = tail call noundef zeroext i8 @_ZNK5o3dgc12BinaryStream9ReadUCharERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28) %2, ptr noundef nonnull align 8 dereferenceable(8) %4, i32 noundef %23)
  %25 = zext i8 %24 to i64
  tail call void @_ZN5o3dgc14DVEncodeParams12SetQuantBitsEm(ptr noundef nonnull align 8 dereferenceable(16) %13, i64 noundef %25)
  br label %26

26:                                               ; preds = %9, %20, %7
  %.0 = phi i32 [ 5, %7 ], [ 0, %20 ], [ 0, %9 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK5o3dgc12BinaryStream10ReadUInt32ERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5o3dgc14DVEncodeParams13SetEncodeModeENS_19O3DGCDVEncodingModeE(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZNK5o3dgc12BinaryStream9ReadUCharERmNS_15O3DGCStreamTypeE(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5o3dgc13DynamicVector10SetNVectorEm(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5o3dgc13DynamicVector12SetDimVectorEm(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5o3dgc14DVEncodeParams12SetQuantBitsEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) 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 32}
!6 = !{!"_ZTSN5o3dgc20DynamicVectorDecoderE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !11, i64 48, !12, i64 64}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSN5o3dgc14DVEncodeParamsE", !7, i64 0, !12, i64 8, !13, i64 12}
!12 = !{!"_ZTSN5o3dgc15O3DGCStreamTypeE", !8, i64 0}
!13 = !{!"_ZTSN5o3dgc19O3DGCDVEncodingModeE", !8, i64 0}
!14 = !{!6, !12, i64 64}
!15 = !{!6, !7, i64 0}


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