; LLVM IR from jingweizhanghuai/Morn :: src/ptc (morn_pipeline)

; 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.MHandle = type { i32, i32, ptr, ptr }
%struct.MList = type { i32, ptr }
%struct.HandlePipeline = type { i32, ptr, ptr, i32, %struct.MThreadSignal, %struct.MThreadSignal, i32 }
%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 }

@Pipeline0.Sgn_valid = external hidden global i32, align 4
@Pipeline0.Sgn_valid.1 = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @endPipeline(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Pipeline0(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call ptr @GetHandle(ptr noundef %12, i32 noundef 344, i32 noundef 75085391, ptr noundef @endPipeline)
  store ptr %13, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.MHandle, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  store ptr %16, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.MHandle, ptr %17, i32 0, i32 1
  %19 = load volatile i32, ptr %18, align 4, !tbaa !13
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %79

21:                                               ; preds = %2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.MList, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.HandlePipeline, ptr %25, i32 0, i32 0
  store volatile i32 %24, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.HandlePipeline, ptr %27, i32 0, i32 6
  store volatile i32 0, ptr %28, align 8, !tbaa !19
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.MList, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !14
  %32 = sext i32 %31 to i64
  %33 = mul i64 4, %32
  %34 = trunc i64 %33 to i32
  %35 = call ptr @m_Malloc(i32 noundef %34)
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.HandlePipeline, ptr %36, i32 0, i32 1
  store ptr %35, ptr %37, align 8, !tbaa !20
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MList, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !14
  %41 = sext i32 %40 to i64
  %42 = mul i64 4, %41
  %43 = trunc i64 %42 to i32
  %44 = call ptr @m_Malloc(i32 noundef %43)
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.HandlePipeline, ptr %45, i32 0, i32 2
  store ptr %44, ptr %46, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %71, %21
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.MList, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !14
  %52 = icmp slt i32 %48, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %74

54:                                               ; preds = %47
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = sub nsw i32 0, %55
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.HandlePipeline, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !20
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i32, ptr %59, i64 %61
  store i32 %56, ptr %62, align 4, !tbaa !9
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = sub nsw i32 -1, %63
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.HandlePipeline, ptr %65, i32 0, i32 2
  %67 = load ptr, ptr %66, align 8, !tbaa !21
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i32, ptr %67, i64 %69
  store i32 %64, ptr %70, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %54
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %8, align 4, !tbaa !9
  br label %47, !llvm.loop !22

74:                                               ; preds = %53
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.MHandle, ptr %75, i32 0, i32 1
  store volatile i32 1, ptr %76, align 4, !tbaa !13
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.HandlePipeline, ptr %77, i32 0, i32 3
  store volatile i32 1, ptr %78, align 8, !tbaa !24
  br label %79

79:                                               ; preds = %74, %2
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.HandlePipeline, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !20
  %83 = load i32, ptr %5, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i32, ptr %82, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !9
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.HandlePipeline, ptr %87, i32 0, i32 2
  %89 = load ptr, ptr %88, align 8, !tbaa !21
  %90 = load i32, ptr %5, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr %89, i64 %91
  store i32 %86, ptr %92, align 4, !tbaa !9
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.HandlePipeline, ptr %93, i32 0, i32 0
  %95 = load volatile i32, ptr %94, align 8, !tbaa !16
  %96 = icmp eq i32 %95, 1
  br i1 %96, label %97, label %98

97:                                               ; preds = %79
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %277

98:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.HandlePipeline, ptr %99, i32 0, i32 0
  %101 = load volatile i32, ptr %100, align 8, !tbaa !16
  store i32 %101, ptr %10, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %98
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr @Pipeline0.Sgn_valid, align 4, !tbaa !9
  %106 = icmp eq i32 %105, 0
  br i1 %106, label %107, label %123

107:                                              ; preds = %104
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.HandlePipeline, ptr %108, i32 0, i32 4
  %110 = getelementptr inbounds %struct.MThreadSignal, ptr %109, i32 0, i32 3
  %111 = atomicrmw xchg ptr %110, i32 -1135873169 seq_cst, align 8
  %112 = icmp ne i32 %111, -1135873169
  br i1 %112, label %113, label %122

113:                                              ; preds = %107
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.HandlePipeline, ptr %114, i32 0, i32 4
  %116 = getelementptr inbounds %struct.MThreadSignal, ptr %115, i32 0, i32 0
  %117 = call i32 @pthread_mutex_init(ptr noundef %116, ptr noundef null) #4
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.HandlePipeline, ptr %118, i32 0, i32 4
  %120 = getelementptr inbounds %struct.MThreadSignal, ptr %119, i32 0, i32 2
  %121 = call i32 @pthread_rwlock_init(ptr noundef %120, ptr noundef null) #4
  br label %122

122:                                              ; preds = %113, %107
  store i32 1, ptr @Pipeline0.Sgn_valid, align 4, !tbaa !9
  br label %123

123:                                              ; preds = %122, %104
  br label %124

124:                                              ; preds = %123
  br label %125

125:                                              ; preds = %124
  %126 = load ptr, ptr %7, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.HandlePipeline, ptr %126, i32 0, i32 4
  %128 = getelementptr inbounds %struct.MThreadSignal, ptr %127, i32 0, i32 0
  %129 = call i32 @pthread_mutex_lock(ptr noundef %128) #4
  br label %130

130:                                              ; preds = %125
  br label %131

131:                                              ; preds = %130
  br label %132

132:                                              ; preds = %139, %131
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.HandlePipeline, ptr %133, i32 0, i32 3
  %135 = load volatile i32, ptr %134, align 8, !tbaa !24
  %136 = load i32, ptr %10, align 4, !tbaa !9
  %137 = icmp sge i32 %135, %136
  %138 = xor i1 %137, true
  br i1 %138, label %139, label %147

139:                                              ; preds = %132
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.HandlePipeline, ptr %140, i32 0, i32 4
  %142 = getelementptr inbounds %struct.MThreadSignal, ptr %141, i32 0, i32 1
  %143 = load ptr, ptr %7, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.HandlePipeline, ptr %143, i32 0, i32 4
  %145 = getelementptr inbounds %struct.MThreadSignal, ptr %144, i32 0, i32 0
  %146 = call i32 @pthread_cond_wait(ptr noundef %142, ptr noundef %145)
  br label %132, !llvm.loop !25

147:                                              ; preds = %132
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.HandlePipeline, ptr %148, i32 0, i32 4
  %150 = getelementptr inbounds %struct.MThreadSignal, ptr %149, i32 0, i32 0
  %151 = call i32 @pthread_mutex_unlock(ptr noundef %150) #4
  br label %152

152:                                              ; preds = %147
  br label %153

153:                                              ; preds = %152
  %154 = load ptr, ptr %7, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.HandlePipeline, ptr %154, i32 0, i32 6
  %156 = load volatile i32, ptr %155, align 8, !tbaa !19
  %157 = icmp ne i32 %156, 0
  br i1 %157, label %158, label %168

158:                                              ; preds = %153
  %159 = load ptr, ptr %7, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.HandlePipeline, ptr %159, i32 0, i32 6
  %161 = load volatile i32, ptr %160, align 8, !tbaa !19
  %162 = load ptr, ptr %7, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.HandlePipeline, ptr %162, i32 0, i32 0
  %164 = load volatile i32, ptr %163, align 8, !tbaa !16
  %165 = sub nsw i32 %164, %161
  store volatile i32 %165, ptr %163, align 8, !tbaa !16
  %166 = load ptr, ptr %7, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.HandlePipeline, ptr %166, i32 0, i32 6
  store volatile i32 1, ptr %167, align 8, !tbaa !19
  br label %168

168:                                              ; preds = %158, %153
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %169

169:                                              ; preds = %204, %168
  %170 = load i32, ptr %11, align 4, !tbaa !9
  %171 = load ptr, ptr %4, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.MList, ptr %171, i32 0, i32 0
  %173 = load i32, ptr %172, align 8, !tbaa !14
  %174 = icmp slt i32 %170, %173
  br i1 %174, label %176, label %175

175:                                              ; preds = %169
  store i32 13, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %207

176:                                              ; preds = %169
  %177 = load ptr, ptr %7, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.HandlePipeline, ptr %177, i32 0, i32 1
  %179 = load ptr, ptr %178, align 8, !tbaa !20
  %180 = load i32, ptr %11, align 4, !tbaa !9
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds i32, ptr %179, i64 %181
  %183 = load i32, ptr %182, align 4, !tbaa !9
  %184 = add nsw i32 %183, 1
  store i32 %184, ptr %182, align 4, !tbaa !9
  %185 = load ptr, ptr %7, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.HandlePipeline, ptr %185, i32 0, i32 1
  %187 = load ptr, ptr %186, align 8, !tbaa !20
  %188 = load i32, ptr %11, align 4, !tbaa !9
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds i32, ptr %187, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !9
  %192 = load ptr, ptr %4, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.MList, ptr %192, i32 0, i32 0
  %194 = load i32, ptr %193, align 8, !tbaa !14
  %195 = icmp eq i32 %191, %194
  br i1 %195, label %196, label %203

196:                                              ; preds = %176
  %197 = load ptr, ptr %7, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.HandlePipeline, ptr %197, i32 0, i32 1
  %199 = load ptr, ptr %198, align 8, !tbaa !20
  %200 = load i32, ptr %11, align 4, !tbaa !9
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds i32, ptr %199, i64 %201
  store i32 0, ptr %202, align 4, !tbaa !9
  br label %203

203:                                              ; preds = %196, %176
  br label %204

204:                                              ; preds = %203
  %205 = load i32, ptr %11, align 4, !tbaa !9
  %206 = add nsw i32 %205, 1
  store i32 %206, ptr %11, align 4, !tbaa !9
  br label %169, !llvm.loop !26

207:                                              ; preds = %175
  %208 = load ptr, ptr %7, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.HandlePipeline, ptr %208, i32 0, i32 3
  store volatile i32 1, ptr %209, align 8, !tbaa !24
  br label %210

210:                                              ; preds = %207
  br label %211

211:                                              ; preds = %210
  br label %212

212:                                              ; preds = %211
  %213 = load i32, ptr @Pipeline0.Sgn_valid.1, align 4, !tbaa !9
  %214 = icmp eq i32 %213, 0
  br i1 %214, label %215, label %231

215:                                              ; preds = %212
  %216 = load ptr, ptr %7, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.HandlePipeline, ptr %216, i32 0, i32 5
  %218 = getelementptr inbounds %struct.MThreadSignal, ptr %217, i32 0, i32 3
  %219 = atomicrmw xchg ptr %218, i32 -1135873169 seq_cst, align 8
  %220 = icmp ne i32 %219, -1135873169
  br i1 %220, label %221, label %230

221:                                              ; preds = %215
  %222 = load ptr, ptr %7, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.HandlePipeline, ptr %222, i32 0, i32 5
  %224 = getelementptr inbounds %struct.MThreadSignal, ptr %223, i32 0, i32 0
  %225 = call i32 @pthread_mutex_init(ptr noundef %224, ptr noundef null) #4
  %226 = load ptr, ptr %7, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.HandlePipeline, ptr %226, i32 0, i32 5
  %228 = getelementptr inbounds %struct.MThreadSignal, ptr %227, i32 0, i32 2
  %229 = call i32 @pthread_rwlock_init(ptr noundef %228, ptr noundef null) #4
  br label %230

230:                                              ; preds = %221, %215
  store i32 1, ptr @Pipeline0.Sgn_valid.1, align 4, !tbaa !9
  br label %231

231:                                              ; preds = %230, %212
  br label %232

232:                                              ; preds = %231
  br label %233

233:                                              ; preds = %232
  %234 = load ptr, ptr %7, align 8, !tbaa !5
  %235 = getelementptr inbounds %struct.HandlePipeline, ptr %234, i32 0, i32 5
  %236 = getelementptr inbounds %struct.MThreadSignal, ptr %235, i32 0, i32 0
  %237 = call i32 @pthread_mutex_lock(ptr noundef %236) #4
  br label %238

238:                                              ; preds = %233
  br label %239

239:                                              ; preds = %238
  %240 = load ptr, ptr %7, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.HandlePipeline, ptr %240, i32 0, i32 5
  %242 = getelementptr inbounds %struct.MThreadSignal, ptr %241, i32 0, i32 1
  %243 = call i32 @pthread_cond_broadcast(ptr noundef %242) #4
  %244 = load ptr, ptr %7, align 8, !tbaa !5
  %245 = getelementptr inbounds %struct.HandlePipeline, ptr %244, i32 0, i32 5
  %246 = getelementptr inbounds %struct.MThreadSignal, ptr %245, i32 0, i32 0
  %247 = call i32 @pthread_mutex_unlock(ptr noundef %246) #4
  br label %248

248:                                              ; preds = %239
  br label %249

249:                                              ; preds = %248
  %250 = load ptr, ptr %7, align 8, !tbaa !5
  %251 = getelementptr inbounds %struct.HandlePipeline, ptr %250, i32 0, i32 2
  %252 = load ptr, ptr %251, align 8, !tbaa !21
  %253 = load i32, ptr %5, align 4, !tbaa !9
  %254 = sext i32 %253 to i64
  %255 = getelementptr inbounds i32, ptr %252, i64 %254
  %256 = load i32, ptr %255, align 4, !tbaa !9
  %257 = icmp slt i32 %256, 0
  br i1 %257, label %258, label %262

258:                                              ; preds = %249
  %259 = load ptr, ptr %4, align 8, !tbaa !5
  %260 = load i32, ptr %5, align 4, !tbaa !9
  %261 = call ptr @Pipeline0(ptr noundef %259, i32 noundef %260)
  store ptr %261, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %276

262:                                              ; preds = %249
  %263 = load ptr, ptr %4, align 8, !tbaa !5
  %264 = getelementptr inbounds %struct.MList, ptr %263, i32 0, i32 1
  %265 = load ptr, ptr %264, align 8, !tbaa !27
  %266 = load ptr, ptr %7, align 8, !tbaa !5
  %267 = getelementptr inbounds %struct.HandlePipeline, ptr %266, i32 0, i32 2
  %268 = load ptr, ptr %267, align 8, !tbaa !21
  %269 = load i32, ptr %5, align 4, !tbaa !9
  %270 = sext i32 %269 to i64
  %271 = getelementptr inbounds i32, ptr %268, i64 %270
  %272 = load i32, ptr %271, align 4, !tbaa !9
  %273 = sext i32 %272 to i64
  %274 = getelementptr inbounds ptr, ptr %265, i64 %273
  %275 = load ptr, ptr %274, align 8, !tbaa !5
  store ptr %275, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %276

276:                                              ; preds = %262, %258
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %277

277:                                              ; preds = %276, %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %278 = load ptr, ptr %3, align 8
  ret ptr %278
}

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

declare ptr @m_Malloc(i32 noundef) #2

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

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

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

declare i32 @pthread_cond_wait(ptr noundef, ptr noundef) #2

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !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, !6, i64 16}
!12 = !{!"MHandle", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!13 = !{!12, !10, i64 4}
!14 = !{!15, !10, i64 0}
!15 = !{!"MList", !10, i64 0, !6, i64 8}
!16 = !{!17, !10, i64 0}
!17 = !{!"HandlePipeline", !10, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !18, i64 32, !18, i64 184, !10, i64 336}
!18 = !{!"MThreadSignal", !7, i64 0, !7, i64 40, !7, i64 88, !10, i64 144}
!19 = !{!17, !10, i64 336}
!20 = !{!17, !6, i64 8}
!21 = !{!17, !6, i64 16}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!17, !10, i64 24}
!25 = distinct !{!25, !23}
!26 = distinct !{!26, !23}
!27 = !{!15, !6, i64 8}


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

@Pipeline0.Sgn_valid = external hidden local_unnamed_addr global i32, align 4
@Pipeline0.Sgn_valid.1 = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local void @endPipeline(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @Pipeline0(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = sext i32 %1 to i64
  br label %tailrecurse

tailrecurse:                                      ; preds = %96, %2
  %4 = tail call ptr @GetHandle(ptr noundef %0, i32 noundef 344, i32 noundef 75085391, ptr noundef nonnull @endPipeline) #3
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 4
  %8 = load volatile i32, ptr %7, align 4, !tbaa !11
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %tailrecurse._crit_edge

tailrecurse._crit_edge:                           ; preds = %tailrecurse
  %.phi.trans.insert = getelementptr inbounds i8, ptr %6, i64 16
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !12
  br label %34

10:                                               ; preds = %tailrecurse
  %11 = load i32, ptr %0, align 8, !tbaa !15
  store volatile i32 %11, ptr %6, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %6, i64 336
  store volatile i32 0, ptr %12, align 8, !tbaa !18
  %13 = shl i32 %11, 2
  %14 = tail call ptr @m_Malloc(i32 noundef %13) #3
  %15 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %14, ptr %15, align 8, !tbaa !19
  %16 = load i32, ptr %0, align 8, !tbaa !15
  %17 = shl i32 %16, 2
  %18 = tail call ptr @m_Malloc(i32 noundef %17) #3
  %19 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %18, ptr %19, align 8, !tbaa !12
  %20 = load i32, ptr %0, align 8, !tbaa !15
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10
  %22 = load ptr, ptr %15, align 8, !tbaa !19
  br label %24

._crit_edge:                                      ; preds = %24, %10
  store volatile i32 1, ptr %7, align 4, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %6, i64 24
  store volatile i32 1, ptr %23, align 8, !tbaa !20
  br label %34

24:                                               ; preds = %.lr.ph, %24
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %24 ]
  %25 = getelementptr inbounds i32, ptr %22, i64 %indvars.iv
  %26 = trunc i64 %indvars.iv to i32
  %27 = sub i32 0, %26
  store i32 %27, ptr %25, align 4, !tbaa !21
  %28 = trunc nuw nsw i64 %indvars.iv to i32
  %29 = xor i32 %28, -1
  %30 = getelementptr inbounds i32, ptr %18, i64 %indvars.iv
  store i32 %29, ptr %30, align 4, !tbaa !21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %31 = load i32, ptr %0, align 8, !tbaa !15
  %32 = sext i32 %31 to i64
  %33 = icmp slt i64 %indvars.iv.next, %32
  br i1 %33, label %24, label %._crit_edge, !llvm.loop !22

34:                                               ; preds = %tailrecurse._crit_edge, %._crit_edge
  %35 = phi ptr [ %.pre, %tailrecurse._crit_edge ], [ %18, %._crit_edge ]
  %36 = getelementptr inbounds i8, ptr %6, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = getelementptr inbounds i32, ptr %37, i64 %3
  %39 = load i32, ptr %38, align 4, !tbaa !21
  %40 = getelementptr inbounds i8, ptr %6, i64 16
  %41 = getelementptr inbounds i32, ptr %35, i64 %3
  store i32 %39, ptr %41, align 4, !tbaa !21
  %42 = load volatile i32, ptr %6, align 8, !tbaa !17
  %43 = icmp eq i32 %42, 1
  br i1 %43, label %.loopexit, label %44

44:                                               ; preds = %34
  %45 = load volatile i32, ptr %6, align 8, !tbaa !17
  %46 = load i32, ptr @Pipeline0.Sgn_valid, align 4, !tbaa !21
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %57

48:                                               ; preds = %44
  %49 = getelementptr inbounds i8, ptr %6, i64 176
  %50 = atomicrmw xchg ptr %49, i32 -1135873169 seq_cst, align 8
  %.not = icmp eq i32 %50, -1135873169
  br i1 %.not, label %56, label %51

51:                                               ; preds = %48
  %52 = getelementptr inbounds i8, ptr %6, i64 32
  %53 = tail call i32 @pthread_mutex_init(ptr noundef nonnull %52, ptr noundef null) #3
  %54 = getelementptr inbounds i8, ptr %6, i64 120
  %55 = tail call i32 @pthread_rwlock_init(ptr noundef nonnull %54, ptr noundef null) #3
  br label %56

56:                                               ; preds = %51, %48
  store i32 1, ptr @Pipeline0.Sgn_valid, align 4, !tbaa !21
  br label %57

57:                                               ; preds = %56, %44
  %58 = getelementptr inbounds i8, ptr %6, i64 32
  %59 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %58) #3
  %60 = getelementptr inbounds i8, ptr %6, i64 24
  %61 = load volatile i32, ptr %60, align 8, !tbaa !20
  %.not6773 = icmp slt i32 %61, %45
  br i1 %.not6773, label %.lr.ph75, label %._crit_edge76

