; 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__.mStreamRead = external hidden unnamed_addr constant [12 x i8], align 1
@mStreamRead.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 uwtable
define dso_local i32 @mStreamRead(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  br label %14

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

17:                                               ; preds = %14
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %23, label %20

20:                                               ; preds = %17
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = icmp sle i32 %21, 0
  br label %23

23:                                               ; preds = %20, %17, %14
  %24 = phi i1 [ true, %17 ], [ true, %14 ], [ %22, %20 ]
  %25 = zext i1 %24 to i32
  store i32 %25, ptr %8, align 4, !tbaa !9
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %23
  %29 = load i32, ptr %8, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %29, i32 noundef -1, ptr noundef @.str, i32 noundef 372, ptr noundef @__FUNCTION__.mStreamRead, ptr noundef @.str.2)
  br label %30

30:                                               ; preds = %28, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %31

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

47:                                               ; preds = %31
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = sub nsw i32 0, %48
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MArray, ptr %50, i32 0, i32 1
  %52 = load i16, ptr %51, align 4, !tbaa !11
  %53 = sext i16 %52 to i32
  %54 = sdiv i32 %49, %53
  store i32 %54, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %200

55:                                               ; preds = %31
  br label %56

56:                                               ; preds = %55
  br label %57

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

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

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

75:                                               ; preds = %66, %60
  store i32 1, ptr @mStreamRead.Sgn_valid, align 4, !tbaa !9
  br label %76

76:                                               ; preds = %75, %57
  br label %77

77:                                               ; preds = %76
  br label %78

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

83:                                               ; preds = %78
  br label %84

84:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.HandleStream, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !17
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.HandleStream, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !20
  %91 = icmp uge ptr %87, %90
  br i1 %91, label %92, label %102

92:                                               ; preds = %84
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.HandleStream, ptr %93, i32 0, i32 1
  %95 = load ptr, ptr %94, align 8, !tbaa !17
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.HandleStream, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8, !tbaa !20
  %99 = ptrtoint ptr %95 to i64
  %100 = ptrtoint ptr %98 to i64
  %101 = sub i64 %99, %100
  br label %122

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

122:                                              ; preds = %102, %92
  %123 = phi i64 [ %101, %92 ], [ %121, %102 ]
  %124 = trunc i64 %123 to i32
  store i32 %124, ptr %12, align 4, !tbaa !9
  %125 = load i32, ptr %7, align 4, !tbaa !9
  %126 = load i32, ptr %12, align 4, !tbaa !9
  %127 = icmp sgt i32 %125, %126
  br i1 %127, label %128, label %129

128:                                              ; preds = %122
  br label %187

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

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

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

187:                                              ; preds = %172, %128
  %188 = load ptr, ptr %10, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.HandleStream, ptr %188, i32 0, i32 2
  %190 = getelementptr inbounds %struct.MThreadSignal, ptr %189, i32 0, i32 0
  %191 = call i32 @pthread_mutex_unlock(ptr noundef %190) #5
  %192 = load i32, ptr %12, align 4, !tbaa !9
  %193 = load i32, ptr %7, align 4, !tbaa !9
  %194 = sub nsw i32 %192, %193
  %195 = load ptr, ptr %5, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.MArray, ptr %195, i32 0, i32 1
  %197 = load i16, ptr %196, align 4, !tbaa !11
  %198 = sext i16 %197 to i32
  %199 = sdiv i32 %194, %198
  store i32 %199, ptr %4, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %200

200:                                              ; preds = %187, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %201 = load i32, ptr %4, align 4
  ret i32 %201
}

; 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

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 = !{!18, !6, i64 8}
!18 = !{!"HandleStream", !6, i64 0, !6, i64 8, !19, i64 16}
!19 = !{!"MThreadSignal", !7, i64 0, !7, i64 40, !7, i64 88, !10, i64 144}
!20 = !{!18, !6, i64 0}
!21 = !{!12, !10, i64 0}
!22 = !{!7, !7, 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__.mStreamRead = external hidden unnamed_addr constant [12 x i8], align 1
@mStreamRead.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 uwtable
define dso_local i32 @mStreamRead(ptr noundef %0, ptr noundef writeonly %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 372, ptr noundef nonnull @__FUNCTION__.mStreamRead, 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 %24

19:                                               ; preds = %8
  %20 = load i16, ptr %9, align 4, !tbaa !5
  %21 = sext i16 %20 to i32
  %22 = sdiv i32 %12, %21
  %23 = sub nsw i32 0, %22
  br label %88

24:                                               ; preds = %8
  %25 = load i32, ptr @mStreamRead.Sgn_valid, align 4, !tbaa !15
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %36

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

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

35:                                               ; preds = %30, %27
  store i32 1, ptr @mStreamRead.Sgn_valid, align 4, !tbaa !15
  br label %36

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

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

46:                                               ; preds = %36
  %47 = load i32, ptr %0, align 8, !tbaa !20
  %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 %41 to i64
  %53 = ptrtoint ptr %40 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 !21
  %62 = load i32, ptr %0, align 8, !tbaa !20
  %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 %41 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 %1, ptr align 1 %41, i64 %73, i1 false)
  %74 = getelementptr inbounds i8, ptr %1, i64 %73
  %75 = load ptr, ptr %60, align 8, !tbaa !21
  store ptr %75, ptr %15, align 8, !tbaa !19
  %76 = sub nsw i32 %12, %71
  br label %77

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

82:                                               ; preds = %55, %77
  %.1 = phi i32 [ %12, %55 ], [ %.053, %77 ]
  %83 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %37) #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
  br label %88

88:                                               ; preds = %82, %19
  %.0 = phi i32 [ %23, %19 ], [ %87, %82 ]
  ret i32 %.0
}

; 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

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 = !{!7, !7, i64 0}
!16 = !{!17, !13, i64 8}
!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 0}
!20 = !{!6, !7, i64 0}
!21 = !{!8, !8, i64 0}


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