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

; 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.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 }
%class.VariableIOClientStream = type { %class.IOClient, i32, ptr, i32, ptr, i32, i32, i8, i8, i64, i64 }

@_ZN8IOClient10WriteBytesE = external global i64, align 8
@_ZN8IOClient9ReadBytesE = external global i64, align 8
@.str.18 = external hidden unnamed_addr constant [32 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: inlinehint mustprogress uwtable
declare dso_local void @_Z20EnterCriticalSectionPN5boost21recursive_timed_mutexExPKc(ptr noundef, i64 noundef, ptr noundef) #1

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN22VariableIOClientStream7ServiceEv(ptr noundef nonnull align 8 dereferenceable(192) %0) unnamed_addr #3 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %7 = getelementptr inbounds %class.IOClient, ptr %6, i32 0, i32 1
  call void @_Z20EnterCriticalSectionPN5boost21recursive_timed_mutexExPKc(ptr noundef %7, i64 noundef 100, ptr noundef @.str.18)
  %8 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 7
  %9 = load i8, ptr %8, align 8, !tbaa !9, !range !17, !noundef !18
  %10 = trunc i8 %9 to i1
  br i1 %10, label %11, label %68

11:                                               ; preds = %1
  %12 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 8
  %13 = load i8, ptr %12, align 1, !tbaa !19, !range !17, !noundef !18
  %14 = trunc i8 %13 to i1
  br i1 %14, label %67, label %15

15:                                               ; preds = %11
  %16 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 6
  %17 = load i32, ptr %16, align 4, !tbaa !20
  %18 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 5
  %19 = load i32, ptr %18, align 8, !tbaa !21
  %20 = sub nsw i32 %17, %19
  %21 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !22
  %23 = icmp slt i32 %20, %22
  br i1 %23, label %24, label %67

24:                                               ; preds = %15
  %25 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !23
  %27 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 6
  %28 = load i32, ptr %27, align 4, !tbaa !20
  %29 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 3
  %30 = load i32, ptr %29, align 8, !tbaa !22
  %31 = srem i32 %28, %30
  %32 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !24
  %34 = mul nsw i32 %31, %33
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i8, ptr %26, i64 %35
  %37 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 1
  %38 = load i32, ptr %37, align 8, !tbaa !24
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 4
  %41 = load ptr, ptr %40, align 8, !tbaa !25
  %42 = call i64 @fread(ptr noundef %36, i64 noundef 1, i64 noundef %39, ptr noundef %41)
  store i64 %42, ptr %4, align 8, !tbaa !26
  %43 = load i64, ptr %4, align 8, !tbaa !26
  %44 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 1
  %45 = load i32, ptr %44, align 8, !tbaa !24
  %46 = sext i32 %45 to i64
  %47 = icmp ne i64 %43, %46
  br i1 %47, label %48, label %50

48:                                               ; preds = %24
  %49 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 8
  store i8 1, ptr %49, align 1, !tbaa !19
  br label %50

50:                                               ; preds = %48, %24
  %51 = load i64, ptr %4, align 8, !tbaa !26
  %52 = load i64, ptr @_ZN8IOClient9ReadBytesE, align 8, !tbaa !27
  %53 = add i64 %52, %51
  store i64 %53, ptr @_ZN8IOClient9ReadBytesE, align 8, !tbaa !27
  %54 = load i64, ptr %4, align 8, !tbaa !26
  %55 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 10
  %56 = load i64, ptr %55, align 8, !tbaa !28
  %57 = add i64 %56, %54
  store i64 %57, ptr %55, align 8, !tbaa !28
  %58 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 6
  %59 = load i32, ptr %58, align 4, !tbaa !20
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %58, align 4, !tbaa !20
  %61 = getelementptr inbounds %class.IOClient, ptr %6, i32 0, i32 1
  call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef %61)
  %62 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 8
  %63 = load i8, ptr %62, align 1, !tbaa !19, !range !17, !noundef !18
  %64 = trunc i8 %63 to i1
  br i1 %64, label %65, label %66

65:                                               ; preds = %50
  store i32 2, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %157

66:                                               ; preds = %50
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %157

67:                                               ; preds = %15, %11
  br label %68

68:                                               ; preds = %67, %1
  %69 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 7
  %70 = load i8, ptr %69, align 8, !tbaa !9, !range !17, !noundef !18
  %71 = trunc i8 %70 to i1
  br i1 %71, label %149, label %72

72:                                               ; preds = %68
  %73 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 6
  %74 = load i32, ptr %73, align 4, !tbaa !20
  %75 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 5
  %76 = load i32, ptr %75, align 8, !tbaa !21
  %77 = icmp slt i32 %74, %76
  br i1 %77, label %78, label %108

