; LLVM IR from Overload-Technologies/Overload :: Dependencies/assimp/code/Common (Compression)

; 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.Assimp::Compression" = type { ptr }
%"struct.Assimp::Compression::impl" = type <{ i8, [7 x i8], %struct.z_stream_s, i32, [4 x i8] }>
%struct.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [112 x i8], align 1
@_ZTI17DeadlyImportError = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.5 = external hidden unnamed_addr constant [46 x i8], align 1

declare i32 @__gxx_personality_v0(...)

declare void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef, ptr noundef, i32 noundef) #0

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

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

declare i32 @inflate(ptr noundef, i32 noundef) #0

declare ptr @__cxa_allocate_exception(i64)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN6Assimp11Compression15decompressBlockEPKvmPcm(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4) #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i64 %4, ptr %11, align 8, !tbaa !9
  %15 = load ptr, ptr %7, align 8
  %16 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %5
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 176)
  br label %20

20:                                               ; preds = %19, %5
  %21 = phi i1 [ true, %5 ], [ false, %19 ]
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %33, label %24

24:                                               ; preds = %20
  %25 = load i64, ptr %9, align 8, !tbaa !9
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %33, label %27

27:                                               ; preds = %24
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %33, label %30

30:                                               ; preds = %27
  %31 = load i64, ptr %11, align 8, !tbaa !9
  %32 = icmp eq i64 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %30, %27, %24, %20
  store i64 0, ptr %6, align 8
  br label %99

34:                                               ; preds = %30
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %37, i32 0, i32 2
  %39 = getelementptr inbounds %struct.z_stream_s, ptr %38, i32 0, i32 0
  store ptr %35, ptr %39, align 8, !tbaa !13
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = trunc i64 %40 to i32
  %42 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %43, i32 0, i32 2
  %45 = getelementptr inbounds %struct.z_stream_s, ptr %44, i32 0, i32 1
  store i32 %41, ptr %45, align 8, !tbaa !19
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %48, i32 0, i32 2
  %50 = getelementptr inbounds %struct.z_stream_s, ptr %49, i32 0, i32 3
  store ptr %46, ptr %50, align 8, !tbaa !20
  %51 = load i64, ptr %11, align 8, !tbaa !9
  %52 = trunc i64 %51 to i32
  %53 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %54, i32 0, i32 2
  %56 = getelementptr inbounds %struct.z_stream_s, ptr %55, i32 0, i32 4
  store i32 %52, ptr %56, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %57 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !11
  %59 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %58, i32 0, i32 2
  %60 = call i32 @inflate(ptr noundef %59, i32 noundef 2)
  store i32 %60, ptr %12, align 4, !tbaa !22
  %61 = load i32, ptr %12, align 4, !tbaa !22
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %73

63:                                               ; preds = %34
  %64 = load i32, ptr %12, align 4, !tbaa !22
  %65 = icmp ne i32 %64, 1
  br i1 %65, label %66, label %73

66:                                               ; preds = %63
  %67 = call ptr @__cxa_allocate_exception(i64 16) #4
  invoke void @_ZN17DeadlyImportErrorC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %67, ptr noundef @.str.5)
          to label %68 unwind label %69

68:                                               ; preds = %66
  call void @__cxa_throw(ptr %67, ptr @_ZTI17DeadlyImportError, ptr @_ZNSt13runtime_errorD2Ev) #5
  unreachable

69:                                               ; preds = %66
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %13, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %14, align 4
  call void @__cxa_free_exception(ptr %67) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %101

73:                                               ; preds = %63, %34
  %74 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !11
  %76 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %75, i32 0, i32 2
  %77 = call i32 @inflateReset(ptr noundef %76)
  %78 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !11
  %80 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %79, i32 0, i32 2
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load i64, ptr %11, align 8, !tbaa !9
  %83 = trunc i64 %82 to i32
  %84 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !11
  %86 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %85, i32 0, i32 2
  %87 = getelementptr inbounds %struct.z_stream_s, ptr %86, i32 0, i32 4
  %88 = load i32, ptr %87, align 8, !tbaa !21
  %89 = sub i32 %83, %88
  %90 = call i32 @inflateSetDictionary(ptr noundef %80, ptr noundef %81, i32 noundef %89)
  %91 = load i64, ptr %11, align 8, !tbaa !9
  %92 = getelementptr inbounds %"class.Assimp::Compression", ptr %15, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !11
  %94 = getelementptr inbounds %"struct.Assimp::Compression::impl", ptr %93, i32 0, i32 2
  %95 = getelementptr inbounds %struct.z_stream_s, ptr %94, i32 0, i32 4
  %96 = load i32, ptr %95, align 8, !tbaa !21
  %97 = zext i32 %96 to i64
  %98 = sub i64 %91, %97
  store i64 %98, ptr %6, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %99

99:                                               ; preds = %73, %33
  %100 = load i64, ptr %6, align 8
  ret i64 %100

101:                                              ; preds = %69
  %102 = load ptr, ptr %13, align 8
  %103 = load i32, ptr %14, align 4
  %104 = insertvalue { ptr, i32 } poison, ptr %102, 0
  %105 = insertvalue { ptr, i32 } %104, i32 %103, 1
  resume { ptr, i32 } %105
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17DeadlyImportErrorC2EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #3 align 2

declare i32 @inflateReset(ptr noundef) #0

declare i32 @inflateSetDictionary(ptr noundef, ptr noundef, i32 noundef) #0

attributes #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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn }

!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, !6, i64 0}
!12 = !{!"_ZTSN6Assimp11CompressionE", !6, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTSN6Assimp11Compression4implE", !15, i64 0, !16, i64 8, !18, i64 120}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTS10z_stream_s", !6, i64 0, !17, i64 8, !10, i64 16, !6, i64 24, !17, i64 32, !10, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !17, i64 88, !10, i64 96, !10, i64 104}
!17 = !{!"int", !7, i64 0}
!18 = !{!"_ZTSN6Assimp11Compression9FlushModeE", !7, i64 0}
!19 = !{!14, !17, i64 16}
!20 = !{!14, !6, i64 32}
!21 = !{!14, !17, i64 40}
!22 = !{!17, !17, 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"

@.str = external hidden unnamed_addr constant [17 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [112 x i8], align 1
@_ZTI17DeadlyImportError = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.5 = external hidden unnamed_addr constant [46 x i8], align 1

declare i32 @__gxx_personality_v0(...)

declare void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @inflate(ptr noundef, i32 noundef) local_unnamed_addr #0

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN6Assimp11Compression15decompressBlockEPKvmPcm(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %8

7:                                                ; preds = %5
  tail call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 176)
  br label %8

8:                                                ; preds = %7, %5
  %9 = icmp eq ptr %1, null
  %10 = icmp eq i64 %2, 0
  %or.cond = or i1 %9, %10
  %11 = icmp eq ptr %3, null
  %or.cond3 = or i1 %or.cond, %11
  %12 = icmp eq i64 %4, 0
  %or.cond5 = or i1 %or.cond3, %12
  br i1 %or.cond5, label %42, label %13

13:                                               ; preds = %8
  %14 = load ptr, ptr %0, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  store ptr %1, ptr %15, align 8, !tbaa !10
  %16 = trunc i64 %2 to i32
  %17 = getelementptr inbounds i8, ptr %14, i64 16
  store i32 %16, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %14, i64 32
  store ptr %3, ptr %18, align 8, !tbaa !18
  %19 = trunc i64 %4 to i32
  %20 = getelementptr inbounds i8, ptr %14, i64 40
  store i32 %19, ptr %20, align 8, !tbaa !19
  %21 = tail call i32 @inflate(ptr noundef nonnull %15, i32 noundef 2)
  %or.cond7 = icmp ugt i32 %21, 1
  br i1 %or.cond7, label %22, label %27

22:                                               ; preds = %13
  %23 = tail call ptr @__cxa_allocate_exception(i64 16) #3
  invoke void @_ZN17DeadlyImportErrorC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull @.str.5)
          to label %24 unwind label %25

24:                                               ; preds = %22
  tail call void @__cxa_throw(ptr nonnull %23, ptr nonnull @_ZTI17DeadlyImportError, ptr nonnull @_ZNSt13runtime_errorD2Ev) #4
  unreachable

25:                                               ; preds = %22
  %26 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %23) #3
  resume { ptr, i32 } %26

27:                                               ; preds = %13
  %28 = load ptr, ptr %0, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = tail call i32 @inflateReset(ptr noundef nonnull %29)
  %31 = load ptr, ptr %0, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %31, i64 8
  %33 = getelementptr inbounds i8, ptr %31, i64 40
  %34 = load i32, ptr %33, align 8, !tbaa !19
  %35 = sub i32 %19, %34
  %36 = tail call i32 @inflateSetDictionary(ptr noundef nonnull %32, ptr noundef nonnull %3, i32 noundef %35)
  %37 = load ptr, ptr %0, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 40
  %39 = load i32, ptr %38, align 8, !tbaa !19
  %40 = zext i32 %39 to i64
  %41 = sub i64 %4, %40
  br label %42

42:                                               ; preds = %8, %27
  %.0 = phi i64 [ %41, %27 ], [ 0, %8 ]
  ret i64 %.0
}

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

declare i32 @inflateReset(ptr noundef) local_unnamed_addr #0

declare i32 @inflateSetDictionary(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

attributes #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 = { 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 #2 = { 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 #3 = { nounwind }
attributes #4 = { noreturn }

!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 = !{!"_ZTSN6Assimp11CompressionE", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 8}
!11 = !{!"_ZTSN6Assimp11Compression4implE", !12, i64 0, !13, i64 8, !16, i64 120}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"_ZTS10z_stream_s", !7, i64 0, !14, i64 8, !15, i64 16, !7, i64 24, !14, i64 32, !15, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !14, i64 88, !15, i64 96, !15, i64 104}
!14 = !{!"int", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!"_ZTSN6Assimp11Compression9FlushModeE", !8, i64 0}
!17 = !{!11, !14, i64 16}
!18 = !{!11, !7, i64 32}
!19 = !{!11, !14, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass