; LLVM IR from mkazhdan/DMG :: Util/MultiStreamIO.ll (ZN22VariableIOClientStream5writeEPKhm)

; 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.VariableIOClientStream = type { %class.IOClient, i32, ptr, i32, ptr, i32, i32, i8, i8, i64, i64 }
%class.IOClient = type { ptr, %"class.boost::recursive_timed_mutex", ptr }
%"class.boost::recursive_timed_mutex" = type <{ %union.pthread_mutex_t, %union.pthread_cond_t, i8, [7 x i8], i64, i32, [4 x i8] }>
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }

@stderr = external global ptr, align 8
@.str.16 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [30 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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z20EnterCriticalSectionPN5boost21recursive_timed_mutexExPKc(ptr noundef, i64 noundef, ptr noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef) #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 @_ZN22VariableIOClientStream5writeEPKhm(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr noundef %1, i64 noundef %2) #4 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = sext i32 %18 to i64
  %20 = icmp ugt i64 %16, %19
  br i1 %20, label %21, label %25

21:                                               ; preds = %3
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = load i64, ptr %6, align 8, !tbaa !9
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.16, i64 noundef %23) #5
  br label %25

25:                                               ; preds = %21, %3
  %26 = getelementptr inbounds %class.IOClient, ptr %15, i32 0, i32 1
  call void @_Z20EnterCriticalSectionPN5boost21recursive_timed_mutexExPKc(ptr noundef %26, i64 noundef 100, ptr noundef @.str.17)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %27 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 9
  %28 = load i64, ptr %27, align 8, !tbaa !18
  store i64 %28, ptr %7, align 8, !tbaa !19
  %29 = load i64, ptr %7, align 8, !tbaa !19
  %30 = load i64, ptr %6, align 8, !tbaa !9
  %31 = add i64 %29, %30
  store i64 %31, ptr %8, align 8, !tbaa !19
  %32 = load i64, ptr %7, align 8, !tbaa !19
  %33 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = sext i32 %34 to i64
  %36 = sdiv i64 %32, %35
  %37 = load i64, ptr %8, align 8, !tbaa !19
  %38 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = sdiv i64 %37, %40
  %42 = icmp ne i64 %36, %41
  br i1 %42, label %43, label %52

43:                                               ; preds = %25
  %44 = getelementptr inbounds %class.IOClient, ptr %15, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = icmp ne ptr %45, null
  br i1 %46, label %52, label %47

47:                                               ; preds = %43
  %48 = load ptr, ptr %15, align 8, !tbaa !21
  %49 = getelementptr inbounds ptr, ptr %48, i64 0
  %50 = load ptr, ptr %49, align 8
  %51 = call noundef i32 %50(ptr noundef nonnull align 8 dereferenceable(192) %15)
  br label %52

52:                                               ; preds = %47, %43, %25
  %53 = load i64, ptr %7, align 8, !tbaa !19
  %54 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %55 = load i32, ptr %54, align 8, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = sdiv i64 %53, %56
  %58 = trunc i64 %57 to i32
  store i32 %58, ptr %9, align 4, !tbaa !23
  %59 = load i64, ptr %8, align 8, !tbaa !19
  %60 = sub nsw i64 %59, 1
  %61 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %62 = load i32, ptr %61, align 8, !tbaa !11
  %63 = sext i32 %62 to i64
  %64 = sdiv i64 %60, %63
  %65 = trunc i64 %64 to i32
  store i32 %65, ptr %10, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %66 = load i32, ptr %9, align 4, !tbaa !23
  %67 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 3
  %68 = load i32, ptr %67, align 8, !tbaa !24
  %69 = srem i32 %66, %68
  store i32 %69, ptr %11, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %70 = load i32, ptr %10, align 4, !tbaa !23
  %71 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 3
  %72 = load i32, ptr %71, align 8, !tbaa !24
  %73 = srem i32 %70, %72
  store i32 %73, ptr %12, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %74 = load i64, ptr %7, align 8, !tbaa !19
  %75 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %76 = load i32, ptr %75, align 8, !tbaa !11
  %77 = sext i32 %76 to i64
  %78 = srem i64 %74, %77
  %79 = trunc i64 %78 to i32
  store i32 %79, ptr %13, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %80 = load i64, ptr %8, align 8, !tbaa !19
  %81 = sub nsw i64 %80, 1
  %82 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %83 = load i32, ptr %82, align 8, !tbaa !11
  %84 = sext i32 %83 to i64
  %85 = srem i64 %81, %84
  %86 = add nsw i64 %85, 1
  %87 = trunc i64 %86 to i32
  store i32 %87, ptr %14, align 4, !tbaa !23
  %88 = load i32, ptr %11, align 4, !tbaa !23
  %89 = load i32, ptr %12, align 4, !tbaa !23
  %90 = icmp eq i32 %88, %89
  br i1 %90, label %91, label %108

91:                                               ; preds = %52
  %92 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 2
  %93 = load ptr, ptr %92, align 8, !tbaa !25
  %94 = load i32, ptr %11, align 4, !tbaa !23
  %95 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %96 = load i32, ptr %95, align 8, !tbaa !11
  %97 = mul nsw i32 %94, %96
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds i8, ptr %93, i64 %98
  %100 = load i32, ptr %13, align 4, !tbaa !23
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds i8, ptr %99, i64 %101
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = load i32, ptr %14, align 4, !tbaa !23
  %105 = load i32, ptr %13, align 4, !tbaa !23
  %106 = sub nsw i32 %104, %105
  %107 = sext i32 %106 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %102, ptr align 1 %103, i64 %107, i1 false)
  br label %146

108:                                              ; preds = %52
  %109 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 2
  %110 = load ptr, ptr %109, align 8, !tbaa !25
  %111 = load i32, ptr %11, align 4, !tbaa !23
  %112 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %113 = load i32, ptr %112, align 8, !tbaa !11
  %114 = mul nsw i32 %111, %113
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds i8, ptr %110, i64 %115
  %117 = load i32, ptr %13, align 4, !tbaa !23
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds i8, ptr %116, i64 %118
  %120 = load ptr, ptr %5, align 8, !tbaa !5
  %121 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %122 = load i32, ptr %121, align 8, !tbaa !11
  %123 = load i32, ptr %13, align 4, !tbaa !23
  %124 = sub nsw i32 %122, %123
  %125 = sext i32 %124 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %119, ptr align 1 %120, i64 %125, i1 false)
  %126 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 2
  %127 = load ptr, ptr %126, align 8, !tbaa !25
  %128 = load i32, ptr %12, align 4, !tbaa !23
  %129 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %130 = load i32, ptr %129, align 8, !tbaa !11
  %131 = mul nsw i32 %128, %130
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i8, ptr %127, i64 %132
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = ptrtoint ptr %134 to i64
  %136 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %137 = load i32, ptr %136, align 8, !tbaa !11
  %138 = sext i32 %137 to i64
  %139 = add i64 %135, %138
  %140 = load i32, ptr %13, align 4, !tbaa !23
  %141 = sext i32 %140 to i64
  %142 = sub i64 %139, %141
  %143 = inttoptr i64 %142 to ptr
  %144 = load i32, ptr %14, align 4, !tbaa !23
  %145 = sext i32 %144 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %133, ptr align 1 %143, i64 %145, i1 false)
  br label %146

146:                                              ; preds = %108, %91
  %147 = load i64, ptr %8, align 8, !tbaa !19
  %148 = load i64, ptr %7, align 8, !tbaa !19
  %149 = sub nsw i64 %147, %148
  %150 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 9
  %151 = load i64, ptr %150, align 8, !tbaa !18
  %152 = add nsw i64 %151, %149
  store i64 %152, ptr %150, align 8, !tbaa !18
  %153 = load i64, ptr %7, align 8, !tbaa !19
  %154 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %155 = load i32, ptr %154, align 8, !tbaa !11
  %156 = sext i32 %155 to i64
  %157 = sdiv i64 %153, %156
  %158 = load i64, ptr %8, align 8, !tbaa !19
  %159 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %160 = load i32, ptr %159, align 8, !tbaa !11
  %161 = sext i32 %160 to i64
  %162 = sdiv i64 %158, %161
  %163 = icmp ne i64 %157, %162
  br i1 %163, label %164, label %168

164:                                              ; preds = %146
  %165 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 5
  %166 = load i32, ptr %165, align 8, !tbaa !26
  %167 = add nsw i32 %166, 1
  store i32 %167, ptr %165, align 8, !tbaa !26
  br label %168

168:                                              ; preds = %164, %146
  %169 = getelementptr inbounds %class.IOClient, ptr %15, i32 0, i32 1
  call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef %169)
  %170 = load i64, ptr %8, align 8, !tbaa !19
  %171 = load i64, ptr %7, align 8, !tbaa !19
  %172 = sub nsw i64 %170, %171
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret i64 %172
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = { 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 128}
!12 = !{!"_ZTS22VariableIOClientStream", !13, i64 0, !16, i64 128, !6, i64 136, !16, i64 144, !6, i64 152, !16, i64 160, !16, i64 164, !15, i64 168, !15, i64 169, !17, i64 176, !17, i64 184}
!13 = !{!"_ZTS8IOClient", !14, i64 8, !6, i64 120}
!14 = !{!"_ZTSN5boost21recursive_timed_mutexE", !7, i64 0, !7, i64 40, !15, i64 88, !10, i64 96, !16, i64 104}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = !{!12, !17, i64 176}
!19 = !{!17, !17, i64 0}
!20 = !{!13, !6, i64 120}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !8, i64 0}
!23 = !{!16, !16, i64 0}
!24 = !{!12, !16, i64 144}
!25 = !{!12, !6, i64 136}
!26 = !{!12, !16, i64 160}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.16 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z20EnterCriticalSectionPN5boost21recursive_timed_mutexExPKc(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef) local_unnamed_addr #1

; 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 @_ZN22VariableIOClientStream5writeEPKhm(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr noundef %1, i64 noundef returned %2) local_unnamed_addr #3 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 128
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = icmp ult i64 %6, %2
  br i1 %7, label %8, label %11

8:                                                ; preds = %3
  %9 = load ptr, ptr @stderr, align 8, !tbaa !16
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.16, i64 noundef %2) #4
  br label %11

11:                                               ; preds = %8, %3
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_Z20EnterCriticalSectionPN5boost21recursive_timed_mutexExPKc(ptr noundef nonnull %12, i64 noundef 100, ptr noundef nonnull @.str.17)
  %13 = getelementptr inbounds i8, ptr %0, i64 176
  %14 = load i64, ptr %13, align 8, !tbaa !17
  %15 = add i64 %14, %2
  %16 = load i32, ptr %4, align 8, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = sdiv i64 %14, %17
  %19 = sdiv i64 %15, %17
  %.not = icmp ne i64 %18, %19
  %20 = getelementptr inbounds i8, ptr %0, i64 120
  %21 = load ptr, ptr %20, align 8
  %.not35 = icmp eq ptr %21, null
  %or.cond = select i1 %.not, i1 %.not35, i1 false
  br i1 %or.cond, label %22, label %26

22:                                               ; preds = %11
  %23 = load ptr, ptr %0, align 8, !tbaa !18
  %24 = load ptr, ptr %23, align 8
  %25 = tail call noundef i32 %24(ptr noundef nonnull align 8 dereferenceable(192) %0)
  %.pre = load i32, ptr %4, align 8, !tbaa !5
  %.pre39 = sext i32 %.pre to i64
  %.pre40 = sdiv i64 %14, %.pre39
  br label %26