78:                                               ; preds = %72
  %79 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 2
  %80 = load ptr, ptr %79, align 8, !tbaa !23
  %81 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 6
  %82 = load i32, ptr %81, align 4, !tbaa !20
  %83 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 3
  %84 = load i32, ptr %83, align 8, !tbaa !22
  %85 = srem i32 %82, %84
  %86 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 1
  %87 = load i32, ptr %86, align 8, !tbaa !24
  %88 = mul nsw i32 %85, %87
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i8, ptr %80, i64 %89
  %91 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 1
  %92 = load i32, ptr %91, align 8, !tbaa !24
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 4
  %95 = load ptr, ptr %94, align 8, !tbaa !25
  %96 = call i64 @fwrite(ptr noundef %90, i64 noundef 1, i64 noundef %93, ptr noundef %95)
  store i64 %96, ptr %4, align 8, !tbaa !26
  %97 = load i64, ptr %4, align 8, !tbaa !26
  %98 = load i64, ptr @_ZN8IOClient10WriteBytesE, align 8, !tbaa !27
  %99 = add i64 %98, %97
  store i64 %99, ptr @_ZN8IOClient10WriteBytesE, align 8, !tbaa !27
  %100 = load i64, ptr %4, align 8, !tbaa !26
  %101 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 10
  %102 = load i64, ptr %101, align 8, !tbaa !28
  %103 = add i64 %102, %100
  store i64 %103, ptr %101, align 8, !tbaa !28
  %104 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 6
  %105 = load i32, ptr %104, align 4, !tbaa !20
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %104, align 4, !tbaa !20
  %107 = getelementptr inbounds %class.IOClient, ptr %6, i32 0, i32 1
  call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef %107)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %157

108:                                              ; preds = %72
  %109 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 8
  %110 = load i8, ptr %109, align 1, !tbaa !19, !range !17, !noundef !18
  %111 = trunc i8 %110 to i1
  br i1 %111, label %112, label %147

112:                                              ; preds = %108
  %113 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 10
  %114 = load i64, ptr %113, align 8, !tbaa !28
  %115 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 9
  %116 = load i64, ptr %115, align 8, !tbaa !29
  %117 = icmp slt i64 %114, %116
  br i1 %117, label %118, label %147

118:                                              ; preds = %112
  %119 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 2
  %120 = load ptr, ptr %119, align 8, !tbaa !23
  %121 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 5
  %122 = load i32, ptr %121, align 8, !tbaa !21
  %123 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 3
  %124 = load i32, ptr %123, align 8, !tbaa !22
  %125 = srem i32 %122, %124
  %126 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 1
  %127 = load i32, ptr %126, align 8, !tbaa !24
  %128 = mul nsw i32 %125, %127
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i8, ptr %120, i64 %129
  %131 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 9
  %132 = load i64, ptr %131, align 8, !tbaa !29
  %133 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 10
  %134 = load i64, ptr %133, align 8, !tbaa !28
  %135 = sub nsw i64 %132, %134
  %136 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 4
  %137 = load ptr, ptr %136, align 8, !tbaa !25
  %138 = call i64 @fwrite(ptr noundef %130, i64 noundef 1, i64 noundef %135, ptr noundef %137)
  store i64 %138, ptr %4, align 8, !tbaa !26
  %139 = load i64, ptr %4, align 8, !tbaa !26
  %140 = load i64, ptr @_ZN8IOClient10WriteBytesE, align 8, !tbaa !27
  %141 = add i64 %140, %139
  store i64 %141, ptr @_ZN8IOClient10WriteBytesE, align 8, !tbaa !27
  %142 = load i64, ptr %4, align 8, !tbaa !26
  %143 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 10
  %144 = load i64, ptr %143, align 8, !tbaa !28
  %145 = add i64 %144, %142
  store i64 %145, ptr %143, align 8, !tbaa !28
  %146 = getelementptr inbounds %class.IOClient, ptr %6, i32 0, i32 1
  call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef %146)
  store i32 2, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %157

147:                                              ; preds = %112, %108
  br label %148

148:                                              ; preds = %147
  br label %149

149:                                              ; preds = %148, %68
  %150 = getelementptr inbounds %class.VariableIOClientStream, ptr %6, i32 0, i32 8
  %151 = load i8, ptr %150, align 1, !tbaa !19, !range !17, !noundef !18
  %152 = trunc i8 %151 to i1
  br i1 %152, label %153, label %155

153:                                              ; preds = %149
  %154 = getelementptr inbounds %class.IOClient, ptr %6, i32 0, i32 1
  call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef %154)
  store i32 2, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %157

155:                                              ; preds = %149
  %156 = getelementptr inbounds %class.IOClient, ptr %6, i32 0, i32 1
  call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef %156)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %157

157:                                              ; preds = %155, %153, %118, %78, %66, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %158 = load i32, ptr %2, align 4
  ret i32 %158
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !13, i64 168}
!10 = !{!"_ZTS22VariableIOClientStream", !11, i64 0, !15, i64 128, !6, i64 136, !15, i64 144, !6, i64 152, !15, i64 160, !15, i64 164, !13, i64 168, !13, i64 169, !16, i64 176, !16, i64 184}
!11 = !{!"_ZTS8IOClient", !12, i64 8, !6, i64 120}
!12 = !{!"_ZTSN5boost21recursive_timed_mutexE", !7, i64 0, !7, i64 40, !13, i64 88, !14, i64 96, !15, i64 104}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!10, !13, i64 169}
!20 = !{!10, !15, i64 164}
!21 = !{!10, !15, i64 160}
!22 = !{!10, !15, i64 144}
!23 = !{!10, !6, i64 136}
!24 = !{!10, !15, i64 128}
!25 = !{!10, !6, i64 152}
!26 = !{!14, !14, i64 0}
!27 = !{!16, !16, i64 0}
!28 = !{!10, !16, i64 184}
!29 = !{!10, !16, i64 176}


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

@_ZN8IOClient10WriteBytesE = external local_unnamed_addr global i64, align 8
@_ZN8IOClient9ReadBytesE = external local_unnamed_addr global i64, align 8
@.str.18 = external hidden unnamed_addr constant [32 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 3) i32 @_ZN22VariableIOClientStream7ServiceEv(ptr noundef nonnull align 8 dereferenceable(192) %0) unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_Z20EnterCriticalSectionPN5boost21recursive_timed_mutexExPKc(ptr noundef nonnull %2, i64 noundef 100, ptr noundef nonnull @.str.18)
  %3 = getelementptr inbounds i8, ptr %0, i64 168
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !16, !noundef !17
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %6, label %45

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 169
  %8 = load i8, ptr %7, align 1, !tbaa !18, !range !16, !noundef !17
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %.thread, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 164
  %12 = load i32, ptr %11, align 4, !tbaa !19
  %13 = getelementptr inbounds i8, ptr %0, i64 160
  %14 = load i32, ptr %13, align 8, !tbaa !20
  %15 = sub nsw i32 %12, %14
  %16 = getelementptr inbounds i8, ptr %0, i64 144
  %17 = load i32, ptr %16, align 8, !tbaa !21
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %19, label %.thread

19:                                               ; preds = %10
  %20 = getelementptr inbounds i8, ptr %0, i64 136
  %21 = load ptr, ptr %20, align 8, !tbaa !22
  %22 = srem i32 %12, %17
  %23 = getelementptr inbounds i8, ptr %0, i64 128
  %24 = load i32, ptr %23, align 8, !tbaa !23
  %25 = mul nsw i32 %24, %22
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i8, ptr %21, i64 %26
  %28 = sext i32 %24 to i64
  %29 = getelementptr inbounds i8, ptr %0, i64 152
  %30 = load ptr, ptr %29, align 8, !tbaa !24
  %31 = tail call i64 @fread(ptr noundef %27, i64 noundef 1, i64 noundef %28, ptr noundef %30)
  %32 = load i32, ptr %23, align 8, !tbaa !23
  %33 = sext i32 %32 to i64
  %.not = icmp eq i64 %31, %33
  br i1 %.not, label %35, label %34

34:                                               ; preds = %19
  store i8 1, ptr %7, align 1, !tbaa !18
  br label %35

35:                                               ; preds = %34, %19
  %36 = load i64, ptr @_ZN8IOClient9ReadBytesE, align 8, !tbaa !25
  %37 = add i64 %36, %31
  store i64 %37, ptr @_ZN8IOClient9ReadBytesE, align 8, !tbaa !25
  %38 = getelementptr inbounds i8, ptr %0, i64 184
  %39 = load i64, ptr %38, align 8, !tbaa !26
  %40 = add i64 %39, %31
  store i64 %40, ptr %38, align 8, !tbaa !26
  %41 = load i32, ptr %11, align 4, !tbaa !19
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %11, align 4, !tbaa !19
  tail call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull %2)
  %43 = load i8, ptr %7, align 1, !tbaa !18, !range !16, !noundef !17
  %44 = trunc nuw i8 %43 to i1
  %. = select i1 %44, i32 2, i32 1
  br label %104

45:                                               ; preds = %1
  %46 = getelementptr inbounds i8, ptr %0, i64 164
  %47 = load i32, ptr %46, align 4, !tbaa !19
  %48 = getelementptr inbounds i8, ptr %0, i64 160
  %49 = load i32, ptr %48, align 8, !tbaa !20
  %50 = icmp slt i32 %47, %49
  br i1 %50, label %51, label %73

