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

; 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.14 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [29 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: mustprogress uwtable
define dso_local noundef i64 @_ZN22VariableIOClientStream4readEPhm(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr noundef %1, i64 noundef %2) #3 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.14, i64 noundef %23) #6
  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.15)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %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 %8, align 8, !tbaa !19
  %33 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 10
  %34 = load i64, ptr %33, align 8, !tbaa !20
  %35 = icmp sgt i64 %32, %34
  br i1 %35, label %36, label %43

36:                                               ; preds = %25
  %37 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 8
  %38 = load i8, ptr %37, align 1, !tbaa !21, !range !22, !noundef !23
  %39 = trunc i8 %38 to i1
  br i1 %39, label %40, label %43

40:                                               ; preds = %36
  %41 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 10
  %42 = load i64, ptr %41, align 8, !tbaa !20
  store i64 %42, ptr %8, align 8, !tbaa !19
  br label %43

43:                                               ; preds = %40, %36, %25
  %44 = load i64, ptr %7, align 8, !tbaa !19
  %45 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %46 = load i32, ptr %45, align 8, !tbaa !11
  %47 = sext i32 %46 to i64
  %48 = sdiv i64 %44, %47
  %49 = load i64, ptr %8, align 8, !tbaa !19
  %50 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !11
  %52 = sext i32 %51 to i64
  %53 = sdiv i64 %49, %52
  %54 = icmp ne i64 %48, %53
  br i1 %54, label %55, label %64

55:                                               ; preds = %43
  %56 = getelementptr inbounds %class.IOClient, ptr %15, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !24
  %58 = icmp ne ptr %57, null
  br i1 %58, label %64, label %59

59:                                               ; preds = %55
  %60 = load ptr, ptr %15, align 8, !tbaa !25
  %61 = getelementptr inbounds ptr, ptr %60, i64 0
  %62 = load ptr, ptr %61, align 8
  %63 = call noundef i32 %62(ptr noundef nonnull align 8 dereferenceable(192) %15)
  br label %64

64:                                               ; preds = %59, %55, %43
  %65 = load i64, ptr %7, align 8, !tbaa !19
  %66 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %67 = load i32, ptr %66, align 8, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = sdiv i64 %65, %68
  %70 = trunc i64 %69 to i32
  store i32 %70, ptr %9, align 4, !tbaa !27
  %71 = load i64, ptr %8, align 8, !tbaa !19
  %72 = sub nsw i64 %71, 1
  %73 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %74 = load i32, ptr %73, align 8, !tbaa !11
  %75 = sext i32 %74 to i64
  %76 = sdiv i64 %72, %75
  %77 = trunc i64 %76 to i32
  store i32 %77, ptr %10, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %78 = load i32, ptr %9, align 4, !tbaa !27
  %79 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 3
  %80 = load i32, ptr %79, align 8, !tbaa !28
  %81 = srem i32 %78, %80
  store i32 %81, ptr %11, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %82 = load i32, ptr %10, align 4, !tbaa !27
  %83 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 3
  %84 = load i32, ptr %83, align 8, !tbaa !28
  %85 = srem i32 %82, %84
  store i32 %85, ptr %12, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %86 = load i64, ptr %7, align 8, !tbaa !19
  %87 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %88 = load i32, ptr %87, align 8, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = srem i64 %86, %89
  %91 = trunc i64 %90 to i32
  store i32 %91, ptr %13, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %92 = load i64, ptr %8, align 8, !tbaa !19
  %93 = sub nsw i64 %92, 1
  %94 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %95 = load i32, ptr %94, align 8, !tbaa !11
  %96 = sext i32 %95 to i64
  %97 = srem i64 %93, %96
  %98 = add nsw i64 %97, 1
  %99 = trunc i64 %98 to i32
  store i32 %99, ptr %14, align 4, !tbaa !27
  %100 = load i32, ptr %11, align 4, !tbaa !27
  %101 = load i32, ptr %12, align 4, !tbaa !27
  %102 = icmp eq i32 %100, %101
  br i1 %102, label %103, label %120

103:                                              ; preds = %64
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 2
  %106 = load ptr, ptr %105, align 8, !tbaa !29
  %107 = load i32, ptr %11, align 4, !tbaa !27
  %108 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %109 = load i32, ptr %108, align 8, !tbaa !11
  %110 = mul nsw i32 %107, %109
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds i8, ptr %106, i64 %111
  %113 = load i32, ptr %13, align 4, !tbaa !27
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds i8, ptr %112, i64 %114
  %116 = load i32, ptr %14, align 4, !tbaa !27
  %117 = load i32, ptr %13, align 4, !tbaa !27
  %118 = sub nsw i32 %116, %117
  %119 = sext i32 %118 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %104, ptr align 1 %115, i64 %119, i1 false)
  br label %159

