; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_array)

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

%struct.MArray = type { i32, i16, %union.anon }
%union.anon = type { ptr }
%struct.MHandle = type { i32, i32, ptr, ptr }
%struct.HandleStream = type { ptr, ptr, %struct.MThreadSignal }
%struct.MThreadSignal = type { %union.pthread_mutex_t, %union.pthread_cond_t, %union.pthread_rwlock_t, i32 }
%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 }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }

@.str = external hidden unnamed_addr constant [77 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mStreamWrite = external hidden unnamed_addr constant [13 x i8], align 1
@mStreamWrite.Sgn_valid = external hidden global i32, align 4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @GetHandle(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

; 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: nounwind uwtable
declare dso_local void @endStream(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind
declare i32 @pthread_rwlock_init(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) #4

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @mStreamWrite(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %21, label %15

15:                                               ; preds = %12
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %21, label %18

18:                                               ; preds = %15
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp sle i32 %19, 0
  br label %21

21:                                               ; preds = %18, %15, %12
  %22 = phi i1 [ true, %15 ], [ true, %12 ], [ %20, %18 ]
  %23 = zext i1 %22 to i32
  store i32 %23, ptr %7, align 4, !tbaa !9
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %21
  %27 = load i32, ptr %7, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %27, i32 noundef -1, ptr noundef @.str, i32 noundef 407, ptr noundef @__FUNCTION__.mStreamWrite, ptr noundef @.str.2)
  br label %28

28:                                               ; preds = %26, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %29

29:                                               ; preds = %28
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.MArray, ptr %31, i32 0, i32 1
  %33 = load i16, ptr %32, align 4, !tbaa !11
  %34 = sext i16 %33 to i32
  %35 = mul nsw i32 %30, %34
  store i32 %35, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call ptr @GetHandle(ptr noundef %36, i32 noundef 168, i32 noundef -894268103, ptr noundef @endStream)
  store ptr %37, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MHandle, ptr %38, i32 0, i32 3
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  store ptr %40, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.MHandle, ptr %41, i32 0, i32 1
  %43 = load volatile i32, ptr %42, align 4, !tbaa !16
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %56

45:                                               ; preds = %29
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.MArray, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.HandleStream, ptr %49, i32 0, i32 0
  store ptr %48, ptr %50, align 8, !tbaa !18
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.MArray, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !17
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.HandleStream, ptr %54, i32 0, i32 1
  store ptr %53, ptr %55, align 8, !tbaa !21
  br label %56

56:                                               ; preds = %45, %29
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr @mStreamWrite.Sgn_valid, align 4, !tbaa !9
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %77

61:                                               ; preds = %58
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.HandleStream, ptr %62, i32 0, i32 2
  %64 = getelementptr inbounds %struct.MThreadSignal, ptr %63, i32 0, i32 3
  %65 = atomicrmw xchg ptr %64, i32 -1135873169 seq_cst, align 8
  %66 = icmp ne i32 %65, -1135873169
  br i1 %66, label %67, label %76

67:                                               ; preds = %61
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.HandleStream, ptr %68, i32 0, i32 2
  %70 = getelementptr inbounds %struct.MThreadSignal, ptr %69, i32 0, i32 0
  %71 = call i32 @pthread_mutex_init(ptr noundef %70, ptr noundef null) #5
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.HandleStream, ptr %72, i32 0, i32 2
  %74 = getelementptr inbounds %struct.MThreadSignal, ptr %73, i32 0, i32 2
  %75 = call i32 @pthread_rwlock_init(ptr noundef %74, ptr noundef null) #5
  br label %76

76:                                               ; preds = %67, %61
  store i32 1, ptr @mStreamWrite.Sgn_valid, align 4, !tbaa !9
  br label %77

77:                                               ; preds = %76, %58
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.HandleStream, ptr %80, i32 0, i32 2
  %82 = getelementptr inbounds %struct.MThreadSignal, ptr %81, i32 0, i32 0
  %83 = call i32 @pthread_mutex_lock(ptr noundef %82) #5
  br label %84

84:                                               ; preds = %79
  br label %85

85:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.HandleStream, ptr %86, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !18
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.HandleStream, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !21
  %92 = icmp ugt ptr %88, %91
  br i1 %92, label %93, label %103

93:                                               ; preds = %85
  %94 = load ptr, ptr %9, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.HandleStream, ptr %94, i32 0, i32 0
  %96 = load ptr, ptr %95, align 8, !tbaa !18
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.HandleStream, ptr %97, i32 0, i32 1
  %99 = load ptr, ptr %98, align 8, !tbaa !21
  %100 = ptrtoint ptr %96 to i64
  %101 = ptrtoint ptr %99 to i64
  %102 = sub i64 %100, %101
  br label %123

103:                                              ; preds = %85
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.MArray, ptr %104, i32 0, i32 0
  %106 = load i32, ptr %105, align 8, !tbaa !22
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.MArray, ptr %107, i32 0, i32 1
  %109 = load i16, ptr %108, align 4, !tbaa !11
  %110 = sext i16 %109 to i32
  %111 = mul nsw i32 %106, %110
  %112 = sext i32 %111 to i64
  %113 = load ptr, ptr %9, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.HandleStream, ptr %113, i32 0, i32 1
  %115 = load ptr, ptr %114, align 8, !tbaa !21
  %116 = load ptr, ptr %9, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.HandleStream, ptr %116, i32 0, i32 0
  %118 = load ptr, ptr %117, align 8, !tbaa !18
  %119 = ptrtoint ptr %115 to i64
  %120 = ptrtoint ptr %118 to i64
  %121 = sub i64 %119, %120
  %122 = sub nsw i64 %112, %121
  br label %123

123:                                              ; preds = %103, %93
  %124 = phi i64 [ %102, %93 ], [ %122, %103 ]
  %125 = trunc i64 %124 to i32
  store i32 %125, ptr %10, align 4, !tbaa !9
  %126 = load i32, ptr %6, align 4, !tbaa !9
  %127 = load i32, ptr %10, align 4, !tbaa !9
  %128 = icmp sgt i32 %126, %127
  br i1 %128, label %129, label %130

129:                                              ; preds = %123
  br label %188

130:                                              ; preds = %123
  %131 = load ptr, ptr %4, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.MArray, ptr %131, i32 0, i32 2
  %133 = load ptr, ptr %132, align 8, !tbaa !17
  %134 = load ptr, ptr %4, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.MArray, ptr %134, i32 0, i32 0
  %136 = load i32, ptr %135, align 8, !tbaa !22
  %137 = load ptr, ptr %4, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.MArray, ptr %137, i32 0, i32 1
  %139 = load i16, ptr %138, align 4, !tbaa !11
  %140 = sext i16 %139 to i32
  %141 = mul nsw i32 %136, %140
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds i8, ptr %133, i64 %142
  %144 = load ptr, ptr %9, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.HandleStream, ptr %144, i32 0, i32 1
  %146 = load ptr, ptr %145, align 8, !tbaa !21
  %147 = ptrtoint ptr %143 to i64
  %148 = ptrtoint ptr %146 to i64
  %149 = sub i64 %147, %148
  %150 = trunc i64 %149 to i32
  store i32 %150, ptr %11, align 4, !tbaa !9
  %151 = load i32, ptr %11, align 4, !tbaa !9
  %152 = load i32, ptr %6, align 4, !tbaa !9
  %153 = icmp sle i32 %151, %152
  br i1 %153, label %154, label %173

154:                                              ; preds = %130
  %155 = load ptr, ptr %9, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.HandleStream, ptr %155, i32 0, i32 1
  %157 = load ptr, ptr %156, align 8, !tbaa !21
  %158 = load ptr, ptr %5, align 8, !tbaa !5
  %159 = load i32, ptr %11, align 4, !tbaa !9
  %160 = sext i32 %159 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %157, ptr align 1 %158, i64 %160, i1 false)
  %161 = load ptr, ptr %5, align 8, !tbaa !5
  %162 = load i32, ptr %11, align 4, !tbaa !9
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds i8, ptr %161, i64 %163
  store ptr %164, ptr %5, align 8, !tbaa !5
  %165 = load ptr, ptr %4, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.MArray, ptr %165, i32 0, i32 2
  %167 = load ptr, ptr %166, align 8, !tbaa !17
  %168 = load ptr, ptr %9, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.HandleStream, ptr %168, i32 0, i32 1
  store ptr %167, ptr %169, align 8, !tbaa !21
  %170 = load i32, ptr %6, align 4, !tbaa !9
  %171 = load i32, ptr %11, align 4, !tbaa !9
  %172 = sub nsw i32 %170, %171
  store i32 %172, ptr %6, align 4, !tbaa !9
  br label %173

173:                                              ; preds = %154, %130
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct.HandleStream, ptr %174, i32 0, i32 1
  %176 = load ptr, ptr %175, align 8, !tbaa !21
  %177 = load ptr, ptr %5, align 8, !tbaa !5
  %178 = load i32, ptr %6, align 4, !tbaa !9
  %179 = sext i32 %178 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %176, ptr align 1 %177, i64 %179, i1 false)
  %180 = load ptr, ptr %9, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.HandleStream, ptr %180, i32 0, i32 1
  %182 = load ptr, ptr %181, align 8, !tbaa !21
  %183 = load i32, ptr %6, align 4, !tbaa !9
  %184 = sext i32 %183 to i64
  %185 = getelementptr inbounds i8, ptr %182, i64 %184
  %186 = load ptr, ptr %9, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.HandleStream, ptr %186, i32 0, i32 1
  store ptr %185, ptr %187, align 8, !tbaa !21
  br label %188

188:                                              ; preds = %173, %129
  %189 = load ptr, ptr %8, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.MHandle, ptr %189, i32 0, i32 1
  store volatile i32 1, ptr %190, align 4, !tbaa !16
  %191 = load ptr, ptr %9, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.HandleStream, ptr %191, i32 0, i32 2
  %193 = getelementptr inbounds %struct.MThreadSignal, ptr %192, i32 0, i32 0
  %194 = call i32 @pthread_mutex_unlock(ptr noundef %193) #5
  %195 = load i32, ptr %10, align 4, !tbaa !9
  %196 = load i32, ptr %6, align 4, !tbaa !9
  %197 = sub nsw i32 %195, %196
  %198 = load ptr, ptr %4, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.MArray, ptr %198, i32 0, i32 1
  %200 = load i16, ptr %199, align 4, !tbaa !11
  %201 = sext i16 %200 to i32
  %202 = sdiv i32 %197, %201
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  ret i32 %202
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"MArray", !10, i64 0, !13, i64 4, !7, i64 8}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !6, i64 16}
!15 = !{!"MHandle", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!16 = !{!15, !10, i64 4}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !6, i64 0}
!19 = !{!"HandleStream", !6, i64 0, !6, i64 8, !20, i64 16}
!20 = !{!"MThreadSignal", !7, i64 0, !7, i64 40, !7, i64 88, !10, i64 144}
!21 = !{!19, !6, i64 8}
!22 = !{!12, !10, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [77 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mStreamWrite = external hidden unnamed_addr constant [13 x i8], align 1
@mStreamWrite.Sgn_valid = external hidden local_unnamed_addr global i32, align 4

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

declare ptr @GetHandle(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @endStream(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @pthread_mutex_init(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_rwlock_init(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mStreamWrite(ptr noundef %0, ptr noundef readonly %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond = or i1 %4, %5
  %6 = icmp slt i32 %2, 1
  %spec.select = or i1 %or.cond, %6
  br i1 %spec.select, label %7, label %8

7:                                                ; preds = %3
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 407, ptr noundef nonnull @__FUNCTION__.mStreamWrite, ptr noundef nonnull @.str.2) #4
  br label %8

8:                                                ; preds = %7, %3
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i16, ptr %9, align 4, !tbaa !5
  %11 = sext i16 %10 to i32
  %12 = mul nsw i32 %11, %2
  %13 = tail call ptr @GetHandle(ptr noundef %0, i32 noundef 168, i32 noundef -894268103, ptr noundef nonnull @endStream) #4
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %13, i64 4
  %17 = load volatile i32, ptr %16, align 4, !tbaa !14
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %8
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  store ptr %21, ptr %15, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %21, ptr %22, align 8, !tbaa !19
  br label %23

23:                                               ; preds = %19, %8
  %24 = load i32, ptr @mStreamWrite.Sgn_valid, align 4, !tbaa !20
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %35

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %15, i64 160
  %28 = atomicrmw xchg ptr %27, i32 -1135873169 seq_cst, align 8
  %.not = icmp eq i32 %28, -1135873169
  br i1 %.not, label %34, label %29

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %15, i64 16
  %31 = tail call i32 @pthread_mutex_init(ptr noundef nonnull %30, ptr noundef null) #4
  %32 = getelementptr inbounds i8, ptr %15, i64 104
  %33 = tail call i32 @pthread_rwlock_init(ptr noundef nonnull %32, ptr noundef null) #4
  br label %34

34:                                               ; preds = %29, %26
  store i32 1, ptr @mStreamWrite.Sgn_valid, align 4, !tbaa !20
  br label %35

35:                                               ; preds = %34, %23
  %36 = getelementptr inbounds i8, ptr %15, i64 16
  %37 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %36) #4
  %38 = load ptr, ptr %15, align 8, !tbaa !16
  %39 = getelementptr inbounds i8, ptr %15, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !19
  %41 = icmp ugt ptr %38, %40
  br i1 %41, label %42, label %46

42:                                               ; preds = %35
  %43 = ptrtoint ptr %38 to i64
  %44 = ptrtoint ptr %40 to i64
  %45 = sub i64 %43, %44
  br label %55

46:                                               ; preds = %35
  %47 = load i32, ptr %0, align 8, !tbaa !21
  %48 = load i16, ptr %9, align 4, !tbaa !5
  %49 = sext i16 %48 to i32
  %50 = mul nsw i32 %47, %49
  %51 = zext i32 %50 to i64
  %52 = ptrtoint ptr %40 to i64
  %53 = ptrtoint ptr %38 to i64
  %.neg = sub i64 %53, %52
  %54 = add i64 %.neg, %51
  br label %55

55:                                               ; preds = %46, %42
  %56 = phi i64 [ %45, %42 ], [ %54, %46 ]
  %57 = trunc i64 %56 to i32
  %58 = icmp sgt i32 %12, %57
  br i1 %58, label %82, label %59

59:                                               ; preds = %55
  %60 = getelementptr inbounds i8, ptr %0, i64 8
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = load i32, ptr %0, align 8, !tbaa !21
  %63 = load i16, ptr %9, align 4, !tbaa !5
  %64 = sext i16 %63 to i32
  %65 = mul nsw i32 %62, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %61, i64 %66
  %68 = ptrtoint ptr %67 to i64
  %69 = ptrtoint ptr %40 to i64
  %70 = sub i64 %68, %69
  %71 = trunc i64 %70 to i32
  %.not62 = icmp slt i32 %12, %71
  br i1 %.not62, label %77, label %72

72:                                               ; preds = %59
  %sext = shl i64 %70, 32
  %73 = ashr exact i64 %sext, 32
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %40, ptr align 1 %1, i64 %73, i1 false)
  %74 = getelementptr inbounds i8, ptr %1, i64 %73
  %75 = load ptr, ptr %60, align 8, !tbaa !15
  store ptr %75, ptr %39, align 8, !tbaa !19
  %76 = sub nsw i32 %12, %71
  br label %77

77:                                               ; preds = %72, %59
  %78 = phi ptr [ %75, %72 ], [ %40, %59 ]
  %.054 = phi i32 [ %76, %72 ], [ %12, %59 ]
  %.0 = phi ptr [ %74, %72 ], [ %1, %59 ]
  %79 = sext i32 %.054 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %78, ptr align 1 %.0, i64 %79, i1 false)
  %80 = load ptr, ptr %39, align 8, !tbaa !19
  %81 = getelementptr inbounds i8, ptr %80, i64 %79
  store ptr %81, ptr %39, align 8, !tbaa !19
  br label %82

82:                                               ; preds = %55, %77
  %.1 = phi i32 [ %12, %55 ], [ %.054, %77 ]
  store volatile i32 1, ptr %16, align 4, !tbaa !14
  %83 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %36) #4
  %84 = sub nsw i32 %57, %.1
  %85 = load i16, ptr %9, align 4, !tbaa !5
  %86 = sext i16 %85 to i32
  %87 = sdiv i32 %84, %86
  ret i32 %87
}

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #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, !10, i64 4}
!6 = !{!"MArray", !7, i64 0, !10, i64 4, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!12, !13, i64 16}
!12 = !{!"MHandle", !7, i64 0, !7, i64 4, !13, i64 8, !13, i64 16}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!12, !7, i64 4}
!15 = !{!8, !8, i64 0}
!16 = !{!17, !13, i64 0}
!17 = !{!"HandleStream", !13, i64 0, !13, i64 8, !18, i64 16}
!18 = !{!"MThreadSignal", !8, i64 0, !8, i64 40, !8, i64 88, !7, i64 144}
!19 = !{!17, !13, i64 8}
!20 = !{!7, !7, i64 0}
!21 = !{!6, !7, i64 0}


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