51:                                               ; preds = %45
  %52 = getelementptr inbounds i8, ptr %0, i64 136
  %53 = load ptr, ptr %52, align 8, !tbaa !22
  %54 = getelementptr inbounds i8, ptr %0, i64 144
  %55 = load i32, ptr %54, align 8, !tbaa !21
  %56 = srem i32 %47, %55
  %57 = getelementptr inbounds i8, ptr %0, i64 128
  %58 = load i32, ptr %57, align 8, !tbaa !23
  %59 = mul nsw i32 %58, %56
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i8, ptr %53, i64 %60
  %62 = sext i32 %58 to i64
  %63 = getelementptr inbounds i8, ptr %0, i64 152
  %64 = load ptr, ptr %63, align 8, !tbaa !24
  %65 = tail call i64 @fwrite(ptr noundef %61, i64 noundef 1, i64 noundef %62, ptr noundef %64)
  %66 = load i64, ptr @_ZN8IOClient10WriteBytesE, align 8, !tbaa !25
  %67 = add i64 %66, %65
  store i64 %67, ptr @_ZN8IOClient10WriteBytesE, align 8, !tbaa !25
  %68 = getelementptr inbounds i8, ptr %0, i64 184
  %69 = load i64, ptr %68, align 8, !tbaa !26
  %70 = add i64 %69, %65
  store i64 %70, ptr %68, align 8, !tbaa !26
  %71 = load i32, ptr %46, align 4, !tbaa !19
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %46, align 4, !tbaa !19
  tail call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull %2)
  br label %104

73:                                               ; preds = %45
  %74 = getelementptr inbounds i8, ptr %0, i64 169
  %75 = load i8, ptr %74, align 1, !tbaa !18, !range !16, !noundef !17
  %76 = trunc nuw i8 %75 to i1
  br i1 %76, label %77, label %.thread

77:                                               ; preds = %73
  %78 = getelementptr inbounds i8, ptr %0, i64 184
  %79 = load i64, ptr %78, align 8, !tbaa !26
  %80 = getelementptr inbounds i8, ptr %0, i64 176
  %81 = load i64, ptr %80, align 8, !tbaa !27
  %82 = icmp slt i64 %79, %81
  br i1 %82, label %83, label %.thread

83:                                               ; preds = %77
  %84 = getelementptr inbounds i8, ptr %0, i64 136
  %85 = load ptr, ptr %84, align 8, !tbaa !22
  %86 = getelementptr inbounds i8, ptr %0, i64 144
  %87 = load i32, ptr %86, align 8, !tbaa !21
  %88 = srem i32 %49, %87
  %89 = getelementptr inbounds i8, ptr %0, i64 128
  %90 = load i32, ptr %89, align 8, !tbaa !23
  %91 = mul nsw i32 %90, %88
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i8, ptr %85, i64 %92
  %94 = sub nsw i64 %81, %79
  %95 = getelementptr inbounds i8, ptr %0, i64 152
  %96 = load ptr, ptr %95, align 8, !tbaa !24
  %97 = tail call i64 @fwrite(ptr noundef %93, i64 noundef 1, i64 noundef %94, ptr noundef %96)
  %98 = load i64, ptr @_ZN8IOClient10WriteBytesE, align 8, !tbaa !25
  %99 = add i64 %98, %97
  store i64 %99, ptr @_ZN8IOClient10WriteBytesE, align 8, !tbaa !25
  %100 = load i64, ptr %78, align 8, !tbaa !26
  %101 = add i64 %100, %97
  store i64 %101, ptr %78, align 8, !tbaa !26
  tail call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull %2)
  br label %104

.thread:                                          ; preds = %10, %6, %77, %73
  %102 = phi i8 [ %8, %10 ], [ %8, %6 ], [ %75, %77 ], [ %75, %73 ]
  %103 = trunc nuw i8 %102 to i1
  tail call void @_Z20LeaveCriticalSectionPN5boost21recursive_timed_mutexE(ptr noundef nonnull %2)
  %.13 = select i1 %103, i32 2, i32 0
  br label %104

104:                                              ; preds = %.thread, %35, %83, %51
  %.0 = phi i32 [ 1, %51 ], [ 2, %83 ], [ %., %35 ], [ %.13, %.thread ]
  ret i32 %.0
}

attributes #0 = { 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 #1 = { 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 #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" }

!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, !11, i64 168}
!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 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!6, !11, i64 169}
!19 = !{!6, !13, i64 164}
!20 = !{!6, !13, i64 160}
!21 = !{!6, !13, i64 144}
!22 = !{!6, !14, i64 136}
!23 = !{!6, !13, i64 128}
!24 = !{!6, !14, i64 152}
!25 = !{!15, !15, i64 0}
!26 = !{!6, !15, i64 184}
!27 = !{!6, !15, i64 176}


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