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

; 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::Arithmetic_Codec" = type <{ ptr, ptr, ptr, i32, i32, i32, i32, i32, [4 x i8] }>
%"class.o3dgc::Adaptive_Bit_Model" = type { i32, i32, i32, i32, i32 }
%"class.o3dgc::CompressedTriangleFans" = type <{ %"class.o3dgc::Vector.0", %"class.o3dgc::Vector.0", %"class.o3dgc::Vector.0", %"class.o3dgc::Vector.0", %"class.o3dgc::Vector.0", %"class.o3dgc::Vector.0", ptr, i64, i32, [4 x i8] }>
%"class.o3dgc::Vector.0" = type { ptr, i64, i64 }

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

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

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

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

; 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
declare dso_local void @_ZN5o3dgc12BinaryStream14WriteUInt32BinEm(ptr noundef nonnull align 8 dereferenceable(28), i64 noundef) #1 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

declare void @_ZN5o3dgc16Arithmetic_CodecC1Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #5

declare void @_ZN5o3dgc16Arithmetic_Codec10set_bufferEjPh(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef, ptr noundef) #5

declare i32 @__gxx_personality_v0(...)

declare void @_ZN5o3dgc16Arithmetic_Codec13start_encoderEv(ptr noundef nonnull align 8 dereferenceable(44)) #5

declare noundef i32 @_ZN5o3dgc16Arithmetic_Codec12stop_encoderEv(ptr noundef nonnull align 8 dereferenceable(44)) #5

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

; Function Attrs: nounwind
declare void @_ZN5o3dgc16Arithmetic_CodecD1Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #6

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5o3dgc22CompressedTriangleFans9SaveBinACERKNS_6VectorIlEERNS_12BinaryStreamE(ptr noundef nonnull align 8 dereferenceable(164) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(28) %2) #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca %"class.o3dgc::Arithmetic_Codec", align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"class.o3dgc::Adaptive_Bit_Model", align 4
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef i64 @_ZNK5o3dgc12BinaryStream7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(28) %18)
  store i64 %19, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call noundef i64 @_ZNK5o3dgc6VectorIlE7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(24) %20)
  %22 = mul i64 %21, 8
  %23 = add i64 %22, 100
  %24 = trunc i64 %23 to i32
  store i32 %24, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call noundef i64 @_ZNK5o3dgc6VectorIlE7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(24) %25)
  store i64 %26, ptr %9, align 8, !tbaa !9
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN5o3dgc12BinaryStream14WriteUInt32BinEm(ptr noundef nonnull align 8 dereferenceable(28) %27, i64 noundef 0)
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i64, ptr %9, align 8, !tbaa !9
  call void @_ZN5o3dgc12BinaryStream14WriteUInt32BinEm(ptr noundef nonnull align 8 dereferenceable(28) %28, i64 noundef %29)
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = icmp ugt i64 %30, 0
  br i1 %31, label %32, label %118

32:                                               ; preds = %3
  %33 = getelementptr inbounds %"class.o3dgc::CompressedTriangleFans", ptr %17, i32 0, i32 7
  %34 = load i64, ptr %33, align 8, !tbaa !13
  %35 = load i32, ptr %8, align 4, !tbaa !11
  %36 = zext i32 %35 to i64
  %37 = icmp ult i64 %34, %36
  br i1 %37, label %38, label %51

38:                                               ; preds = %32
  %39 = getelementptr inbounds %"class.o3dgc::CompressedTriangleFans", ptr %17, i32 0, i32 6
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  %41 = icmp eq ptr %40, null
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  call void @_ZdaPv(ptr noundef %40) #8
  br label %43

43:                                               ; preds = %42, %38
  %44 = load i32, ptr %8, align 4, !tbaa !11
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds %"class.o3dgc::CompressedTriangleFans", ptr %17, i32 0, i32 7
  store i64 %45, ptr %46, align 8, !tbaa !13
  %47 = getelementptr inbounds %"class.o3dgc::CompressedTriangleFans", ptr %17, i32 0, i32 7
  %48 = load i64, ptr %47, align 8, !tbaa !13
  %49 = call noalias noundef nonnull ptr @_Znam(i64 noundef %48) #9
  %50 = getelementptr inbounds %"class.o3dgc::CompressedTriangleFans", ptr %17, i32 0, i32 6
  store ptr %49, ptr %50, align 8, !tbaa !17
  br label %51

51:                                               ; preds = %43, %32
  call void @llvm.lifetime.start.p0(i64 48, ptr %10) #7
  call void @_ZN5o3dgc16Arithmetic_CodecC1Ev(ptr noundef nonnull align 8 dereferenceable(44) %10)
  %52 = load i32, ptr %8, align 4, !tbaa !11
  %53 = getelementptr inbounds %"class.o3dgc::CompressedTriangleFans", ptr %17, i32 0, i32 6
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  invoke void @_ZN5o3dgc16Arithmetic_Codec10set_bufferEjPh(ptr noundef nonnull align 8 dereferenceable(44) %10, i32 noundef %52, ptr noundef %54)
          to label %55 unwind label %63

55:                                               ; preds = %51
  invoke void @_ZN5o3dgc16Arithmetic_Codec13start_encoderEv(ptr noundef nonnull align 8 dereferenceable(44) %10)
          to label %56 unwind label %63

56:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 20, ptr %13) #7
  invoke void @_ZN5o3dgc18Adaptive_Bit_ModelC1Ev(ptr noundef nonnull align 4 dereferenceable(20) %13)
          to label %57 unwind label %67

57:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %79, %57
  %59 = load i64, ptr %14, align 8, !tbaa !9
  %60 = load i64, ptr %9, align 8, !tbaa !9
  %61 = icmp ult i64 %59, %60
  br i1 %61, label %71, label %62

62:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %86

63:                                               ; preds = %55, %51
  %64 = landingpad { ptr, i32 }
          cleanup
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %11, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %12, align 4
  br label %117

67:                                               ; preds = %56
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %11, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %12, align 4
  br label %116

71:                                               ; preds = %58
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = load i64, ptr %14, align 8, !tbaa !9
  %74 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5o3dgc6VectorIlEixEm(ptr noundef nonnull align 8 dereferenceable(24) %72, i64 noundef %73)
          to label %75 unwind label %82

75:                                               ; preds = %71
  %76 = load i64, ptr %74, align 8, !tbaa !9
  %77 = trunc i64 %76 to i32
  invoke void @_ZN5o3dgc16Arithmetic_Codec6encodeEjRNS_18Adaptive_Bit_ModelE(ptr noundef nonnull align 8 dereferenceable(44) %10, i32 noundef %77, ptr noundef nonnull align 4 dereferenceable(20) %13)
          to label %78 unwind label %82

78:                                               ; preds = %75
  br label %79

79:                                               ; preds = %78
  %80 = load i64, ptr %14, align 8, !tbaa !9
  %81 = add i64 %80, 1
  store i64 %81, ptr %14, align 8, !tbaa !9
  br label %58, !llvm.loop !18

82:                                               ; preds = %75, %71
  %83 = landingpad { ptr, i32 }
          cleanup
  %84 = extractvalue { ptr, i32 } %83, 0
  store ptr %84, ptr %11, align 8
  %85 = extractvalue { ptr, i32 } %83, 1
  store i32 %85, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %116

86:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %87 = invoke noundef i32 @_ZN5o3dgc16Arithmetic_Codec12stop_encoderEv(ptr noundef nonnull align 8 dereferenceable(44) %10)
          to label %88 unwind label %95

88:                                               ; preds = %86
  %89 = zext i32 %87 to i64
  store i64 %89, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  store i64 0, ptr %16, align 8, !tbaa !9
  br label %90

90:                                               ; preds = %107, %88
  %91 = load i64, ptr %16, align 8, !tbaa !9
  %92 = load i64, ptr %15, align 8, !tbaa !9
  %93 = icmp ult i64 %91, %92
  br i1 %93, label %99, label %94

94:                                               ; preds = %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %114

95:                                               ; preds = %86
  %96 = landingpad { ptr, i32 }
          cleanup
  %97 = extractvalue { ptr, i32 } %96, 0
  store ptr %97, ptr %11, align 8
  %98 = extractvalue { ptr, i32 } %96, 1
  store i32 %98, ptr %12, align 4
  br label %115

99:                                               ; preds = %90
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds %"class.o3dgc::CompressedTriangleFans", ptr %17, i32 0, i32 6
  %102 = load ptr, ptr %101, align 8, !tbaa !17
  %103 = load i64, ptr %16, align 8, !tbaa !9
  %104 = getelementptr inbounds i8, ptr %102, i64 %103
  %105 = load i8, ptr %104, align 1, !tbaa !20
  invoke void @_ZN5o3dgc12BinaryStream14WriteUChar8BinEh(ptr noundef nonnull align 8 dereferenceable(28) %100, i8 noundef zeroext %105)
          to label %106 unwind label %110

106:                                              ; preds = %99
  br label %107

107:                                              ; preds = %106
  %108 = load i64, ptr %16, align 8, !tbaa !9
  %109 = add i64 %108, 1
  store i64 %109, ptr %16, align 8, !tbaa !9
  br label %90, !llvm.loop !21

110:                                              ; preds = %99
  %111 = landingpad { ptr, i32 }
          cleanup
  %112 = extractvalue { ptr, i32 } %111, 0
  store ptr %112, ptr %11, align 8
  %113 = extractvalue { ptr, i32 } %111, 1
  store i32 %113, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %115

114:                                              ; preds = %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 20, ptr %13) #7
  call void @_ZN5o3dgc16Arithmetic_CodecD1Ev(ptr noundef nonnull align 8 dereferenceable(44) %10) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %10) #7
  br label %118

115:                                              ; preds = %110, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %116

116:                                              ; preds = %115, %82, %67
  call void @llvm.lifetime.end.p0(i64 20, ptr %13) #7
  br label %117

117:                                              ; preds = %116, %63
  call void @_ZN5o3dgc16Arithmetic_CodecD1Ev(ptr noundef nonnull align 8 dereferenceable(44) %10) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %125

118:                                              ; preds = %114, %3
  %119 = load ptr, ptr %6, align 8, !tbaa !5
  %120 = load i64, ptr %7, align 8, !tbaa !9
  %121 = load ptr, ptr %6, align 8, !tbaa !5
  %122 = call noundef i64 @_ZNK5o3dgc12BinaryStream7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(28) %121)
  %123 = load i64, ptr %7, align 8, !tbaa !9
  %124 = sub i64 %122, %123
  call void @_ZN5o3dgc12BinaryStream14WriteUInt32BinEmm(ptr noundef nonnull align 8 dereferenceable(28) %119, i64 noundef %120, i64 noundef %124)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  ret i32 0

125:                                              ; preds = %117
  %126 = load ptr, ptr %11, align 8
  %127 = load i32, ptr %12, align 4
  %128 = insertvalue { ptr, i32 } poison, ptr %126, 0
  %129 = insertvalue { ptr, i32 } %128, i32 %127, 1
  resume { ptr, i32 } %129
}

declare void @_ZN5o3dgc18Adaptive_Bit_ModelC1Ev(ptr noundef nonnull align 4 dereferenceable(20)) unnamed_addr #5

declare void @_ZN5o3dgc16Arithmetic_Codec6encodeEjRNS_18Adaptive_Bit_ModelE(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef, ptr noundef nonnull align 4 dereferenceable(20)) #5

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 = { nobuiltin 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 = { nobuiltin allocsize(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 #5 = { "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 #6 = { 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 #7 = { nounwind }
attributes #8 = { builtin nounwind }
attributes #9 = { builtin allocsize(0) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 152}
!14 = !{!"_ZTSN5o3dgc22CompressedTriangleFansE", !15, i64 0, !15, i64 24, !15, i64 48, !15, i64 72, !15, i64 96, !15, i64 120, !6, i64 144, !10, i64 152, !16, i64 160}
!15 = !{!"_ZTSN5o3dgc6VectorIlEE", !6, i64 0, !10, i64 8, !10, i64 16}
!16 = !{!"_ZTSN5o3dgc15O3DGCStreamTypeE", !7, i64 0}
!17 = !{!14, !6, i64 144}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !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"

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5o3dgc6VectorIlEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #4

declare void @_ZN5o3dgc16Arithmetic_CodecC1Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #5

declare void @_ZN5o3dgc16Arithmetic_Codec10set_bufferEjPh(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef, ptr noundef) local_unnamed_addr #5

declare i32 @__gxx_personality_v0(...)

declare void @_ZN5o3dgc16Arithmetic_Codec13start_encoderEv(ptr noundef nonnull align 8 dereferenceable(44)) local_unnamed_addr #5

declare noundef i32 @_ZN5o3dgc16Arithmetic_Codec12stop_encoderEv(ptr noundef nonnull align 8 dereferenceable(44)) local_unnamed_addr #5

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

; Function Attrs: nounwind
declare void @_ZN5o3dgc16Arithmetic_CodecD1Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #6

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5o3dgc22CompressedTriangleFans9SaveBinACERKNS_6VectorIlEERNS_12BinaryStreamE(ptr nocapture noundef nonnull align 8 dereferenceable(164) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(28) %2) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.o3dgc::Arithmetic_Codec", align 8
  %5 = alloca %"class.o3dgc::Adaptive_Bit_Model", align 4
  %6 = tail call noundef i64 @_ZNK5o3dgc12BinaryStream7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(28) %2)
  %7 = tail call noundef i64 @_ZNK5o3dgc6VectorIlE7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.tr = trunc i64 %7 to i32
  %8 = shl i32 %.tr, 3
  %9 = add i32 %8, 100
  %10 = tail call noundef i64 @_ZNK5o3dgc6VectorIlE7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  tail call void @_ZN5o3dgc12BinaryStream14WriteUInt32BinEm(ptr noundef nonnull align 8 dereferenceable(28) %2, i64 noundef 0)
  tail call void @_ZN5o3dgc12BinaryStream14WriteUInt32BinEm(ptr noundef nonnull align 8 dereferenceable(28) %2, i64 noundef %10)
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %54, label %11

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %0, i64 152
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = zext i32 %9 to i64
  %15 = icmp ult i64 %13, %14
  br i1 %15, label %16, label %23

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %0, i64 144
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = icmp eq ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  tail call void @_ZdaPv(ptr noundef nonnull %18) #7
  br label %21

21:                                               ; preds = %20, %16
  store i64 %14, ptr %12, align 8, !tbaa !5
  %22 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %14) #8
  store ptr %22, ptr %17, align 8, !tbaa !13
  br label %23

23:                                               ; preds = %21, %11
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %4) #9
  call void @_ZN5o3dgc16Arithmetic_CodecC1Ev(ptr noundef nonnull align 8 dereferenceable(44) %4)
  %24 = getelementptr inbounds i8, ptr %0, i64 144
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  invoke void @_ZN5o3dgc16Arithmetic_Codec10set_bufferEjPh(ptr noundef nonnull align 8 dereferenceable(44) %4, i32 noundef %9, ptr noundef %25)
          to label %26 unwind label %30

26:                                               ; preds = %23
  invoke void @_ZN5o3dgc16Arithmetic_Codec13start_encoderEv(ptr noundef nonnull align 8 dereferenceable(44) %4)
          to label %27 unwind label %30

27:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %5) #9
  invoke void @_ZN5o3dgc18Adaptive_Bit_ModelC1Ev(ptr noundef nonnull align 4 dereferenceable(20) %5)
          to label %.preheader unwind label %32

28:                                               ; preds = %37
  %29 = invoke noundef i32 @_ZN5o3dgc16Arithmetic_Codec12stop_encoderEv(ptr noundef nonnull align 8 dereferenceable(44) %4)
          to label %41 unwind label %43

30:                                               ; preds = %26, %23
  %31 = landingpad { ptr, i32 }
          cleanup
  br label %53

32:                                               ; preds = %27
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %52

.preheader:                                       ; preds = %27, %37
  %.02738 = phi i64 [ %38, %37 ], [ 0, %27 ]
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK5o3dgc6VectorIlEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.02738)
  %35 = load i64, ptr %34, align 8, !tbaa !14
  %36 = trunc i64 %35 to i32
  invoke void @_ZN5o3dgc16Arithmetic_Codec6encodeEjRNS_18Adaptive_Bit_ModelE(ptr noundef nonnull align 8 dereferenceable(44) %4, i32 noundef %36, ptr noundef nonnull align 4 dereferenceable(20) %5)
          to label %37 unwind label %39

37:                                               ; preds = %.preheader
  %38 = add nuw i64 %.02738, 1
  %exitcond.not = icmp eq i64 %38, %10
  br i1 %exitcond.not, label %28, label %.preheader, !llvm.loop !15

39:                                               ; preds = %.preheader
  %40 = landingpad { ptr, i32 }
          cleanup
  br label %52

41:                                               ; preds = %28
  %42 = zext i32 %29 to i64
  %.not40 = icmp eq i32 %29, 0
  br i1 %.not40, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %48, %41
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %5) #9
  call void @_ZN5o3dgc16Arithmetic_CodecD1Ev(ptr noundef nonnull align 8 dereferenceable(44) %4) #9
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #9
  br label %54

43:                                               ; preds = %28
  %44 = landingpad { ptr, i32 }
          cleanup
  br label %52

.lr.ph:                                           ; preds = %41, %48
  %.039 = phi i64 [ %49, %48 ], [ 0, %41 ]
  %45 = load ptr, ptr %24, align 8, !tbaa !13
  %46 = getelementptr inbounds i8, ptr %45, i64 %.039
  %47 = load i8, ptr %46, align 1, !tbaa !17
  invoke void @_ZN5o3dgc12BinaryStream14WriteUChar8BinEh(ptr noundef nonnull align 8 dereferenceable(28) %2, i8 noundef zeroext %47)
          to label %48 unwind label %50

48:                                               ; preds = %.lr.ph
  %49 = add nuw nsw i64 %.039, 1
  %exitcond41.not = icmp eq i64 %49, %42
  br i1 %exitcond41.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

50:                                               ; preds = %.lr.ph
  %51 = landingpad { ptr, i32 }
          cleanup
  br label %52

52:                                               ; preds = %43, %50, %39, %32
  %.pn35 = phi { ptr, i32 } [ %40, %39 ], [ %33, %32 ], [ %51, %50 ], [ %44, %43 ]
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %5) #9
  br label %53

53:                                               ; preds = %52, %30
  %.pn35.pn = phi { ptr, i32 } [ %.pn35, %52 ], [ %31, %30 ]
  call void @_ZN5o3dgc16Arithmetic_CodecD1Ev(ptr noundef nonnull align 8 dereferenceable(44) %4) #9
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #9
  resume { ptr, i32 } %.pn35.pn

54:                                               ; preds = %._crit_edge, %3
  %55 = call noundef i64 @_ZNK5o3dgc12BinaryStream7GetSizeEv(ptr noundef nonnull align 8 dereferenceable(28) %2)
  %56 = sub i64 %55, %6
  call void @_ZN5o3dgc12BinaryStream14WriteUInt32BinEmm(ptr noundef nonnull align 8 dereferenceable(28) %2, i64 noundef %6, i64 noundef %56)
  ret i32 0
}

declare void @_ZN5o3dgc18Adaptive_Bit_ModelC1Ev(ptr noundef nonnull align 4 dereferenceable(20)) unnamed_addr #5

declare void @_ZN5o3dgc16Arithmetic_Codec6encodeEjRNS_18Adaptive_Bit_ModelE(ptr noundef nonnull align 8 dereferenceable(44), i32 noundef, ptr noundef nonnull align 4 dereferenceable(20)) local_unnamed_addr #5

attributes #0 = { mustprogress 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 = { nobuiltin 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 = { nobuiltin allocsize(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 #5 = { "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 #6 = { 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 #7 = { builtin nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { 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, !11, i64 152}
!6 = !{!"_ZTSN5o3dgc22CompressedTriangleFansE", !7, i64 0, !7, i64 24, !7, i64 48, !7, i64 72, !7, i64 96, !7, i64 120, !8, i64 144, !11, i64 152, !12, i64 160}
!7 = !{!"_ZTSN5o3dgc6VectorIlEE", !8, i64 0, !11, i64 8, !11, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"_ZTSN5o3dgc15O3DGCStreamTypeE", !9, i64 0}
!13 = !{!6, !8, i64 144}
!14 = !{!11, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!9, !9, i64 0}
!18 = distinct !{!18, !16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass