; LLVM IR from heremaps/tin-terrain :: src/BinaryIO.ll (ZN4tntn8BinaryIO10write_implEPKvmmPKcRNS_20BinaryIOErrorTrackerE)

; 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.tntn::BinaryIO" = type { %"class.std::shared_ptr", i32, i64, i64 }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"struct.tntn::BinaryIOErrorTracker" = type { %"struct.tntn::BinaryIOError", %"struct.tntn::BinaryIOError" }
%"struct.tntn::BinaryIOError" = type { ptr, i64, i32, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN4tntn8FileLikeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #1 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) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIPhEvT_S1_(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4tntn8BinaryIO10write_implEPKvmmPKcRNS_20BinaryIOErrorTrackerE(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef nonnull align 8 dereferenceable(80) %5) #4 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i8, align 1
  %16 = alloca [34 x i8], align 16
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i8, align 1
  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 i64 %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = icmp ugt i64 %21, 32
  br i1 %22, label %23, label %24

23:                                               ; preds = %6
  br label %166

24:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %25 = load i64, ptr %9, align 8, !tbaa !9
  %26 = load i64, ptr %10, align 8, !tbaa !9
  %27 = mul i64 %25, %26
  store i64 %27, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %28, ptr %14, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = icmp eq i32 1, %30
  br i1 %31, label %32, label %86

32:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #5
  %33 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 0
  %34 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4tntn8FileLikeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %33) #5
  %35 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 3
  %36 = load i64, ptr %35, align 8, !tbaa !17
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  %38 = load i64, ptr %13, align 8, !tbaa !9
  %39 = load ptr, ptr %34, align 8, !tbaa !18
  %40 = getelementptr inbounds ptr, ptr %39, i64 6
  %41 = load ptr, ptr %40, align 8
  %42 = call noundef zeroext i1 %41(ptr noundef nonnull align 8 dereferenceable(8) %34, i64 noundef %36, ptr noundef %37, i64 noundef %38)
  %43 = zext i1 %42 to i8
  store i8 %43, ptr %15, align 1, !tbaa !20
  %44 = load i8, ptr %15, align 1, !tbaa !20, !range !22, !noundef !23
  %45 = trunc i8 %44 to i1
  br i1 %45, label %77, label %46

46:                                               ; preds = %32
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %48, i32 0, i32 1
  %50 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %49, i32 0, i32 0
  store ptr %47, ptr %50, align 8, !tbaa !24
  %51 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 3
  %52 = load i64, ptr %51, align 8, !tbaa !17
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %53, i32 0, i32 1
  %55 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %54, i32 0, i32 1
  store i64 %52, ptr %55, align 8, !tbaa !28
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %57, i32 0, i32 2
  store i32 2, ptr %58, align 8, !tbaa !29
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %59, i32 0, i32 1
  %61 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %60, i32 0, i32 4
  store i64 0, ptr %61, align 8, !tbaa !30
  %62 = load i64, ptr %13, align 8, !tbaa !9
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %63, i32 0, i32 1
  %65 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %64, i32 0, i32 3
  store i64 %62, ptr %65, align 8, !tbaa !31
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !32
  %70 = icmp ne ptr %69, null
  br i1 %70, label %76, label %71

71:                                               ; preds = %46
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %72, i32 0, i32 1
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %74, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %75, ptr align 8 %73, i64 40, i1 false), !tbaa.struct !33
  br label %76

76:                                               ; preds = %71, %46
  br label %77

77:                                               ; preds = %76, %32
  %78 = load i8, ptr %15, align 1, !tbaa !20, !range !22, !noundef !23
  %79 = trunc i8 %78 to i1
  br i1 %79, label %80, label %85

80:                                               ; preds = %77
  %81 = load i64, ptr %13, align 8, !tbaa !9
  %82 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 3
  %83 = load i64, ptr %82, align 8, !tbaa !17
  %84 = add i64 %83, %81
  store i64 %84, ptr %82, align 8, !tbaa !17
  br label %85

85:                                               ; preds = %80, %77
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #5
  br label %165

86:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 34, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %87 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %87, ptr %17, align 8, !tbaa !5
  br label %88

88:                                               ; preds = %159, %86
  %89 = load ptr, ptr %17, align 8, !tbaa !5
  %90 = load ptr, ptr %14, align 8, !tbaa !5
  %91 = load i64, ptr %13, align 8, !tbaa !9
  %92 = getelementptr inbounds i8, ptr %90, i64 %91
  %93 = icmp ult ptr %89, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %88
  store i32 2, ptr %18, align 4
  br label %163

95:                                               ; preds = %88
  %96 = getelementptr inbounds [34 x i8], ptr %16, i64 0, i64 0
  %97 = load ptr, ptr %17, align 8, !tbaa !5
  %98 = load i64, ptr %9, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %96, ptr align 1 %97, i64 %98, i1 false)
  %99 = getelementptr inbounds [34 x i8], ptr %16, i64 0, i64 0
  %100 = getelementptr inbounds [34 x i8], ptr %16, i64 0, i64 0
  %101 = load i64, ptr %9, align 8, !tbaa !9
  %102 = getelementptr inbounds i8, ptr %100, i64 %101
  call void @_ZSt7reverseIPhEvT_S1_(ptr noundef %99, ptr noundef %102)
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #5
  %103 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 0
  %104 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4tntn8FileLikeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %103) #5
  %105 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 3
  %106 = load i64, ptr %105, align 8, !tbaa !17
  %107 = getelementptr inbounds [34 x i8], ptr %16, i64 0, i64 0
  %108 = load i64, ptr %9, align 8, !tbaa !9
  %109 = load ptr, ptr %104, align 8, !tbaa !18
  %110 = getelementptr inbounds ptr, ptr %109, i64 6
  %111 = load ptr, ptr %110, align 8
  %112 = call noundef zeroext i1 %111(ptr noundef nonnull align 8 dereferenceable(8) %104, i64 noundef %106, ptr noundef %107, i64 noundef %108)
  %113 = zext i1 %112 to i8
  store i8 %113, ptr %19, align 1, !tbaa !20
  %114 = load i8, ptr %19, align 1, !tbaa !20, !range !22, !noundef !23
  %115 = trunc i8 %114 to i1
  br i1 %115, label %147, label %116

116:                                              ; preds = %95
  %117 = load ptr, ptr %11, align 8, !tbaa !5
  %118 = load ptr, ptr %12, align 8, !tbaa !5
  %119 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %118, i32 0, i32 1
  %120 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %119, i32 0, i32 0
  store ptr %117, ptr %120, align 8, !tbaa !24
  %121 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 3
  %122 = load i64, ptr %121, align 8, !tbaa !17
  %123 = load ptr, ptr %12, align 8, !tbaa !5
  %124 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %123, i32 0, i32 1
  %125 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %124, i32 0, i32 1
  store i64 %122, ptr %125, align 8, !tbaa !28
  %126 = load ptr, ptr %12, align 8, !tbaa !5
  %127 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %126, i32 0, i32 1
  %128 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %127, i32 0, i32 2
  store i32 2, ptr %128, align 8, !tbaa !29
  %129 = load ptr, ptr %12, align 8, !tbaa !5
  %130 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %129, i32 0, i32 1
  %131 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %130, i32 0, i32 4
  store i64 0, ptr %131, align 8, !tbaa !30
  %132 = load i64, ptr %13, align 8, !tbaa !9
  %133 = load ptr, ptr %12, align 8, !tbaa !5
  %134 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %133, i32 0, i32 1
  %135 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %134, i32 0, i32 3
  store i64 %132, ptr %135, align 8, !tbaa !31
  %136 = load ptr, ptr %12, align 8, !tbaa !5
  %137 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %136, i32 0, i32 0
  %138 = getelementptr inbounds %"struct.tntn::BinaryIOError", ptr %137, i32 0, i32 0
  %139 = load ptr, ptr %138, align 8, !tbaa !32
  %140 = icmp ne ptr %139, null
  br i1 %140, label %146, label %141

141:                                              ; preds = %116
  %142 = load ptr, ptr %12, align 8, !tbaa !5
  %143 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %142, i32 0, i32 1
  %144 = load ptr, ptr %12, align 8, !tbaa !5
  %145 = getelementptr inbounds %"struct.tntn::BinaryIOErrorTracker", ptr %144, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %145, ptr align 8 %143, i64 40, i1 false), !tbaa.struct !33
  br label %146

146:                                              ; preds = %141, %116
  store i32 2, ptr %18, align 4
  br label %156

147:                                              ; preds = %95
  %148 = load i8, ptr %19, align 1, !tbaa !20, !range !22, !noundef !23
  %149 = trunc i8 %148 to i1
  br i1 %149, label %150, label %155

150:                                              ; preds = %147
  %151 = load i64, ptr %13, align 8, !tbaa !9
  %152 = getelementptr inbounds %"class.tntn::BinaryIO", ptr %20, i32 0, i32 3
  %153 = load i64, ptr %152, align 8, !tbaa !17
  %154 = add i64 %153, %151
  store i64 %154, ptr %152, align 8, !tbaa !17
  br label %155

155:                                              ; preds = %150, %147
  store i32 0, ptr %18, align 4
  br label %156

156:                                              ; preds = %155, %146
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #5
  %157 = load i32, ptr %18, align 4
  switch i32 %157, label %163 [
    i32 0, label %158
  ]

158:                                              ; preds = %156
  br label %159

159:                                              ; preds = %158
  %160 = load i64, ptr %9, align 8, !tbaa !9
  %161 = load ptr, ptr %17, align 8, !tbaa !5
  %162 = getelementptr inbounds i8, ptr %161, i64 %160
  store ptr %162, ptr %17, align 8, !tbaa !5
  br label %88, !llvm.loop !35

163:                                              ; preds = %156, %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  br label %164

164:                                              ; preds = %163
  call void @llvm.lifetime.end.p0(i64 34, ptr %16) #5
  br label %165

165:                                              ; preds = %164, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %166

166:                                              ; preds = %165, %23
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 = { 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 = { 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, !16, i64 16}
!12 = !{!"_ZTSN4tntn8BinaryIOE", !13, i64 0, !16, i64 16, !10, i64 24, !10, i64 32}
!13 = !{!"_ZTSSt10shared_ptrIN4tntn8FileLikeEE", !14, i64 0}
!14 = !{!"_ZTSSt12__shared_ptrIN4tntn8FileLikeELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !15, i64 8}
!15 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!16 = !{!"_ZTSN4tntn10EndiannessE", !7, i64 0}
!17 = !{!12, !10, i64 32}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!25, !6, i64 40}
!25 = !{!"_ZTSN4tntn20BinaryIOErrorTrackerE", !26, i64 0, !26, i64 40}
!26 = !{!"_ZTSN4tntn13BinaryIOErrorE", !6, i64 0, !10, i64 8, !27, i64 16, !10, i64 24, !10, i64 32}
!27 = !{!"_ZTSN4tntn13BinaryIOError7InOrOutE", !7, i64 0}
!28 = !{!25, !10, i64 48}
!29 = !{!25, !27, i64 56}
!30 = !{!25, !10, i64 72}
!31 = !{!25, !10, i64 64}
!32 = !{!25, !6, i64 0}
!33 = !{i64 0, i64 8, !5, i64 8, i64 8, !9, i64 16, i64 4, !34, i64 24, i64 8, !9, i64 32, i64 8, !9}
!34 = !{!27, !27, i64 0}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; 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 nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN4tntn8FileLikeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIPhEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4tntn8BinaryIO10write_implEPKvmmPKcRNS_20BinaryIOErrorTrackerE(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, ptr nocapture noundef nonnull align 8 dereferenceable(80) %5) local_unnamed_addr #4 align 2 {
  %7 = alloca [34 x i8], align 16
  %8 = icmp ugt i64 %2, 32
  br i1 %8, label %59, label %9

9:                                                ; preds = %6
  %10 = mul i64 %3, %2
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load i32, ptr %11, align 8, !tbaa !5
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %33

14:                                               ; preds = %9
  %15 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN4tntn8FileLikeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #5
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = load ptr, ptr %15, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %18, i64 48
  %20 = load ptr, ptr %19, align 8
  %21 = tail call noundef zeroext i1 %20(ptr noundef nonnull align 8 dereferenceable(8) %15, i64 noundef %17, ptr noundef %1, i64 noundef %10)
  br i1 %21, label %.critedge, label %22

22:                                               ; preds = %14
  %23 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr %4, ptr %23, align 8, !tbaa !18
  %24 = load i64, ptr %16, align 8, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %5, i64 48
  store i64 %24, ptr %25, align 8, !tbaa !22
  %26 = getelementptr inbounds i8, ptr %5, i64 56
  store i32 2, ptr %26, align 8, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %5, i64 72
  store i64 0, ptr %27, align 8, !tbaa !24
  %28 = getelementptr inbounds i8, ptr %5, i64 64
  store i64 %10, ptr %28, align 8, !tbaa !25
  %29 = load ptr, ptr %5, align 8, !tbaa !26
  %.not46 = icmp eq ptr %29, null
  br i1 %.not46, label %30, label %59

30:                                               ; preds = %22
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %5, ptr noundef nonnull align 8 dereferenceable(40) %23, i64 40, i1 false), !tbaa.struct !27
  br label %59

.critedge:                                        ; preds = %14
  %31 = load i64, ptr %16, align 8, !tbaa !15
  %32 = add i64 %31, %10
  store i64 %32, ptr %16, align 8, !tbaa !15
  br label %59

33:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 34, ptr nonnull %7) #5
  %34 = getelementptr inbounds i8, ptr %1, i64 %10
  %35 = icmp sgt i64 %10, 0
  br i1 %35, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %33
  %36 = getelementptr inbounds i8, ptr %7, i64 %2
  %37 = getelementptr inbounds i8, ptr %0, i64 32
  br label %38

38:                                               ; preds = %.lr.ph, %54
  %.047 = phi ptr [ %1, %.lr.ph ], [ %57, %54 ]
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %7, ptr align 1 %.047, i64 %2, i1 false)
  call void @_ZSt7reverseIPhEvT_S1_(ptr noundef nonnull %7, ptr noundef nonnull %36)
  %39 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4tntn8FileLikeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #5
  %40 = load i64, ptr %37, align 8, !tbaa !15
  %41 = load ptr, ptr %39, align 8, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %41, i64 48
  %43 = load ptr, ptr %42, align 8
  %44 = call noundef zeroext i1 %43(ptr noundef nonnull align 8 dereferenceable(8) %39, i64 noundef %40, ptr noundef nonnull %7, i64 noundef %2)
  br i1 %44, label %54, label %45

45:                                               ; preds = %38
  %46 = getelementptr inbounds i8, ptr %5, i64 40
  store ptr %4, ptr %46, align 8, !tbaa !18
  %47 = load i64, ptr %37, align 8, !tbaa !15
  %48 = getelementptr inbounds i8, ptr %5, i64 48
  store i64 %47, ptr %48, align 8, !tbaa !22
  %49 = getelementptr inbounds i8, ptr %5, i64 56
  store i32 2, ptr %49, align 8, !tbaa !23
  %50 = getelementptr inbounds i8, ptr %5, i64 72
  store i64 0, ptr %50, align 8, !tbaa !24
  %51 = getelementptr inbounds i8, ptr %5, i64 64
  store i64 %10, ptr %51, align 8, !tbaa !25
  %52 = load ptr, ptr %5, align 8, !tbaa !26
  %.not = icmp eq ptr %52, null
  br i1 %.not, label %53, label %.thread

53:                                               ; preds = %45
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %5, ptr noundef nonnull align 8 dereferenceable(40) %46, i64 40, i1 false), !tbaa.struct !27
  br label %.thread

54:                                               ; preds = %38
  %55 = load i64, ptr %37, align 8, !tbaa !15
  %56 = add i64 %55, %10
  store i64 %56, ptr %37, align 8, !tbaa !15
  %57 = getelementptr inbounds i8, ptr %.047, i64 %2
  %58 = icmp ult ptr %57, %34
  br i1 %58, label %38, label %.thread, !llvm.loop !31

.thread:                                          ; preds = %54, %33, %53, %45
  call void @llvm.lifetime.end.p0(i64 34, ptr nonnull %7) #5
  br label %59

59:                                               ; preds = %30, %22, %.thread, %.critedge, %6
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 = { 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 16}
!6 = !{!"_ZTSN4tntn8BinaryIOE", !7, i64 0, !13, i64 16, !14, i64 24, !14, i64 32}
!7 = !{!"_ZTSSt10shared_ptrIN4tntn8FileLikeEE", !8, i64 0}
!8 = !{!"_ZTSSt12__shared_ptrIN4tntn8FileLikeELN9__gnu_cxx12_Lock_policyE2EE", !9, i64 0, !12, i64 8}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !9, i64 0}
!13 = !{!"_ZTSN4tntn10EndiannessE", !10, i64 0}
!14 = !{!"long", !10, i64 0}
!15 = !{!6, !14, i64 32}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !11, i64 0}
!18 = !{!19, !9, i64 40}
!19 = !{!"_ZTSN4tntn20BinaryIOErrorTrackerE", !20, i64 0, !20, i64 40}
!20 = !{!"_ZTSN4tntn13BinaryIOErrorE", !9, i64 0, !14, i64 8, !21, i64 16, !14, i64 24, !14, i64 32}
!21 = !{!"_ZTSN4tntn13BinaryIOError7InOrOutE", !10, i64 0}
!22 = !{!19, !14, i64 48}
!23 = !{!19, !21, i64 56}
!24 = !{!19, !14, i64 72}
!25 = !{!19, !14, i64 64}
!26 = !{!19, !9, i64 0}
!27 = !{i64 0, i64 8, !28, i64 8, i64 8, !29, i64 16, i64 4, !30, i64 24, i64 8, !29, i64 32, i64 8, !29}
!28 = !{!9, !9, i64 0}
!29 = !{!14, !14, i64 0}
!30 = !{!21, !21, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass