; LLVM IR from indygreg/python-zstandard :: zstd (zstd)

; 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.syncPoint_t = type { i64, i32 }
%struct.ZSTDMT_CCtx_s = type { ptr, ptr, ptr, ptr, ptr, %struct.ZSTD_CCtx_params_s, i64, i64, i32, %struct.inBuff_t, %struct.roundBuff_t, %struct.serialState_t, %struct.rsyncState_t, i32, i32, i32, i32, i32, i64, i64, i64, %struct.ZSTD_customMem, ptr, ptr, i8 }
%struct.ZSTD_CCtx_params_s = type { i32, %struct.ZSTD_compressionParameters, %struct.ZSTD_frameParameters, i32, i32, i64, i32, i32, i32, i32, i64, i32, i32, %struct.ldmParams_t, i32, i32, i32, i32, i32, i32, i32, i32, %struct.ZSTD_customMem, i32, i32, ptr, ptr, i64, i32 }
%struct.ZSTD_compressionParameters = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.ZSTD_frameParameters = type { i32, i32, i32 }
%struct.ldmParams_t = type { i32, i32, i32, i32, i32, i32 }
%struct.inBuff_t = type { %struct.range_t, %struct.buffer_s, i64 }
%struct.range_t = type { ptr, i64 }
%struct.buffer_s = type { ptr, i64 }
%struct.roundBuff_t = type { ptr, i64, i64 }
%struct.serialState_t = type { %union.pthread_mutex_t, %union.pthread_cond_t, %struct.ZSTD_CCtx_params_s, %struct.ldmState_t, %struct.XXH_NAMESPACEXXH64_state_s, i32, %union.pthread_mutex_t, %union.pthread_cond_t, %struct.ZSTD_window_t }
%struct.ldmState_t = type { %struct.ZSTD_window_t, ptr, i32, ptr, [64 x i64], [64 x %struct.ldmMatchCandidate_t] }
%struct.ldmMatchCandidate_t = type { ptr, i32, i32, ptr }
%struct.XXH_NAMESPACEXXH64_state_s = type { i64, [4 x i64], [4 x i64], i32, i32, i64 }
%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 }
%struct.ZSTD_window_t = type { ptr, ptr, ptr, i32, i32, i32 }
%struct.rsyncState_t = type { i64, i64, i64 }
%struct.ZSTD_customMem = type { ptr, ptr, ptr }
%struct.ZSTD_inBuffer_s = type { ptr, i64, i64 }

; Function Attrs: nounwind uwtable
declare hidden i32 @ERR_isError(i64 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: 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
define dso_local i64 @ZSTDMT_compressStream_generic(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.syncPoint_t, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %4
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %19, i32 0, i32 16
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %18
  %24 = load i32, ptr %9, align 4, !tbaa !9
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store i64 -60, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %232

27:                                               ; preds = %23, %18
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %28, i32 0, i32 8
  %30 = load i32, ptr %29, align 8, !tbaa !29
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %123, label %32

32:                                               ; preds = %27
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %33, i32 0, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !30
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %36, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !32
  %39 = icmp ugt i64 %35, %38
  br i1 %39, label %40, label %123

40:                                               ; preds = %32
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %41, i32 0, i32 9
  %43 = getelementptr inbounds %struct.inBuff_t, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.buffer_s, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !33
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %60

47:                                               ; preds = %40
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call i32 @ZSTDMT_tryGetInputRange(ptr noundef %48)
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %55, label %51

51:                                               ; preds = %47
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  br label %59

55:                                               ; preds = %47
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  br label %59

59:                                               ; preds = %58, %54
  br label %60

60:                                               ; preds = %59, %40
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %61, i32 0, i32 9
  %63 = getelementptr inbounds %struct.inBuff_t, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.buffer_s, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !33
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %122

67:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #3
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = call { i64, i32 } @findSynchronizationPoint(ptr noundef %68, ptr noundef byval(%struct.ZSTD_inBuffer_s) align 8 %69)
  %71 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %72 = extractvalue { i64, i32 } %70, 0
  store i64 %72, ptr %71, align 8
  %73 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %74 = extractvalue { i64, i32 } %70, 1
  store i32 %74, ptr %73, align 8
  %75 = getelementptr inbounds %struct.syncPoint_t, ptr %12, i32 0, i32 1
  %76 = load i32, ptr %75, align 8, !tbaa !34
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %82

78:                                               ; preds = %67
  %79 = load i32, ptr %9, align 4, !tbaa !9
  %80 = icmp eq i32 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %78
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %81, %78, %67
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83
  br label %85

85:                                               ; preds = %84
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %86, i32 0, i32 9
  %88 = getelementptr inbounds %struct.inBuff_t, ptr %87, i32 0, i32 1
  %89 = getelementptr inbounds %struct.buffer_s, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !33
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %91, i32 0, i32 9
  %93 = getelementptr inbounds %struct.inBuff_t, ptr %92, i32 0, i32 2
  %94 = load i64, ptr %93, align 8, !tbaa !36
  %95 = getelementptr inbounds i8, ptr %90, i64 %94
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8, !tbaa !37
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %99, i32 0, i32 2
  %101 = load i64, ptr %100, align 8, !tbaa !32
  %102 = getelementptr inbounds i8, ptr %98, i64 %101
  %103 = getelementptr inbounds %struct.syncPoint_t, ptr %12, i32 0, i32 0
  %104 = load i64, ptr %103, align 8, !tbaa !38
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %95, ptr align 1 %102, i64 %104, i1 false)
  %105 = getelementptr inbounds %struct.syncPoint_t, ptr %12, i32 0, i32 0
  %106 = load i64, ptr %105, align 8, !tbaa !38
  %107 = load ptr, ptr %8, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %107, i32 0, i32 2
  %109 = load i64, ptr %108, align 8, !tbaa !32
  %110 = add i64 %109, %106
  store i64 %110, ptr %108, align 8, !tbaa !32
  %111 = getelementptr inbounds %struct.syncPoint_t, ptr %12, i32 0, i32 0
  %112 = load i64, ptr %111, align 8, !tbaa !38
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %113, i32 0, i32 9
  %115 = getelementptr inbounds %struct.inBuff_t, ptr %114, i32 0, i32 2
  %116 = load i64, ptr %115, align 8, !tbaa !36
  %117 = add i64 %116, %112
  store i64 %117, ptr %115, align 8, !tbaa !36
  %118 = getelementptr inbounds %struct.syncPoint_t, ptr %12, i32 0, i32 0
  %119 = load i64, ptr %118, align 8, !tbaa !38
  %120 = icmp ugt i64 %119, 0
  %121 = zext i1 %120 to i32
  store i32 %121, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  br label %122

122:                                              ; preds = %85, %60
  br label %123

123:                                              ; preds = %122, %32, %27
  %124 = load ptr, ptr %8, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %124, i32 0, i32 2
  %126 = load i64, ptr %125, align 8, !tbaa !32
  %127 = load ptr, ptr %8, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %127, i32 0, i32 1
  %129 = load i64, ptr %128, align 8, !tbaa !30
  %130 = icmp ult i64 %126, %129
  br i1 %130, label %131, label %135

131:                                              ; preds = %123
  %132 = load i32, ptr %9, align 4, !tbaa !9
  %133 = icmp eq i32 %132, 2
  br i1 %133, label %134, label %135

134:                                              ; preds = %131
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %135

135:                                              ; preds = %134, %131, %123
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %136, i32 0, i32 8
  %138 = load i32, ptr %137, align 8, !tbaa !29
  %139 = icmp ne i32 %138, 0
  br i1 %139, label %166, label %140

140:                                              ; preds = %135
  %141 = load ptr, ptr %6, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %141, i32 0, i32 9
  %143 = getelementptr inbounds %struct.inBuff_t, ptr %142, i32 0, i32 2
  %144 = load i64, ptr %143, align 8, !tbaa !36
  %145 = load ptr, ptr %6, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %145, i32 0, i32 6
  %147 = load i64, ptr %146, align 8, !tbaa !39
  %148 = icmp uge i64 %144, %147
  br i1 %148, label %166, label %149

149:                                              ; preds = %140
  %150 = load i32, ptr %9, align 4, !tbaa !9
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %158

152:                                              ; preds = %149
  %153 = load ptr, ptr %6, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %153, i32 0, i32 9
  %155 = getelementptr inbounds %struct.inBuff_t, ptr %154, i32 0, i32 2
  %156 = load i64, ptr %155, align 8, !tbaa !36
  %157 = icmp ugt i64 %156, 0
  br i1 %157, label %166, label %158

158:                                              ; preds = %152, %149
  %159 = load i32, ptr %9, align 4, !tbaa !9
  %160 = icmp eq i32 %159, 2
  br i1 %160, label %161, label %202

161:                                              ; preds = %158
  %162 = load ptr, ptr %6, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %162, i32 0, i32 16
  %164 = load i32, ptr %163, align 4, !tbaa !11
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %202, label %166

166:                                              ; preds = %161, %152, %140, %135
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %167 = load ptr, ptr %6, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.ZSTDMT_CCtx_s, ptr %167, i32 0, i32 9
  %169 = getelementptr inbounds %struct.inBuff_t, ptr %168, i32 0, i32 2
  %170 = load i64, ptr %169, align 8, !tbaa !36
  store i64 %170, ptr %13, align 8, !tbaa !40
  br label %171

171:                                              ; preds = %166
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %172 = load ptr, ptr %6, align 8, !tbaa !5
  %173 = load i64, ptr %13, align 8, !tbaa !40
  %174 = load i32, ptr %9, align 4, !tbaa !9
  %175 = call i64 @ZSTDMT_createCompressionJob(ptr noundef %172, i64 noundef %173, i32 noundef %174)
  store i64 %175, ptr %14, align 8, !tbaa !40
  %176 = load i64, ptr %14, align 8, !tbaa !40
  %177 = call i32 @ERR_isError(i64 noundef %176)
  %178 = icmp ne i32 %177, 0
  br i1 %178, label %179, label %193

179:                                              ; preds = %171
  br label %180

180:                                              ; preds = %179
  br label %181

181:                                              ; preds = %180
  br label %182

182:                                              ; preds = %181
  br label %183

183:                                              ; preds = %182
  br label %184

184:                                              ; preds = %183
  br label %185

185:                                              ; preds = %184
  br label %186

186:                                              ; preds = %185
  br label %187

187:                                              ; preds = %186
  br label %188

188:                                              ; preds = %187
  br label %189

189:                                              ; preds = %188
  br label %190

190:                                              ; preds = %189
  br label %191

191:                                              ; preds = %190
  %192 = load i64, ptr %14, align 8, !tbaa !40
  store i64 %192, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %194

193:                                              ; preds = %171
  store i32 0, ptr %11, align 4
  br label %194

194:                                              ; preds = %193, %191
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %195 = load i32, ptr %11, align 4
  switch i32 %195, label %199 [
    i32 0, label %196
  ]

196:                                              ; preds = %194
  br label %197

197:                                              ; preds = %196
  br label %198

198:                                              ; preds = %197
  store i32 0, ptr %11, align 4
  br label %199

199:                                              ; preds = %198, %194
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %200 = load i32, ptr %11, align 4
  switch i32 %200, label %232 [
    i32 0, label %201
  ]

201:                                              ; preds = %199
  br label %202

202:                                              ; preds = %201, %161, %158
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %203 = load ptr, ptr %6, align 8, !tbaa !5
  %204 = load ptr, ptr %7, align 8, !tbaa !5
  %205 = load i32, ptr %10, align 4, !tbaa !9
  %206 = icmp ne i32 %205, 0
  %207 = xor i1 %206, true
  %208 = zext i1 %207 to i32
  %209 = load i32, ptr %9, align 4, !tbaa !9
  %210 = call i64 @ZSTDMT_flushProduced(ptr noundef %203, ptr noundef %204, i32 noundef %208, i32 noundef %209)
  store i64 %210, ptr %15, align 8, !tbaa !40
  %211 = load ptr, ptr %8, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %211, i32 0, i32 2
  %213 = load i64, ptr %212, align 8, !tbaa !32
  %214 = load ptr, ptr %8, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.ZSTD_inBuffer_s, ptr %214, i32 0, i32 1
  %216 = load i64, ptr %215, align 8, !tbaa !30
  %217 = icmp ult i64 %213, %216
  br i1 %217, label %218, label %226

218:                                              ; preds = %202
  %219 = load i64, ptr %15, align 8, !tbaa !40
  %220 = icmp ugt i64 %219, 1
  br i1 %220, label %221, label %223

221:                                              ; preds = %218
  %222 = load i64, ptr %15, align 8, !tbaa !40
  br label %224

223:                                              ; preds = %218
  br label %224

224:                                              ; preds = %223, %221
  %225 = phi i64 [ %222, %221 ], [ 1, %223 ]
  store i64 %225, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %231

226:                                              ; preds = %202
  br label %227

227:                                              ; preds = %226
  br label %228

228:                                              ; preds = %227
  br label %229

229:                                              ; preds = %228
  %230 = load i64, ptr %15, align 8, !tbaa !40
  store i64 %230, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %231

231:                                              ; preds = %229, %224
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %232

232:                                              ; preds = %231, %199, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %233 = load i64, ptr %5, align 8
  ret i64 %233
}

; Function Attrs: nounwind uwtable
declare hidden i32 @ZSTDMT_tryGetInputRange(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden { i64, i32 } @findSynchronizationPoint(ptr noundef, ptr noundef byval(%struct.ZSTD_inBuffer_s) align 8) #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTDMT_createCompressionJob(ptr noundef, i64 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTDMT_flushProduced(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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, !10, i64 3020}
!12 = !{!"ZSTDMT_CCtx_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !16, i64 256, !16, i64 264, !10, i64 272, !19, i64 280, !22, i64 320, !23, i64 344, !27, i64 2984, !10, i64 3008, !10, i64 3012, !10, i64 3016, !10, i64 3020, !10, i64 3024, !28, i64 3032, !28, i64 3040, !28, i64 3048, !18, i64 3056, !6, i64 3080, !6, i64 3088, !10, i64 3096}
!13 = !{!"ZSTD_CCtx_params_s", !10, i64 0, !14, i64 4, !15, i64 32, !10, i64 44, !10, i64 48, !16, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !16, i64 80, !10, i64 88, !10, i64 92, !17, i64 96, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !18, i64 152, !10, i64 176, !10, i64 180, !6, i64 184, !6, i64 192, !16, i64 200, !10, i64 208}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!16 = !{!"long", !7, i64 0}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!18 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"", !20, i64 0, !21, i64 16, !16, i64 32}
!20 = !{!"", !6, i64 0, !16, i64 8}
!21 = !{!"buffer_s", !6, i64 0, !16, i64 8}
!22 = !{!"", !6, i64 0, !16, i64 8, !16, i64 16}
!23 = !{!"", !7, i64 0, !7, i64 40, !13, i64 88, !24, i64 304, !26, i64 2416, !10, i64 2504, !7, i64 2512, !7, i64 2552, !25, i64 2600}
!24 = !{!"", !25, i64 0, !6, i64 40, !10, i64 48, !6, i64 56, !7, i64 64, !7, i64 576}
!25 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32}
!26 = !{!"XXH_NAMESPACEXXH64_state_s", !16, i64 0, !7, i64 8, !7, i64 40, !10, i64 72, !10, i64 76, !16, i64 80}
!27 = !{!"", !16, i64 0, !16, i64 8, !16, i64 16}
!28 = !{!"long long", !7, i64 0}
!29 = !{!12, !10, i64 272}
!30 = !{!31, !16, i64 8}
!31 = !{!"ZSTD_inBuffer_s", !6, i64 0, !16, i64 8, !16, i64 16}
!32 = !{!31, !16, i64 16}
!33 = !{!12, !6, i64 296}
!34 = !{!35, !10, i64 8}
!35 = !{!"", !16, i64 0, !10, i64 8}
!36 = !{!12, !16, i64 312}
!37 = !{!31, !6, i64 0}
!38 = !{!35, !16, i64 0}
!39 = !{!12, !16, i64 256}
!40 = !{!16, !16, 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"

%struct.ZSTD_inBuffer_s = type { ptr, i64, i64 }

; Function Attrs: nounwind uwtable
declare hidden i32 @ERR_isError(i64 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
define dso_local i64 @ZSTDMT_compressStream_generic(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 3020
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp ne i32 %6, 0
  %8 = icmp eq i32 %3, 0
  %or.cond = and i1 %8, %7
  br i1 %or.cond, label %66, label %9

9:                                                ; preds = %4
  %10 = getelementptr inbounds i8, ptr %0, i64 272
  %11 = load i32, ptr %10, align 8, !tbaa !27
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %40

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %2, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !28
  %15 = getelementptr inbounds i8, ptr %2, i64 16
  %16 = load i64, ptr %15, align 8, !tbaa !30
  %17 = icmp ugt i64 %14, %16
  br i1 %17, label %18, label %40

18:                                               ; preds = %12
  %19 = getelementptr inbounds i8, ptr %0, i64 296
  %20 = load ptr, ptr %19, align 8, !tbaa !31
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %.thread

22:                                               ; preds = %18
  %23 = tail call i32 @ZSTDMT_tryGetInputRange(ptr noundef nonnull %0)
  %.pr = load ptr, ptr %19, align 8, !tbaa !31
  %.not58 = icmp eq ptr %.pr, null
  br i1 %.not58, label %40, label %.thread

.thread:                                          ; preds = %18, %22
  %24 = tail call { i64, i32 } @findSynchronizationPoint(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.ZSTD_inBuffer_s) align 8 %2)
  %25 = extractvalue { i64, i32 } %24, 0
  %26 = extractvalue { i64, i32 } %24, 1
  %27 = icmp ne i32 %26, 0
  %or.cond4 = and i1 %8, %27
  %spec.store.select = select i1 %or.cond4, i32 1, i32 %3
  %28 = load ptr, ptr %19, align 8, !tbaa !31
  %29 = getelementptr inbounds i8, ptr %0, i64 312
  %30 = load i64, ptr %29, align 8, !tbaa !32
  %31 = getelementptr inbounds i8, ptr %28, i64 %30
  %32 = load ptr, ptr %2, align 8, !tbaa !33
  %33 = load i64, ptr %15, align 8, !tbaa !30
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %31, ptr align 1 %34, i64 %25, i1 false)
  %35 = load i64, ptr %15, align 8, !tbaa !30
  %36 = add i64 %35, %25
  store i64 %36, ptr %15, align 8, !tbaa !30
  %37 = load i64, ptr %29, align 8, !tbaa !32
  %38 = add i64 %37, %25
  store i64 %38, ptr %29, align 8, !tbaa !32
  %.not66 = icmp eq i64 %25, 0
  %39 = zext i1 %.not66 to i32
  br label %40

40:                                               ; preds = %22, %.thread, %12, %9
  %.056 = phi i32 [ 1, %9 ], [ %39, %.thread ], [ 1, %22 ], [ 1, %12 ]
  %.055 = phi i32 [ %3, %9 ], [ %spec.store.select, %.thread ], [ %3, %22 ], [ %3, %12 ]
  %41 = getelementptr inbounds i8, ptr %2, i64 16
  %42 = load i64, ptr %41, align 8, !tbaa !30
  %43 = getelementptr inbounds i8, ptr %2, i64 8
  %44 = load i64, ptr %43, align 8, !tbaa !28
  %45 = icmp ult i64 %42, %44
  %46 = icmp eq i32 %.055, 2
  %or.cond6 = select i1 %45, i1 %46, i1 false
  %spec.store.select7 = select i1 %or.cond6, i32 1, i32 %.055
  %47 = load i32, ptr %10, align 8, !tbaa !27
  %.not59 = icmp eq i32 %47, 0
  %48 = getelementptr inbounds i8, ptr %0, i64 312
  %49 = load i64, ptr %48, align 8, !tbaa !32
  br i1 %.not59, label %50, label %._crit_edge

50:                                               ; preds = %40
  %51 = getelementptr inbounds i8, ptr %0, i64 256
  %52 = load i64, ptr %51, align 8, !tbaa !34
  %.not60 = icmp ult i64 %49, %52
  br i1 %.not60, label %53, label %._crit_edge

53:                                               ; preds = %50
  %.not61 = icmp eq i32 %spec.store.select7, 0
  %.not62 = icmp eq i64 %49, 0
  %or.cond67 = or i1 %.not61, %.not62
  br i1 %or.cond67, label %54, label %._crit_edge

54:                                               ; preds = %53
  %55 = icmp eq i32 %spec.store.select7, 2
  br i1 %55, label %56, label %60

56:                                               ; preds = %54
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %.not63 = icmp eq i32 %57, 0
  br i1 %.not63, label %._crit_edge, label %60

._crit_edge:                                      ; preds = %40, %53, %56, %50
  %58 = tail call i64 @ZSTDMT_createCompressionJob(ptr noundef nonnull %0, i64 noundef %49, i32 noundef %spec.store.select7)
  %59 = tail call i32 @ERR_isError(i64 noundef %58)
  %.not64 = icmp eq i32 %59, 0
  br i1 %.not64, label %60, label %66

60:                                               ; preds = %._crit_edge, %56, %54
  %61 = tail call i64 @ZSTDMT_flushProduced(ptr noundef nonnull %0, ptr noundef %1, i32 noundef %.056, i32 noundef %spec.store.select7)
  %62 = load i64, ptr %41, align 8, !tbaa !30
  %63 = load i64, ptr %43, align 8, !tbaa !28
  %64 = icmp ult i64 %62, %63
  %65 = tail call i64 @llvm.umax.i64(i64 %61, i64 1)
  %.1 = select i1 %64, i64 %65, i64 %61
  br label %66

66:                                               ; preds = %4, %._crit_edge, %60
  %.2 = phi i64 [ %.1, %60 ], [ %58, %._crit_edge ], [ -60, %4 ]
  ret i64 %.2
}