.lr.ph75:                                         ; preds = %57
  %62 = getelementptr inbounds i8, ptr %6, i64 72
  br label %63

63:                                               ; preds = %.lr.ph75, %63
  %64 = tail call i32 @pthread_cond_wait(ptr noundef nonnull %62, ptr noundef nonnull %58) #3
  %65 = load volatile i32, ptr %60, align 8, !tbaa !20
  %.not67 = icmp slt i32 %65, %45
  br i1 %.not67, label %63, label %._crit_edge76, !llvm.loop !24

._crit_edge76:                                    ; preds = %63, %57
  %66 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %58) #3
  %67 = getelementptr inbounds i8, ptr %6, i64 336
  %68 = load volatile i32, ptr %67, align 8, !tbaa !18
  %.not68 = icmp eq i32 %68, 0
  br i1 %.not68, label %73, label %69

69:                                               ; preds = %._crit_edge76
  %70 = load volatile i32, ptr %67, align 8, !tbaa !18
  %71 = load volatile i32, ptr %6, align 8, !tbaa !17
  %72 = sub nsw i32 %71, %70
  store volatile i32 %72, ptr %6, align 8, !tbaa !17
  store volatile i32 1, ptr %67, align 8, !tbaa !18
  br label %73

73:                                               ; preds = %69, %._crit_edge76
  %74 = load i32, ptr %0, align 8, !tbaa !15
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %.lr.ph79, label %._crit_edge80

._crit_edge80:                                    ; preds = %.lr.ph79, %73
  store volatile i32 1, ptr %60, align 8, !tbaa !20
  %76 = load i32, ptr @Pipeline0.Sgn_valid.1, align 4, !tbaa !21
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %87, label %96

.lr.ph79:                                         ; preds = %73, %.lr.ph79
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %.lr.ph79 ], [ 0, %73 ]
  %78 = load ptr, ptr %36, align 8, !tbaa !19
  %79 = getelementptr inbounds i32, ptr %78, i64 %indvars.iv82
  %80 = load i32, ptr %79, align 4, !tbaa !21
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %79, align 4, !tbaa !21
  %82 = load i32, ptr %0, align 8, !tbaa !15
  %83 = icmp eq i32 %81, %82
  %spec.store.select = select i1 %83, i32 0, i32 %81
  store i32 %spec.store.select, ptr %79, align 4
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %84 = load i32, ptr %0, align 8, !tbaa !15
  %85 = sext i32 %84 to i64
  %86 = icmp slt i64 %indvars.iv.next83, %85
  br i1 %86, label %.lr.ph79, label %._crit_edge80, !llvm.loop !25

87:                                               ; preds = %._crit_edge80
  %88 = getelementptr inbounds i8, ptr %6, i64 328
  %89 = atomicrmw xchg ptr %88, i32 -1135873169 seq_cst, align 8
  %.not69 = icmp eq i32 %89, -1135873169
  br i1 %.not69, label %95, label %90

