; LLVM IR from Overload-Technologies/Overload :: Dependencies/assimp/code/Common/ZipArchiveIOSystem.ll (ZN6Assimp7ZipFile4ReadEPvmm)

; 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::ZipFile" = type { %"class.Assimp::IOStream", %"class.std::__cxx11::basic_string", i64, i64, %"class.std::unique_ptr" }
%"class.Assimp::IOStream" = type { ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.4" }
%"struct.std::_Head_base.4" = type { ptr }

@.str.5 = external hidden unnamed_addr constant [119 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1

; 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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN6Assimp7ZipFile4ReadEPvmm(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) unnamed_addr #4 align 2 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !9
  %12 = load ptr, ptr %6, align 8
  %13 = getelementptr inbounds %"class.Assimp::ZipFile", ptr %12, i32 0, i32 4
  %14 = call noundef zeroext i1 @_ZStneIA_hSt14default_deleteIS0_EEbRKSt10unique_ptrIT_T0_EDn(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr null) #6
  br i1 %14, label %16, label %15

15:                                               ; preds = %4
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str.7, ptr noundef @.str.5, i32 noundef 300)
  br label %16

16:                                               ; preds = %15, %4
  %17 = phi i1 [ true, %4 ], [ false, %15 ]
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = icmp ne ptr null, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str.8, ptr noundef @.str.5, i32 noundef 301)
  br label %21

21:                                               ; preds = %20, %16
  %22 = phi i1 [ true, %16 ], [ false, %20 ]
  %23 = load i64, ptr %8, align 8, !tbaa !9
  %24 = icmp ne i64 0, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str.9, ptr noundef @.str.5, i32 noundef 302)
  br label %26

26:                                               ; preds = %25, %21
  %27 = phi i1 [ true, %21 ], [ false, %25 ]
  %28 = load i64, ptr %9, align 8, !tbaa !9
  %29 = icmp ne i64 0, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str.10, ptr noundef @.str.5, i32 noundef 303)
  br label %31

31:                                               ; preds = %30, %26
  %32 = phi i1 [ true, %26 ], [ false, %30 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %33 = load i64, ptr %8, align 8, !tbaa !9
  %34 = load i64, ptr %9, align 8, !tbaa !9
  %35 = mul i64 %33, %34
  store i64 %35, ptr %10, align 8, !tbaa !9
  %36 = load i64, ptr %10, align 8, !tbaa !9
  %37 = getelementptr inbounds %"class.Assimp::ZipFile", ptr %12, i32 0, i32 3
  %38 = load i64, ptr %37, align 8, !tbaa !11
  %39 = add i64 %36, %38
  %40 = getelementptr inbounds %"class.Assimp::ZipFile", ptr %12, i32 0, i32 2
  %41 = load i64, ptr %40, align 8, !tbaa !22
  %42 = icmp ugt i64 %39, %41
  br i1 %42, label %43, label %58

43:                                               ; preds = %31
  %44 = getelementptr inbounds %"class.Assimp::ZipFile", ptr %12, i32 0, i32 2
  %45 = load i64, ptr %44, align 8, !tbaa !22
  %46 = getelementptr inbounds %"class.Assimp::ZipFile", ptr %12, i32 0, i32 3
  %47 = load i64, ptr %46, align 8, !tbaa !11
  %48 = sub i64 %45, %47
  %49 = load i64, ptr %8, align 8, !tbaa !9
  %50 = udiv i64 %48, %49
  store i64 %50, ptr %9, align 8, !tbaa !9
  %51 = load i64, ptr %8, align 8, !tbaa !9
  %52 = load i64, ptr %9, align 8, !tbaa !9
  %53 = mul i64 %51, %52
  store i64 %53, ptr %10, align 8, !tbaa !9
  %54 = load i64, ptr %10, align 8, !tbaa !9
  %55 = icmp eq i64 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %43
  store i64 0, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %71

57:                                               ; preds = %43
  br label %58

58:                                               ; preds = %57, %31
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.Assimp::ZipFile", ptr %12, i32 0, i32 4
  %61 = call noundef ptr @_ZNKSt10unique_ptrIA_hSt14default_deleteIS0_EE3getEv(ptr noundef nonnull align 8 dereferenceable(8) %60) #6
  %62 = getelementptr inbounds %"class.Assimp::ZipFile", ptr %12, i32 0, i32 3
  %63 = load i64, ptr %62, align 8, !tbaa !11
  %64 = getelementptr inbounds i8, ptr %61, i64 %63
  %65 = load i64, ptr %10, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %59, ptr align 1 %64, i64 %65, i1 false)
  %66 = load i64, ptr %10, align 8, !tbaa !9
  %67 = getelementptr inbounds %"class.Assimp::ZipFile", ptr %12, i32 0, i32 3
  %68 = load i64, ptr %67, align 8, !tbaa !11
  %69 = add i64 %68, %66
  store i64 %69, ptr %67, align 8, !tbaa !11
  %70 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %70, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %71

71:                                               ; preds = %58, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %72 = load i64, ptr %5, align 8
  ret i64 %72
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneIA_hSt14default_deleteIS0_EEbRKSt10unique_ptrIT_T0_EDn(ptr noundef nonnull align 8 dereferenceable(8), ptr) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { inlinehint 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 #6 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 48}
!12 = !{!"_ZTSN6Assimp7ZipFileE", !13, i64 0, !14, i64 8, !10, i64 40, !10, i64 48, !16, i64 56}
!13 = !{!"_ZTSN6Assimp8IOStreamE"}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !10, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"_ZTSSt10unique_ptrIA_hSt14default_deleteIS0_EE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_dataIhSt14default_deleteIA_hELb1ELb1EE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_implIhSt14default_deleteIA_hEE", !19, i64 0}
!19 = !{!"_ZTSSt5tupleIJPhSt14default_deleteIA_hEEE", !20, i64 0}
!20 = !{!"_ZTSSt11_Tuple_implILm0EJPhSt14default_deleteIA_hEEE", !21, i64 0}
!21 = !{!"_ZTSSt10_Head_baseILm0EPhLb0EE", !6, i64 0}
!22 = !{!12, !10, i64 40}


; 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.5 = external hidden unnamed_addr constant [119 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN6Assimp7ZipFile4ReadEPvmm(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef writeonly %1, i64 noundef %2, i64 noundef %3) unnamed_addr #3 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %6 = tail call noundef zeroext i1 @_ZStneIA_hSt14default_deleteIS0_EEbRKSt10unique_ptrIT_T0_EDn(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr null) #5
  br i1 %6, label %8, label %7

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

8:                                                ; preds = %7, %4
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %8
  tail call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.5, i32 noundef 301)
  br label %10

10:                                               ; preds = %9, %8
  %.not19 = icmp eq i64 %2, 0
  br i1 %.not19, label %11, label %12

11:                                               ; preds = %10
  tail call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.5, i32 noundef 302)
  br label %12

12:                                               ; preds = %11, %10
  %.not20 = icmp eq i64 %3, 0
  br i1 %.not20, label %13, label %14

13:                                               ; preds = %12
  tail call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.5, i32 noundef 303)
  br label %14

14:                                               ; preds = %13, %12
  %15 = mul i64 %3, %2
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = add i64 %17, %15
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %20 = load i64, ptr %19, align 8, !tbaa !20
  %21 = icmp ugt i64 %18, %20
  br i1 %21, label %22, label %27

22:                                               ; preds = %14
  %23 = sub i64 %20, %17
  %24 = udiv i64 %23, %2
  %25 = mul i64 %24, %2
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %33, label %27

27:                                               ; preds = %22, %14
  %.015 = phi i64 [ %24, %22 ], [ %3, %14 ]
  %.0 = phi i64 [ %25, %22 ], [ %15, %14 ]
  %28 = tail call noundef ptr @_ZNKSt10unique_ptrIA_hSt14default_deleteIS0_EE3getEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  %29 = load i64, ptr %16, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %28, i64 %29
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr align 1 %30, i64 %.0, i1 false)
  %31 = load i64, ptr %16, align 8, !tbaa !5
  %32 = add i64 %31, %.0
  store i64 %32, ptr %16, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %22, %27
  %.016 = phi i64 [ %.015, %27 ], [ 0, %22 ]
  ret i64 %.016
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneIA_hSt14default_deleteIS0_EEbRKSt10unique_ptrIT_T0_EDn(ptr noundef nonnull align 8 dereferenceable(8), ptr) local_unnamed_addr #4

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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #5 = { 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, !13, i64 48}
!6 = !{!"_ZTSN6Assimp7ZipFileE", !7, i64 0, !8, i64 8, !13, i64 40, !13, i64 48, !14, i64 56}
!7 = !{!"_ZTSN6Assimp8IOStreamE"}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !9, i64 0, !13, i64 8, !11, i64 16}
!9 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !10, i64 0}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"long", !11, i64 0}
!14 = !{!"_ZTSSt10unique_ptrIA_hSt14default_deleteIS0_EE", !15, i64 0}
!15 = !{!"_ZTSSt15__uniq_ptr_dataIhSt14default_deleteIA_hELb1ELb1EE", !16, i64 0}
!16 = !{!"_ZTSSt15__uniq_ptr_implIhSt14default_deleteIA_hEE", !17, i64 0}
!17 = !{!"_ZTSSt5tupleIJPhSt14default_deleteIA_hEEE", !18, i64 0}
!18 = !{!"_ZTSSt11_Tuple_implILm0EJPhSt14default_deleteIA_hEEE", !19, i64 0}
!19 = !{!"_ZTSSt10_Head_baseILm0EPhLb0EE", !10, i64 0}
!20 = !{!6, !13, i64 40}


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