; Function Attrs: nounwind uwtable
declare hidden i32 @ZSTDMT_tryGetInputRange(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden { i64, i32 } @findSynchronizationPoint(ptr noundef, ptr noundef byval(%struct.ZSTD_inBuffer_s) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTDMT_createCompressionJob(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i64 @ZSTDMT_flushProduced(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 3020}
!6 = !{!"ZSTDMT_CCtx_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !14, i64 256, !14, i64 264, !11, i64 272, !17, i64 280, !20, i64 320, !21, i64 344, !25, i64 2984, !11, i64 3008, !11, i64 3012, !11, i64 3016, !11, i64 3020, !11, i64 3024, !26, i64 3032, !26, i64 3040, !26, i64 3048, !16, i64 3056, !7, i64 3080, !7, i64 3088, !11, i64 3096}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"ZSTD_CCtx_params_s", !11, i64 0, !12, i64 4, !13, i64 32, !11, i64 44, !11, i64 48, !14, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !14, i64 80, !11, i64 88, !11, i64 92, !15, i64 96, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !16, i64 152, !11, i64 176, !11, i64 180, !7, i64 184, !7, i64 192, !14, i64 200, !11, i64 208}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!14 = !{!"long", !8, i64 0}
!15 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!16 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!17 = !{!"", !18, i64 0, !19, i64 16, !14, i64 32}
!18 = !{!"", !7, i64 0, !14, i64 8}
!19 = !{!"buffer_s", !7, i64 0, !14, i64 8}
!20 = !{!"", !7, i64 0, !14, i64 8, !14, i64 16}
!21 = !{!"", !8, i64 0, !8, i64 40, !10, i64 88, !22, i64 304, !24, i64 2416, !11, i64 2504, !8, i64 2512, !8, i64 2552, !23, i64 2600}
!22 = !{!"", !23, i64 0, !7, i64 40, !11, i64 48, !7, i64 56, !8, i64 64, !8, i64 576}
!23 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !11, i64 24, !11, i64 28, !11, i64 32}
!24 = !{!"XXH_NAMESPACEXXH64_state_s", !14, i64 0, !8, i64 8, !8, i64 40, !11, i64 72, !11, i64 76, !14, i64 80}
!25 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16}
!26 = !{!"long long", !8, i64 0}
!27 = !{!6, !11, i64 272}
!28 = !{!29, !14, i64 8}
!29 = !{!"ZSTD_inBuffer_s", !7, i64 0, !14, i64 8, !14, i64 16}
!30 = !{!29, !14, i64 16}
!31 = !{!6, !7, i64 296}
!32 = !{!6, !14, i64 312}
!33 = !{!29, !7, i64 0}
!34 = !{!6, !14, i64 256}


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