90:                                               ; preds = %87
  %91 = getelementptr inbounds i8, ptr %6, i64 184
  %92 = tail call i32 @pthread_mutex_init(ptr noundef nonnull %91, ptr noundef null) #3
  %93 = getelementptr inbounds i8, ptr %6, i64 272
  %94 = tail call i32 @pthread_rwlock_init(ptr noundef nonnull %93, ptr noundef null) #3
  br label %95

95:                                               ; preds = %90, %87
  store i32 1, ptr @Pipeline0.Sgn_valid.1, align 4, !tbaa !21
  br label %96

96:                                               ; preds = %95, %._crit_edge80
  %97 = getelementptr inbounds i8, ptr %6, i64 184
  %98 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %97) #3
  %99 = getelementptr inbounds i8, ptr %6, i64 224
  %100 = tail call i32 @pthread_cond_broadcast(ptr noundef nonnull %99) #3
  %101 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %97) #3
  %102 = load ptr, ptr %40, align 8, !tbaa !12
  %103 = getelementptr inbounds i32, ptr %102, i64 %3
  %104 = load i32, ptr %103, align 4, !tbaa !21
  %105 = icmp slt i32 %104, 0
  br i1 %105, label %tailrecurse, label %106

106:                                              ; preds = %96
  %107 = getelementptr inbounds i8, ptr %0, i64 8
  %108 = load ptr, ptr %107, align 8, !tbaa !26
  %109 = zext nneg i32 %104 to i64
  %110 = getelementptr inbounds ptr, ptr %108, i64 %109
  %111 = load ptr, ptr %110, align 8, !tbaa !27
  br label %.loopexit

.loopexit:                                        ; preds = %34, %106
  %.1 = phi ptr [ %111, %106 ], [ null, %34 ]
  ret ptr %.1
}

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

declare ptr @m_Malloc(i32 noundef) local_unnamed_addr #1

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

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

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

declare i32 @pthread_cond_wait(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind
declare i32 @pthread_cond_broadcast(ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 = { 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 #3 = { 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 16}
!6 = !{!"MHandle", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!13, !10, i64 16}
!13 = !{!"HandlePipeline", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !14, i64 32, !14, i64 184, !7, i64 336}
!14 = !{!"MThreadSignal", !8, i64 0, !8, i64 40, !8, i64 88, !7, i64 144}
!15 = !{!16, !7, i64 0}
!16 = !{!"MList", !7, i64 0, !10, i64 8}
!17 = !{!13, !7, i64 0}
!18 = !{!13, !7, i64 336}
!19 = !{!13, !10, i64 8}
!20 = !{!13, !7, i64 24}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = distinct !{!25, !23}
!26 = !{!16, !10, i64 8}
!27 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass