; LLVM IR from jingweizhanghuai/Morn :: src/image (morn_image_binary)

; 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.MImage = type { i32, i32, i32, [4 x ptr], ptr }
%struct.MHandle = type { i32, i32, ptr, ptr }
%struct.HandleImageBinaryDenoise = type { ptr, ptr, i32 }

@.str = external hidden unnamed_addr constant [85 x i8], align 1
@__FUNCTION__.mImageBinaryDenoise = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1

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

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

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

declare void @m_Free(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @mImageBinaryDenoise(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  %26 = zext i1 %25 to i32
  store i32 %26, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

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

31:                                               ; preds = %29, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.MImage, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !11
  %37 = icmp ne i32 %36, 1
  %38 = zext i1 %37 to i32
  store i32 %38, ptr %8, align 4, !tbaa !9
  %39 = load i32, ptr %8, align 4, !tbaa !9
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %43

41:                                               ; preds = %33
  %42 = load i32, ptr %8, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %42, i32 noundef -1, ptr noundef @.str, i32 noundef 155, ptr noundef @__FUNCTION__.mImageBinaryDenoise, ptr noundef @.str.3)
  br label %43

43:                                               ; preds = %41, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = icmp sle i32 %46, 0
  %48 = zext i1 %47 to i32
  store i32 %48, ptr %9, align 4, !tbaa !9
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %54

51:                                               ; preds = %45
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = load i32, ptr %6, align 4, !tbaa !9
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %52, i32 noundef -1, ptr noundef @.str, i32 noundef 156, ptr noundef @__FUNCTION__.mImageBinaryDenoise, ptr noundef @.str.4, i32 noundef %53)
  br label %54

54:                                               ; preds = %51, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %55

55:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = call ptr @GetHandle(ptr noundef %56, i32 noundef 24, i32 noundef 768061410, ptr noundef @endImageBinaryDenoise)
  store ptr %57, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.MHandle, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  store ptr %60, ptr %11, align 8, !tbaa !5
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.MHandle, ptr %61, i32 0, i32 1
  %63 = load volatile i32, ptr %62, align 4, !tbaa !15
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %110

65:                                               ; preds = %55
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %66, i32 0, i32 2
  %68 = load i32, ptr %67, align 8, !tbaa !16
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %71, label %107

71:                                               ; preds = %65
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !18
  %75 = icmp ne ptr %74, null
  br i1 %75, label %76, label %80

76:                                               ; preds = %71
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !18
  call void @m_Free(ptr noundef %79)
  br label %80

80:                                               ; preds = %76, %71
  %81 = load i32, ptr %6, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = mul i64 %82, 4
  %84 = trunc i64 %83 to i32
  %85 = call ptr @m_Malloc(i32 noundef %84)
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %86, i32 0, i32 0
  store ptr %85, ptr %87, align 8, !tbaa !18
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %88, i32 0, i32 1
  %90 = load ptr, ptr %89, align 8, !tbaa !19
  %91 = icmp ne ptr %90, null
  br i1 %91, label %92, label %96

92:                                               ; preds = %80
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %93, i32 0, i32 1
  %95 = load ptr, ptr %94, align 8, !tbaa !19
  call void @m_Free(ptr noundef %95)
  br label %96

96:                                               ; preds = %92, %80
  %97 = load i32, ptr %6, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = mul i64 %98, 4
  %100 = trunc i64 %99 to i32
  %101 = call ptr @m_Malloc(i32 noundef %100)
  %102 = load ptr, ptr %11, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %102, i32 0, i32 1
  store ptr %101, ptr %103, align 8, !tbaa !19
  %104 = load i32, ptr %6, align 4, !tbaa !9
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %105, i32 0, i32 2
  store i32 %104, ptr %106, align 8, !tbaa !16
  br label %107

107:                                              ; preds = %96, %65
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.MHandle, ptr %108, i32 0, i32 1
  store volatile i32 1, ptr %109, align 4, !tbaa !15
  br label %110

110:                                              ; preds = %107, %55
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = icmp eq ptr %111, null
  br i1 %112, label %113, label %115

113:                                              ; preds = %110
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %114, ptr %5, align 8, !tbaa !5
  br label %115

115:                                              ; preds = %113, %110
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = load ptr, ptr %5, align 8, !tbaa !5
  %118 = icmp ne ptr %116, %117
  br i1 %118, label %119, label %123

119:                                              ; preds = %115
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mImageCopy(ptr noundef %120, ptr noundef %121)
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %122, ptr %4, align 8, !tbaa !5
  br label %123

123:                                              ; preds = %119, %115
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %124 = load ptr, ptr %11, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %124, i32 0, i32 0
  %126 = load ptr, ptr %125, align 8, !tbaa !18
  store ptr %126, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %127 = load ptr, ptr %11, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.HandleImageBinaryDenoise, ptr %127, i32 0, i32 1
  %129 = load ptr, ptr %128, align 8, !tbaa !19
  store ptr %129, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.MImage, ptr %130, i32 0, i32 3
  %132 = getelementptr inbounds [4 x ptr], ptr %131, i64 0, i64 0
  %133 = load ptr, ptr %132, align 8, !tbaa !5
  store ptr %133, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %134

134:                                              ; preds = %268, %123
  %135 = load i32, ptr %15, align 4, !tbaa !9
  %136 = load ptr, ptr %4, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.MImage, ptr %136, i32 0, i32 1
  %138 = load i32, ptr %137, align 4, !tbaa !20
  %139 = icmp slt i32 %135, %138
  br i1 %139, label %141, label %140

140:                                              ; preds = %134
  store i32 8, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %271

141:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %142

142:                                              ; preds = %264, %141
  %143 = load i32, ptr %17, align 4, !tbaa !9
  %144 = load ptr, ptr %4, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.MImage, ptr %144, i32 0, i32 2
  %146 = load i32, ptr %145, align 8, !tbaa !21
  %147 = icmp slt i32 %143, %146
  br i1 %147, label %149, label %148

148:                                              ; preds = %142
  store i32 11, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %267

149:                                              ; preds = %142
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %150 = load ptr, ptr %14, align 8, !tbaa !5
  %151 = load i32, ptr %15, align 4, !tbaa !9
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds ptr, ptr %150, i64 %152
  %154 = load ptr, ptr %153, align 8, !tbaa !5
  %155 = load i32, ptr %17, align 4, !tbaa !9
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds i8, ptr %154, i64 %156
  store ptr %157, ptr %18, align 8, !tbaa !5
  %158 = load ptr, ptr %18, align 8, !tbaa !5
  %159 = load i64, ptr %158, align 8, !tbaa !22
  %160 = icmp eq i64 %159, 0
  br i1 %160, label %161, label %162

161:                                              ; preds = %149
  store i32 13, ptr %16, align 4
  br label %261

162:                                              ; preds = %149
  %163 = load ptr, ptr %18, align 8, !tbaa !5
  %164 = load i64, ptr %163, align 8, !tbaa !22
  %165 = icmp eq i64 %164, -72340172838076674
  br i1 %165, label %166, label %168

166:                                              ; preds = %162
  %167 = load ptr, ptr %18, align 8, !tbaa !5
  store i64 -1, ptr %167, align 8, !tbaa !22
  store i32 13, ptr %16, align 4
  br label %261

168:                                              ; preds = %162
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %169 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %169, ptr %19, align 4, !tbaa !9
  br label %170

170:                                              ; preds = %257, %168
  %171 = load i32, ptr %19, align 4, !tbaa !9
  %172 = load i32, ptr %17, align 4, !tbaa !9
  %173 = add nsw i32 %172, 8
  %174 = icmp slt i32 %171, %173
  br i1 %174, label %176, label %175

175:                                              ; preds = %170
  store i32 14, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %260

176:                                              ; preds = %170
  %177 = load ptr, ptr %14, align 8, !tbaa !5
  %178 = load i32, ptr %15, align 4, !tbaa !9
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds ptr, ptr %177, i64 %179
  %181 = load ptr, ptr %180, align 8, !tbaa !5
  %182 = load i32, ptr %19, align 4, !tbaa !9
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds i8, ptr %181, i64 %183
  %185 = load i8, ptr %184, align 1, !tbaa !24
  %186 = zext i8 %185 to i32
  %187 = icmp eq i32 %186, 0
  br i1 %187, label %188, label %189

188:                                              ; preds = %176
  br label %257

189:                                              ; preds = %176
  %190 = load ptr, ptr %14, align 8, !tbaa !5
  %191 = load i32, ptr %15, align 4, !tbaa !9
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds ptr, ptr %190, i64 %192
  %194 = load ptr, ptr %193, align 8, !tbaa !5
  %195 = load i32, ptr %19, align 4, !tbaa !9
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds i8, ptr %194, i64 %196
  %198 = load i8, ptr %197, align 1, !tbaa !24
  %199 = zext i8 %198 to i32
  %200 = icmp eq i32 %199, 254
  br i1 %200, label %201, label %210

201:                                              ; preds = %189
  %202 = load ptr, ptr %14, align 8, !tbaa !5
  %203 = load i32, ptr %15, align 4, !tbaa !9
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds ptr, ptr %202, i64 %204
  %206 = load ptr, ptr %205, align 8, !tbaa !5
  %207 = load i32, ptr %19, align 4, !tbaa !9
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds i8, ptr %206, i64 %208
  store i8 -1, ptr %209, align 1, !tbaa !24
  br label %257

210:                                              ; preds = %189
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  store i32 0, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %211 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %211, ptr %21, align 4, !tbaa !9
  %212 = load ptr, ptr %4, align 8, !tbaa !5
  %213 = load i32, ptr %15, align 4, !tbaa !9
  %214 = load ptr, ptr %12, align 8, !tbaa !5
  %215 = load ptr, ptr %13, align 8, !tbaa !5
  %216 = load i32, ptr %6, align 4, !tbaa !9
  call void @_BinaryDenoise(ptr noundef %212, ptr noundef %21, i32 noundef %213, ptr noundef %20, ptr noundef %214, ptr noundef %215, i32 noundef %216)
  %217 = load i32, ptr %20, align 4, !tbaa !9
  %218 = load i32, ptr %6, align 4, !tbaa !9
  %219 = icmp slt i32 %217, %218
  br i1 %219, label %220, label %247

220:                                              ; preds = %210
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %221

221:                                              ; preds = %243, %220
  %222 = load i32, ptr %22, align 4, !tbaa !9
  %223 = load i32, ptr %20, align 4, !tbaa !9
  %224 = icmp slt i32 %222, %223
  br i1 %224, label %226, label %225

225:                                              ; preds = %221
  store i32 17, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  br label %246

226:                                              ; preds = %221
  %227 = load ptr, ptr %14, align 8, !tbaa !5
  %228 = load ptr, ptr %13, align 8, !tbaa !5
  %229 = load i32, ptr %22, align 4, !tbaa !9
  %230 = sext i32 %229 to i64
  %231 = getelementptr inbounds i32, ptr %228, i64 %230
  %232 = load i32, ptr %231, align 4, !tbaa !9
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds ptr, ptr %227, i64 %233
  %235 = load ptr, ptr %234, align 8, !tbaa !5
  %236 = load ptr, ptr %12, align 8, !tbaa !5
  %237 = load i32, ptr %22, align 4, !tbaa !9
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds i32, ptr %236, i64 %238
  %240 = load i32, ptr %239, align 4, !tbaa !9
  %241 = sext i32 %240 to i64
  %242 = getelementptr inbounds i8, ptr %235, i64 %241
  store i8 0, ptr %242, align 1, !tbaa !24
  br label %243

243:                                              ; preds = %226
  %244 = load i32, ptr %22, align 4, !tbaa !9
  %245 = add nsw i32 %244, 1
  store i32 %245, ptr %22, align 4, !tbaa !9
  br label %221, !llvm.loop !25

246:                                              ; preds = %225
  br label %256

247:                                              ; preds = %210
  %248 = load ptr, ptr %14, align 8, !tbaa !5
  %249 = load i32, ptr %15, align 4, !tbaa !9
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds ptr, ptr %248, i64 %250
  %252 = load ptr, ptr %251, align 8, !tbaa !5
  %253 = load i32, ptr %19, align 4, !tbaa !9
  %254 = sext i32 %253 to i64
  %255 = getelementptr inbounds i8, ptr %252, i64 %254
  store i8 -1, ptr %255, align 1, !tbaa !24
  br label %256

256:                                              ; preds = %247, %246
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  br label %257

257:                                              ; preds = %256, %201, %188
  %258 = load i32, ptr %19, align 4, !tbaa !9
  %259 = add nsw i32 %258, 1
  store i32 %259, ptr %19, align 4, !tbaa !9
  br label %170, !llvm.loop !27

260:                                              ; preds = %175
  store i32 0, ptr %16, align 4
  br label %261

261:                                              ; preds = %260, %166, %161
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  %262 = load i32, ptr %16, align 4
  switch i32 %262, label %272 [
    i32 0, label %263
    i32 13, label %264
  ]

263:                                              ; preds = %261
  br label %264

264:                                              ; preds = %263, %261
  %265 = load i32, ptr %17, align 4, !tbaa !9
  %266 = add nsw i32 %265, 8
  store i32 %266, ptr %17, align 4, !tbaa !9
  br label %142, !llvm.loop !28

267:                                              ; preds = %148
  br label %268

268:                                              ; preds = %267
  %269 = load i32, ptr %15, align 4, !tbaa !9
  %270 = add nsw i32 %269, 1
  store i32 %270, ptr %15, align 4, !tbaa !9
  br label %134, !llvm.loop !29

271:                                              ; preds = %140
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  ret void

272:                                              ; preds = %261
  unreachable
}

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

declare ptr @m_Malloc(i32 noundef) #1

declare void @mImageCopy(ptr noundef, ptr noundef) #1

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 = { 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 }

!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 0}
!12 = !{!"MImage", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 16, !6, i64 48}
!13 = !{!14, !6, i64 16}
!14 = !{!"MHandle", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!15 = !{!14, !10, i64 4}
!16 = !{!17, !10, i64 16}
!17 = !{!"HandleImageBinaryDenoise", !6, i64 0, !6, i64 8, !10, i64 16}
!18 = !{!17, !6, i64 0}
!19 = !{!17, !6, i64 8}
!20 = !{!12, !10, i64 4}
!21 = !{!12, !10, i64 8}
!22 = !{!23, !23, i64 0}
!23 = !{!"long", !7, i64 0}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}
!28 = distinct !{!28, !26}
!29 = distinct !{!29, !26}


; 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 [85 x i8], align 1
@__FUNCTION__.mImageBinaryDenoise = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress 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, ...) local_unnamed_addr #1

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

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

declare void @m_Free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @_BinaryDenoise(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @mImageBinaryDenoise(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = icmp eq ptr %0, null
  br i1 %6, 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 154, ptr noundef nonnull @__FUNCTION__.mImageBinaryDenoise, ptr noundef nonnull @.str.2) #3
  br label %8

8:                                                ; preds = %7, %3
  %9 = load i32, ptr %0, align 8, !tbaa !5
  %.not92 = icmp eq i32 %9, 1
  br i1 %.not92, label %11, label %10

10:                                               ; preds = %8
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 155, ptr noundef nonnull @__FUNCTION__.mImageBinaryDenoise, ptr noundef nonnull @.str.3) #3
  br label %11

11:                                               ; preds = %10, %8
  %12 = icmp slt i32 %2, 1
  br i1 %12, label %13, label %14

13:                                               ; preds = %11
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 156, ptr noundef nonnull @__FUNCTION__.mImageBinaryDenoise, ptr noundef nonnull @.str.4, i32 noundef %2) #3
  br label %14

14:                                               ; preds = %13, %11
  %15 = tail call ptr @GetHandle(ptr noundef nonnull %0, i32 noundef 24, i32 noundef 768061410, ptr noundef nonnull @endImageBinaryDenoise) #3
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %15, i64 4
  %19 = load volatile i32, ptr %18, align 4, !tbaa !13
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %37

21:                                               ; preds = %14
  %22 = getelementptr inbounds i8, ptr %17, i64 16
  %23 = load i32, ptr %22, align 8, !tbaa !14
  %24 = icmp slt i32 %23, %2
  br i1 %24, label %25, label %36

25:                                               ; preds = %21
  %26 = load ptr, ptr %17, align 8, !tbaa !16
  %.not = icmp eq ptr %26, null
  br i1 %.not, label %28, label %27

27:                                               ; preds = %25
  tail call void @m_Free(ptr noundef nonnull %26) #3
  br label %28

28:                                               ; preds = %27, %25
  %29 = shl i32 %2, 2
  %30 = tail call ptr @m_Malloc(i32 noundef %29) #3
  store ptr %30, ptr %17, align 8, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %17, i64 8
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %.not90 = icmp eq ptr %32, null
  br i1 %.not90, label %34, label %33

33:                                               ; preds = %28
  tail call void @m_Free(ptr noundef nonnull %32) #3
  br label %34

34:                                               ; preds = %33, %28
  %35 = tail call ptr @m_Malloc(i32 noundef %29) #3
  store ptr %35, ptr %31, align 8, !tbaa !17
  store i32 %2, ptr %22, align 8, !tbaa !14
  br label %36

36:                                               ; preds = %34, %21
  store volatile i32 1, ptr %18, align 4, !tbaa !13
  br label %37

37:                                               ; preds = %36, %14
  %38 = icmp eq ptr %1, null
  %spec.select = select i1 %38, ptr %0, ptr %1
  %.not91 = icmp eq ptr %spec.select, %0
  br i1 %.not91, label %40, label %39

39:                                               ; preds = %37
  tail call void @mImageCopy(ptr noundef nonnull %0, ptr noundef nonnull %spec.select) #3
  br label %40

40:                                               ; preds = %39, %37
  %.078 = phi ptr [ %spec.select, %39 ], [ %0, %37 ]
  %41 = load ptr, ptr %17, align 8, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %17, i64 8
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = getelementptr inbounds i8, ptr %.078, i64 16
  %45 = load ptr, ptr %44, align 8, !tbaa !18
  %46 = getelementptr inbounds i8, ptr %.078, i64 4
  %47 = load i32, ptr %46, align 4, !tbaa !19
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.preheader95.lr.ph, label %._crit_edge101

.preheader95.lr.ph:                               ; preds = %40
  %49 = getelementptr inbounds i8, ptr %.078, i64 8
  %50 = load i32, ptr %49, align 8, !tbaa !20
  %51 = icmp sgt i32 %50, 0
  br i1 %51, label %.preheader95, label %._crit_edge101

.preheader95:                                     ; preds = %.preheader95.lr.ph, %._crit_edge
  %52 = phi i32 [ %58, %._crit_edge ], [ %47, %.preheader95.lr.ph ]
  %53 = phi i32 [ %59, %._crit_edge ], [ %50, %.preheader95.lr.ph ]
  %54 = phi i32 [ %60, %._crit_edge ], [ %50, %.preheader95.lr.ph ]
  %indvars.iv116 = phi i64 [ %indvars.iv.next117, %._crit_edge ], [ 0, %.preheader95.lr.ph ]
  %55 = icmp sgt i32 %54, 0
  br i1 %55, label %.lr.ph99, label %._crit_edge

.lr.ph99:                                         ; preds = %.preheader95
  %56 = getelementptr inbounds ptr, ptr %45, i64 %indvars.iv116
  %57 = trunc nuw nsw i64 %indvars.iv116 to i32
  br label %63

._crit_edge101:                                   ; preds = %._crit_edge, %.preheader95.lr.ph, %40
  ret void

._crit_edge.loopexit:                             ; preds = %.loopexit94
  %.pre119 = load i32, ptr %46, align 4, !tbaa !19
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader95
  %58 = phi i32 [ %.pre119, %._crit_edge.loopexit ], [ %52, %.preheader95 ]
  %59 = phi i32 [ %94, %._crit_edge.loopexit ], [ %53, %.preheader95 ]
  %60 = phi i32 [ %94, %._crit_edge.loopexit ], [ %54, %.preheader95 ]
  %indvars.iv.next117 = add nuw nsw i64 %indvars.iv116, 1
  %61 = sext i32 %58 to i64
  %62 = icmp slt i64 %indvars.iv.next117, %61
  br i1 %62, label %.preheader95, label %._crit_edge101, !llvm.loop !21

63:                                               ; preds = %.lr.ph99, %.loopexit94
  %64 = phi i32 [ %53, %.lr.ph99 ], [ %94, %.loopexit94 ]
  %indvars.iv111 = phi i64 [ 8, %.lr.ph99 ], [ %indvars.iv.next112, %.loopexit94 ]
  %indvars.iv104 = phi i64 [ 0, %.lr.ph99 ], [ %indvars.iv.next105, %.loopexit94 ]
  %65 = load ptr, ptr %56, align 8, !tbaa !18
  %66 = getelementptr inbounds i8, ptr %65, i64 %indvars.iv104
  %67 = load i64, ptr %66, align 8, !tbaa !24
  switch i64 %67, label %.preheader93 [
    i64 0, label %.loopexit94
    i64 -72340172838076674, label %68
  ]

68:                                               ; preds = %63
  store i64 -1, ptr %66, align 8, !tbaa !24
  br label %.loopexit94

.preheader93:                                     ; preds = %63, %93
  %indvars.iv106 = phi i64 [ %indvars.iv.next107, %93 ], [ %indvars.iv104, %63 ]
  %69 = load ptr, ptr %56, align 8, !tbaa !18
  %70 = getelementptr inbounds i8, ptr %69, i64 %indvars.iv106
  %71 = load i8, ptr %70, align 1, !tbaa !26
  switch i8 %71, label %73 [
    i8 0, label %93
    i8 -2, label %72
  ]

72:                                               ; preds = %.preheader93
  store i8 -1, ptr %70, align 1, !tbaa !26
  br label %93

73:                                               ; preds = %.preheader93
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  store i32 0, ptr %4, align 4, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %74 = trunc nuw nsw i64 %indvars.iv106 to i32
  store i32 %74, ptr %5, align 4, !tbaa !27
  call void @_BinaryDenoise(ptr noundef %.078, ptr noundef nonnull %5, i32 noundef %57, ptr noundef nonnull %4, ptr noundef %41, ptr noundef %43, i32 noundef %2)
  %75 = load i32, ptr %4, align 4, !tbaa !27
  %76 = icmp slt i32 %75, %2
  br i1 %76, label %.preheader, label %90

.preheader:                                       ; preds = %73
  %77 = icmp sgt i32 %75, 0
  br i1 %77, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %78 = getelementptr inbounds i32, ptr %43, i64 %indvars.iv
  %79 = load i32, ptr %78, align 4, !tbaa !27
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds ptr, ptr %45, i64 %80
  %82 = load ptr, ptr %81, align 8, !tbaa !18
  %83 = getelementptr inbounds i32, ptr %41, i64 %indvars.iv
  %84 = load i32, ptr %83, align 4, !tbaa !27
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i8, ptr %82, i64 %85
  store i8 0, ptr %86, align 1, !tbaa !26
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %87 = load i32, ptr %4, align 4, !tbaa !27
  %88 = sext i32 %87 to i64
  %89 = icmp slt i64 %indvars.iv.next, %88
  br i1 %89, label %.lr.ph, label %.loopexit, !llvm.loop !28

90:                                               ; preds = %73
  %91 = load ptr, ptr %56, align 8, !tbaa !18
  %92 = getelementptr inbounds i8, ptr %91, i64 %indvars.iv106
  store i8 -1, ptr %92, align 1, !tbaa !26
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br label %93

93:                                               ; preds = %.preheader93, %.loopexit, %72
  %indvars.iv.next107 = add nuw i64 %indvars.iv106, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next107, %indvars.iv111
  br i1 %exitcond.not, label %.loopexit94.loopexit, label %.preheader93, !llvm.loop !29

.loopexit94.loopexit:                             ; preds = %93
  %.pre = load i32, ptr %49, align 8, !tbaa !20
  br label %.loopexit94

.loopexit94:                                      ; preds = %.loopexit94.loopexit, %63, %68
  %94 = phi i32 [ %.pre, %.loopexit94.loopexit ], [ %64, %63 ], [ %64, %68 ]
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, 8
  %95 = trunc nuw i64 %indvars.iv.next105 to i32
  %96 = icmp sgt i32 %94, %95
  %indvars.iv.next112 = add i64 %indvars.iv111, 8
  br i1 %96, label %63, label %._crit_edge.loopexit, !llvm.loop !30
}

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

declare void @mImageCopy(ptr noundef, ptr noundef) local_unnamed_addr #1

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

!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, !7, i64 0}
!6 = !{!"MImage", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 16, !10, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"MHandle", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!13 = !{!12, !7, i64 4}
!14 = !{!15, !7, i64 16}
!15 = !{!"HandleImageBinaryDenoise", !10, i64 0, !10, i64 8, !7, i64 16}
!16 = !{!15, !10, i64 0}
!17 = !{!15, !10, i64 8}
!18 = !{!10, !10, i64 0}
!19 = !{!6, !7, i64 4}
!20 = !{!6, !7, i64 8}
!21 = distinct !{!21, !22, !23}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.unswitch.partial.disable"}
!24 = !{!25, !25, i64 0}
!25 = !{!"long", !8, i64 0}
!26 = !{!8, !8, i64 0}
!27 = !{!7, !7, i64 0}
!28 = distinct !{!28, !22}
!29 = distinct !{!29, !22}
!30 = distinct !{!30, !22}


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