120:                                              ; preds = %64
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 2
  %123 = load ptr, ptr %122, align 8, !tbaa !29
  %124 = load i32, ptr %11, align 4, !tbaa !27
  %125 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %126 = load i32, ptr %125, align 8, !tbaa !11
  %127 = mul nsw i32 %124, %126
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds i8, ptr %123, i64 %128
  %130 = load i32, ptr %13, align 4, !tbaa !27
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds i8, ptr %129, i64 %131
  %133 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %134 = load i32, ptr %133, align 8, !tbaa !11
  %135 = load i32, ptr %13, align 4, !tbaa !27
  %136 = sub nsw i32 %134, %135
  %137 = sext i32 %136 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %121, ptr align 1 %132, i64 %137, i1 false)
  %138 = load ptr, ptr %5, align 8, !tbaa !5
  %139 = call noundef ptr @_Z10GetAddressIhEPT_S1_(ptr noundef %138)
  %140 = ptrtoint ptr %139 to i64
  %141 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %142 = load i32, ptr %141, align 8, !tbaa !11
  %143 = sext i32 %142 to i64
  %144 = add i64 %140, %143
  %145 = load i32, ptr %13, align 4, !tbaa !27
  %146 = sext i32 %145 to i64
  %147 = sub i64 %144, %146
  %148 = inttoptr i64 %147 to ptr
  %149 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 2
  %150 = load ptr, ptr %149, align 8, !tbaa !29
  %151 = load i32, ptr %12, align 4, !tbaa !27
  %152 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %153 = load i32, ptr %152, align 8, !tbaa !11
  %154 = mul nsw i32 %151, %153
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds i8, ptr %150, i64 %155
  %157 = load i32, ptr %14, align 4, !tbaa !27
  %158 = sext i32 %157 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %148, ptr align 1 %156, i64 %158, i1 false)
  br label %159

159:                                              ; preds = %120, %103
  %160 = load i64, ptr %8, align 8, !tbaa !19
  %161 = load i64, ptr %7, align 8, !tbaa !19
  %162 = sub nsw i64 %160, %161
  %163 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 9
  %164 = load i64, ptr %163, align 8, !tbaa !18
  %165 = add nsw i64 %164, %162
  store i64 %165, ptr %163, align 8, !tbaa !18
  %166 = load i64, ptr %7, align 8, !tbaa !19
  %167 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %168 = load i32, ptr %167, align 8, !tbaa !11
  %169 = sext i32 %168 to i64
  %170 = sdiv i64 %166, %169
  %171 = load i64, ptr %8, align 8, !tbaa !19
  %172 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 1
  %173 = load i32, ptr %172, align 8, !tbaa !11
  %174 = sext i32 %173 to i64
  %175 = sdiv i64 %171, %174
  %176 = icmp ne i64 %170, %175
  br i1 %176, label %177, label %181

177:                                              ; preds = %159
  %178 = getelementptr inbounds %class.VariableIOClientStream, ptr %15, i32 0, i32 5
  %179 = load i32, ptr %178, align 8, !tbaa !30
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %178, align 8, !tbaa !30
  br label %181

181:                                              ; preds = %177, %159
  %182 = getelementptr inbounds %class.IOClient, ptr %15, i32 0, i32 1
  call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef %182)
  %183 = load i64, ptr %8, align 8, !tbaa !19
  %184 = load i64, ptr %7, align 8, !tbaa !19
  %185 = sub nsw i64 %183, %184
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret i64 %185
}

; 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) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z10GetAddressIhEPT_S1_(ptr noundef) #5

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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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, !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 = !{!12, !17, i64 184}
!21 = !{!12, !15, i64 169}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!13, !6, i64 120}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !8, i64 0}
!27 = !{!16, !16, i64 0}
!28 = !{!12, !16, i64 144}
!29 = !{!12, !6, i64 136}
!30 = !{!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.14 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [29 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 uwtable
define dso_local noundef i64 @_ZN22VariableIOClientStream4readEPhm(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 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.14, i64 noundef %2) #5
  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.15)
  %13 = getelementptr inbounds i8, ptr %0, i64 176
  %14 = load i64, ptr %13, align 8, !tbaa !17
  %15 = add i64 %14, %2
  %16 = getelementptr inbounds i8, ptr %0, i64 184
  %17 = load i64, ptr %16, align 8, !tbaa !18
  %18 = icmp sgt i64 %15, %17
  %19 = getelementptr inbounds i8, ptr %0, i64 169
  %20 = load i8, ptr %19, align 1, !range !19
  %21 = trunc nuw i8 %20 to i1
  %22 = select i1 %18, i1 %21, i1 false
  %.0 = select i1 %22, i64 %17, i64 %15
  %23 = load i32, ptr %4, align 8, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = sdiv i64 %14, %24
  %26 = sdiv i64 %.0, %24
  %.not = icmp ne i64 %25, %26
  %27 = getelementptr inbounds i8, ptr %0, i64 120
  %28 = load ptr, ptr %27, align 8
  %.not40 = icmp eq ptr %28, null
  %or.cond = select i1 %.not, i1 %.not40, i1 false
  br i1 %or.cond, label %29, label %33

29:                                               ; preds = %11
  %30 = load ptr, ptr %0, align 8, !tbaa !20
  %31 = load ptr, ptr %30, align 8
  %32 = tail call noundef i32 %31(ptr noundef nonnull align 8 dereferenceable(192) %0)
  %.pre = load i32, ptr %4, align 8, !tbaa !5
  %.pre44 = sext i32 %.pre to i64
  %.pre45 = sdiv i64 %14, %.pre44
  br label %33

33:                                               ; preds = %29, %11
  %.pre-phi46 = phi i64 [ %.pre45, %29 ], [ %25, %11 ]
  %.pre-phi = phi i64 [ %.pre44, %29 ], [ %24, %11 ]
  %34 = phi i32 [ %.pre, %29 ], [ %23, %11 ]
  %35 = trunc i64 %.pre-phi46 to i32
  %36 = add nsw i64 %.0, -1
  %37 = sdiv i64 %36, %.pre-phi
  %38 = trunc i64 %37 to i32
  %39 = getelementptr inbounds i8, ptr %0, i64 144
  %40 = load i32, ptr %39, align 8, !tbaa !22
  %41 = srem i32 %35, %40
  %42 = srem i32 %38, %40
  %43 = srem i64 %14, %.pre-phi
  %44 = trunc nsw i64 %43 to i32
  %45 = srem i64 %36, %.pre-phi
  %46 = trunc nsw i64 %45 to i32
  %47 = add i32 %46, 1
  %48 = icmp eq i32 %41, %42
  %49 = getelementptr inbounds i8, ptr %0, i64 136
  %50 = load ptr, ptr %49, align 8, !tbaa !23
  %51 = mul nsw i32 %41, %34
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i8, ptr %50, i64 %52
  %54 = getelementptr inbounds i8, ptr %53, i64 %43
  br i1 %48, label %55, label %58

55:                                               ; preds = %33
  %56 = sub nsw i32 %47, %44
  %57 = sext i32 %56 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr align 1 %54, i64 %57, i1 false)
  br label %73

58:                                               ; preds = %33
  %59 = sub nsw i32 %34, %44
  %60 = sext i32 %59 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr align 1 %54, i64 %60, i1 false)
  %61 = tail call noundef ptr @_Z10GetAddressIhEPT_S1_(ptr noundef %1)
  %62 = ptrtoint ptr %61 to i64
  %63 = load i32, ptr %4, align 8, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = sub i64 %62, %43
  %66 = add i64 %65, %64
  %67 = inttoptr i64 %66 to ptr
  %68 = load ptr, ptr %49, align 8, !tbaa !23
  %69 = mul nsw i32 %63, %42
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds i8, ptr %68, i64 %70
  %72 = sext i32 %47 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %67, ptr align 1 %71, i64 %72, i1 false)
  br label %73

73:                                               ; preds = %58, %55
  %74 = sub nsw i64 %.0, %14
  %75 = load i64, ptr %13, align 8, !tbaa !17
  %76 = add nsw i64 %75, %74
  store i64 %76, ptr %13, align 8, !tbaa !17
  %77 = load i32, ptr %4, align 8, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = sdiv i64 %14, %78
  %80 = sdiv i64 %.0, %78
  %.not42 = icmp eq i64 %79, %80
  br i1 %.not42, label %85, label %81

81:                                               ; preds = %73
  %82 = getelementptr inbounds i8, ptr %0, i64 160
  %83 = load i32, ptr %82, align 8, !tbaa !24
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %82, align 8, !tbaa !24
  br label %85

85:                                               ; preds = %81, %73
  tail call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull %12)
  ret i64 %74
}

; 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) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z10GetAddressIhEPT_S1_(ptr noundef) local_unnamed_addr #4

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 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { 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 = !{!6, !15, i64 184}
!19 = !{i8 0, i8 2}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !10, i64 0}
!22 = !{!6, !13, i64 144}
!23 = !{!6, !14, i64 136}
!24 = !{!6, !13, i64 160}


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