26:                                               ; preds = %22, %11
  %.pre-phi41 = phi i64 [ %.pre40, %22 ], [ %18, %11 ]
  %.pre-phi = phi i64 [ %.pre39, %22 ], [ %17, %11 ]
  %27 = phi i32 [ %.pre, %22 ], [ %16, %11 ]
  %28 = trunc i64 %.pre-phi41 to i32
  %29 = add nsw i64 %15, -1
  %30 = sdiv i64 %29, %.pre-phi
  %31 = trunc i64 %30 to i32
  %32 = getelementptr inbounds i8, ptr %0, i64 144
  %33 = load i32, ptr %32, align 8, !tbaa !20
  %34 = srem i32 %28, %33
  %35 = srem i32 %31, %33
  %36 = srem i64 %14, %.pre-phi
  %37 = trunc nsw i64 %36 to i32
  %38 = srem i64 %29, %.pre-phi
  %39 = trunc nsw i64 %38 to i32
  %40 = add i32 %39, 1
  %41 = icmp eq i32 %34, %35
  %42 = getelementptr inbounds i8, ptr %0, i64 136
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  %44 = mul nsw i32 %34, %27
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %43, i64 %45
  %47 = getelementptr inbounds i8, ptr %46, i64 %36
  br i1 %41, label %48, label %51

48:                                               ; preds = %26
  %49 = sub nsw i32 %40, %37
  %50 = sext i32 %49 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %47, ptr align 1 %1, i64 %50, i1 false)
  br label %65

51:                                               ; preds = %26
  %52 = sub nsw i32 %27, %37
  %53 = sext i32 %52 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %47, ptr align 1 %1, i64 %53, i1 false)
  %54 = load ptr, ptr %42, align 8, !tbaa !21
  %55 = load i32, ptr %4, align 8, !tbaa !5
  %56 = mul nsw i32 %55, %35
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i8, ptr %54, i64 %57
  %59 = ptrtoint ptr %1 to i64
  %60 = sext i32 %55 to i64
  %61 = sub i64 %59, %36
  %62 = add i64 %61, %60
  %63 = inttoptr i64 %62 to ptr
  %64 = sext i32 %40 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %58, ptr align 1 %63, i64 %64, i1 false)
  br label %65

65:                                               ; preds = %51, %48
  %66 = load i64, ptr %13, align 8, !tbaa !17
  %67 = add nsw i64 %66, %2
  store i64 %67, ptr %13, align 8, !tbaa !17
  %68 = load i32, ptr %4, align 8, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = sdiv i64 %14, %69
  %71 = sdiv i64 %15, %69
  %.not37 = icmp eq i64 %70, %71
  br i1 %.not37, label %76, label %72

72:                                               ; preds = %65
  %73 = getelementptr inbounds i8, ptr %0, i64 160
  %74 = load i32, ptr %73, align 8, !tbaa !22
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %73, align 8, !tbaa !22
  br label %76

76:                                               ; preds = %72, %65
  tail call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull %12)
  ret i64 %2
}

attributes #0 = { nofree 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 #1 = { 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 #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 = { cold 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 128}
!6 = !{!"_ZTS22VariableIOClientStream", !7, i64 0, !13, i64 128, !14, i64 136, !13, i64 144, !14, i64 152, !13, i64 160, !13, i64 164, !11, i64 168, !11, i64 169, !15, i64 176, !15, i64 184}
!7 = !{!"_ZTS8IOClient", !8, i64 8, !14, i64 120}
!8 = !{!"_ZTSN5boost21recursive_timed_mutexE", !9, i64 0, !9, i64 40, !11, i64 88, !12, i64 96, !13, i64 104}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"long long", !9, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!6, !15, i64 176}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !10, i64 0}
!20 = !{!6, !13, i64 144}
!21 = !{!6, !14, i64 136}
!22 = !{!6, !13, i64 160}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass