; LLVM IR from mkazhdan/DMG :: Util/TIFF (tif_write)

; 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.tiff = type { ptr, i32, i32, i32, i32, i32, ptr, i16, %struct.TIFFDirectory, %struct.TIFFHeader, ptr, ptr, i32, i16, i32, i32, i32, i16, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i32, ptr, i32, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr, %struct.TIFFTagMethods, ptr }
%struct.TIFFDirectory = type { [4 x i64], i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i16, i16, i32, i16, i16, double, double, float, float, i16, i16, float, float, [2 x i16], [3 x ptr], [2 x i16], i16, ptr, i32, i32, ptr, ptr, i32, i16, ptr, [2 x i16], i16, [3 x ptr], i32, ptr, i32, ptr }
%struct.TIFFHeader = type { i16, i16, i32 }
%struct.TIFFTagMethods = type { ptr, ptr, ptr }

@TIFFWriteEncodedTile.module = external hidden constant [21 x i8], align 16
@.str.3 = external hidden unnamed_addr constant [35 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @TIFFWriteCheck(ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TIFFWriteBufferSetup(ptr noundef, ptr noundef, i32 noundef) #1

declare void @TIFFErrorExt(ptr noundef, ptr noundef, ptr noundef, ...) #2

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

declare void @TIFFReverseBits(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @TIFFAppendToStrip(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @TIFFWriteEncodedTile(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i16, align 2
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  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 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.tiff, ptr %13, i32 0, i32 3
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = and i32 %15, 64
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %23, label %18

18:                                               ; preds = %4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call i32 @TIFFWriteCheck(ptr noundef %19, i32 noundef 1, ptr noundef @TIFFWriteEncodedTile.module)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

23:                                               ; preds = %18, %4
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.tiff, ptr %24, i32 0, i32 8
  store ptr %25, ptr %10, align 8, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TIFFDirectory, ptr %27, i32 0, i32 33
  %29 = load i32, ptr %28, align 4, !tbaa !20
  %30 = icmp uge i32 %26, %29
  br i1 %30, label %31, label %44

31:                                               ; preds = %23
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.tiff, ptr %32, i32 0, i32 51
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.tiff, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !22
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.TIFFDirectory, ptr %40, i32 0, i32 33
  %42 = load i32, ptr %41, align 4, !tbaa !20
  %43 = zext i32 %42 to i64
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %34, ptr noundef @TIFFWriteEncodedTile.module, ptr noundef @.str.3, ptr noundef %37, i64 noundef %39, i64 noundef %43)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

44:                                               ; preds = %23
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.tiff, ptr %45, i32 0, i32 3
  %47 = load i32, ptr %46, align 8, !tbaa !11
  %48 = and i32 %47, 16
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %55

50:                                               ; preds = %44
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.tiff, ptr %51, i32 0, i32 43
  %53 = load ptr, ptr %52, align 8, !tbaa !23
  %54 = icmp ne ptr %53, null
  br i1 %54, label %60, label %55

55:                                               ; preds = %50, %44
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = call i32 @TIFFWriteBufferSetup(ptr noundef %56, ptr noundef null, i32 noundef -1)
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

60:                                               ; preds = %55, %50
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.tiff, ptr %62, i32 0, i32 20
  store i32 %61, ptr %63, align 8, !tbaa !24
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.tiff, ptr %64, i32 0, i32 46
  store i32 0, ptr %65, align 8, !tbaa !25
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.tiff, ptr %66, i32 0, i32 43
  %68 = load ptr, ptr %67, align 8, !tbaa !23
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.tiff, ptr %69, i32 0, i32 45
  store ptr %68, ptr %70, align 8, !tbaa !26
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.TIFFDirectory, ptr %71, i32 0, i32 35
  %73 = load ptr, ptr %72, align 8, !tbaa !27
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr %73, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = icmp ugt i32 %77, 0
  br i1 %78, label %79, label %88

79:                                               ; preds = %60
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.TIFFDirectory, ptr %80, i32 0, i32 35
  %82 = load ptr, ptr %81, align 8, !tbaa !27
  %83 = load i32, ptr %7, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds i32, ptr %82, i64 %84
  store i32 0, ptr %85, align 4, !tbaa !9
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.tiff, ptr %86, i32 0, i32 15
  store i32 0, ptr %87, align 4, !tbaa !28
  br label %88

88:                                               ; preds = %79, %60
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.TIFFDirectory, ptr %90, i32 0, i32 2
  %92 = load i32, ptr %91, align 4, !tbaa !29
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.TIFFDirectory, ptr %93, i32 0, i32 5
  %95 = load i32, ptr %94, align 8, !tbaa !30
  %96 = sub i32 %95, 1
  %97 = add i32 %92, %96
  %98 = load ptr, ptr %10, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.TIFFDirectory, ptr %98, i32 0, i32 5
  %100 = load i32, ptr %99, align 8, !tbaa !30
  %101 = udiv i32 %97, %100
  %102 = urem i32 %89, %101
  %103 = load ptr, ptr %10, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.TIFFDirectory, ptr %103, i32 0, i32 5
  %105 = load i32, ptr %104, align 8, !tbaa !30
  %106 = mul i32 %102, %105
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.tiff, ptr %107, i32 0, i32 12
  store i32 %106, ptr %108, align 8, !tbaa !31
  %109 = load i32, ptr %7, align 4, !tbaa !9
  %110 = load ptr, ptr %10, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.TIFFDirectory, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 8, !tbaa !32
  %113 = load ptr, ptr %10, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.TIFFDirectory, ptr %113, i32 0, i32 4
  %115 = load i32, ptr %114, align 4, !tbaa !33
  %116 = sub i32 %115, 1
  %117 = add i32 %112, %116
  %118 = load ptr, ptr %10, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.TIFFDirectory, ptr %118, i32 0, i32 4
  %120 = load i32, ptr %119, align 4, !tbaa !33
  %121 = udiv i32 %117, %120
  %122 = urem i32 %109, %121
  %123 = load ptr, ptr %10, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.TIFFDirectory, ptr %123, i32 0, i32 4
  %125 = load i32, ptr %124, align 4, !tbaa !33
  %126 = mul i32 %122, %125
  %127 = load ptr, ptr %6, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.tiff, ptr %127, i32 0, i32 19
  store i32 %126, ptr %128, align 4, !tbaa !34
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.tiff, ptr %129, i32 0, i32 3
  %131 = load i32, ptr %130, align 8, !tbaa !11
  %132 = and i32 %131, 32
  %133 = icmp eq i32 %132, 0
  br i1 %133, label %134, label %147

134:                                              ; preds = %88
  %135 = load ptr, ptr %6, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.tiff, ptr %135, i32 0, i32 25
  %137 = load ptr, ptr %136, align 8, !tbaa !35
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = call i32 %137(ptr noundef %138)
  %140 = icmp ne i32 %139, 0
  br i1 %140, label %142, label %141

141:                                              ; preds = %134
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

142:                                              ; preds = %134
  %143 = load ptr, ptr %6, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.tiff, ptr %143, i32 0, i32 3
  %145 = load i32, ptr %144, align 8, !tbaa !11
  %146 = or i32 %145, 32
  store i32 %146, ptr %144, align 8, !tbaa !11
  br label %147

147:                                              ; preds = %142, %88
  %148 = load ptr, ptr %6, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.tiff, ptr %148, i32 0, i32 3
  %150 = load i32, ptr %149, align 8, !tbaa !11
  %151 = and i32 %150, -4097
  store i32 %151, ptr %149, align 8, !tbaa !11
  %152 = load i32, ptr %7, align 4, !tbaa !9
  %153 = load ptr, ptr %10, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.TIFFDirectory, ptr %153, i32 0, i32 32
  %155 = load i32, ptr %154, align 8, !tbaa !36
  %156 = udiv i32 %152, %155
  %157 = trunc i32 %156 to i16
  store i16 %157, ptr %11, align 2, !tbaa !37
  %158 = load ptr, ptr %6, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.tiff, ptr %158, i32 0, i32 27
  %160 = load ptr, ptr %159, align 8, !tbaa !38
  %161 = load ptr, ptr %6, align 8, !tbaa !5
  %162 = load i16, ptr %11, align 2, !tbaa !37
  %163 = call i32 %160(ptr noundef %161, i16 noundef zeroext %162)
  %164 = icmp ne i32 %163, 0
  br i1 %164, label %166, label %165

165:                                              ; preds = %147
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

166:                                              ; preds = %147
  %167 = load i32, ptr %9, align 4, !tbaa !9
  %168 = icmp slt i32 %167, 1
  br i1 %168, label %175, label %169

169:                                              ; preds = %166
  %170 = load i32, ptr %9, align 4, !tbaa !9
  %171 = load ptr, ptr %6, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.tiff, ptr %171, i32 0, i32 21
  %173 = load i32, ptr %172, align 4, !tbaa !39
  %174 = icmp sgt i32 %170, %173
  br i1 %174, label %175, label %179

175:                                              ; preds = %169, %166
  %176 = load ptr, ptr %6, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.tiff, ptr %176, i32 0, i32 21
  %178 = load i32, ptr %177, align 4, !tbaa !39
  store i32 %178, ptr %9, align 4, !tbaa !9
  br label %179

179:                                              ; preds = %175, %169
  %180 = load ptr, ptr %6, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.tiff, ptr %180, i32 0, i32 57
  %182 = load ptr, ptr %181, align 8, !tbaa !40
  %183 = load ptr, ptr %6, align 8, !tbaa !5
  %184 = load ptr, ptr %8, align 8, !tbaa !5
  %185 = load i32, ptr %9, align 4, !tbaa !9
  call void %182(ptr noundef %183, ptr noundef %184, i32 noundef %185)
  %186 = load ptr, ptr %6, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.tiff, ptr %186, i32 0, i32 34
  %188 = load ptr, ptr %187, align 8, !tbaa !41
  %189 = load ptr, ptr %6, align 8, !tbaa !5
  %190 = load ptr, ptr %8, align 8, !tbaa !5
  %191 = load i32, ptr %9, align 4, !tbaa !9
  %192 = load i16, ptr %11, align 2, !tbaa !37
  %193 = call i32 %188(ptr noundef %189, ptr noundef %190, i32 noundef %191, i16 noundef zeroext %192)
  %194 = icmp ne i32 %193, 0
  br i1 %194, label %196, label %195

195:                                              ; preds = %179
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

196:                                              ; preds = %179
  %197 = load ptr, ptr %6, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.tiff, ptr %197, i32 0, i32 28
  %199 = load ptr, ptr %198, align 8, !tbaa !42
  %200 = load ptr, ptr %6, align 8, !tbaa !5
  %201 = call i32 %199(ptr noundef %200)
  %202 = icmp ne i32 %201, 0
  br i1 %202, label %204, label %203

203:                                              ; preds = %196
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

204:                                              ; preds = %196
  %205 = load ptr, ptr %6, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.tiff, ptr %205, i32 0, i32 3
  %207 = load i32, ptr %206, align 8, !tbaa !11
  %208 = load ptr, ptr %10, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.TIFFDirectory, ptr %208, i32 0, i32 13
  %210 = load i16, ptr %209, align 2, !tbaa !43
  %211 = zext i16 %210 to i32
  %212 = and i32 %207, %211
  %213 = icmp ne i32 %212, 0
  br i1 %213, label %228, label %214

214:                                              ; preds = %204
  %215 = load ptr, ptr %6, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.tiff, ptr %215, i32 0, i32 3
  %217 = load i32, ptr %216, align 8, !tbaa !11
  %218 = and i32 %217, 256
  %219 = icmp eq i32 %218, 0
  br i1 %219, label %220, label %228

220:                                              ; preds = %214
  %221 = load ptr, ptr %6, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.tiff, ptr %221, i32 0, i32 43
  %223 = load ptr, ptr %222, align 8, !tbaa !23
  %224 = load ptr, ptr %6, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct.tiff, ptr %224, i32 0, i32 46
  %226 = load i32, ptr %225, align 8, !tbaa !25
  %227 = sext i32 %226 to i64
  call void @TIFFReverseBits(ptr noundef %223, i64 noundef %227)
  br label %228

228:                                              ; preds = %220, %214, %204
  %229 = load ptr, ptr %6, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.tiff, ptr %229, i32 0, i32 46
  %231 = load i32, ptr %230, align 8, !tbaa !25
  %232 = icmp sgt i32 %231, 0
  br i1 %232, label %233, label %245

233:                                              ; preds = %228
  %234 = load ptr, ptr %6, align 8, !tbaa !5
  %235 = load i32, ptr %7, align 4, !tbaa !9
  %236 = load ptr, ptr %6, align 8, !tbaa !5
  %237 = getelementptr inbounds %struct.tiff, ptr %236, i32 0, i32 43
  %238 = load ptr, ptr %237, align 8, !tbaa !23
  %239 = load ptr, ptr %6, align 8, !tbaa !5
  %240 = getelementptr inbounds %struct.tiff, ptr %239, i32 0, i32 46
  %241 = load i32, ptr %240, align 8, !tbaa !25
  %242 = call i32 @TIFFAppendToStrip(ptr noundef %234, i32 noundef %235, ptr noundef %238, i32 noundef %241)
  %243 = icmp ne i32 %242, 0
  br i1 %243, label %245, label %244

244:                                              ; preds = %233
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

245:                                              ; preds = %233, %228
  %246 = load ptr, ptr %6, align 8, !tbaa !5
  %247 = getelementptr inbounds %struct.tiff, ptr %246, i32 0, i32 46
  store i32 0, ptr %247, align 8, !tbaa !25
  %248 = load ptr, ptr %6, align 8, !tbaa !5
  %249 = getelementptr inbounds %struct.tiff, ptr %248, i32 0, i32 43
  %250 = load ptr, ptr %249, align 8, !tbaa !23
  %251 = load ptr, ptr %6, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.tiff, ptr %251, i32 0, i32 45
  store ptr %250, ptr %252, align 8, !tbaa !26
  %253 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %253, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %254

254:                                              ; preds = %245, %244, %203, %195, %165, %141, %59, %31, %22
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %255 = load i32, ptr %5, align 4
  ret i32 %255
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 }

!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 16}
!12 = !{!"tiff", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !13, i64 40, !14, i64 48, !17, i64 320, !6, i64 328, !6, i64 336, !10, i64 344, !13, i64 348, !10, i64 352, !10, i64 356, !10, i64 360, !13, i64 364, !10, i64 368, !10, i64 372, !10, i64 376, !10, i64 380, !10, i64 384, !6, i64 392, !6, i64 400, !6, i64 408, !10, i64 416, !6, i64 424, !6, i64 432, !6, i64 440, !6, i64 448, !6, i64 456, !6, i64 464, !6, i64 472, !6, i64 480, !6, i64 488, !6, i64 496, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !10, i64 536, !10, i64 540, !6, i64 544, !10, i64 552, !6, i64 560, !10, i64 568, !6, i64 576, !10, i64 584, !6, i64 592, !6, i64 600, !6, i64 608, !6, i64 616, !6, i64 624, !6, i64 632, !6, i64 640, !6, i64 648, !6, i64 656, !6, i64 664, !18, i64 672, !6, i64 680, !19, i64 688, !6, i64 712}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !7, i64 0, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !13, i64 60, !13, i64 62, !13, i64 64, !13, i64 66, !13, i64 68, !13, i64 70, !13, i64 72, !13, i64 74, !10, i64 76, !13, i64 80, !13, i64 82, !15, i64 88, !15, i64 96, !16, i64 104, !16, i64 108, !13, i64 112, !13, i64 114, !16, i64 116, !16, i64 120, !7, i64 124, !7, i64 128, !7, i64 152, !13, i64 156, !6, i64 160, !10, i64 168, !10, i64 172, !6, i64 176, !6, i64 184, !10, i64 192, !13, i64 196, !6, i64 200, !7, i64 208, !13, i64 212, !7, i64 216, !10, i64 240, !6, i64 248, !10, i64 256, !6, i64 264}
!15 = !{!"double", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!"", !13, i64 0, !13, i64 2, !10, i64 4}
!18 = !{!"long", !7, i64 0}
!19 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!14, !10, i64 172}
!21 = !{!12, !6, i64 608}
!22 = !{!12, !6, i64 0}
!23 = !{!12, !6, i64 544}
!24 = !{!12, !10, i64 376}
!25 = !{!12, !10, i64 568}
!26 = !{!12, !6, i64 560}
!27 = !{!14, !6, i64 184}
!28 = !{!12, !10, i64 356}
!29 = !{!14, !10, i64 36}
!30 = !{!14, !10, i64 48}
!31 = !{!12, !10, i64 344}
!32 = !{!14, !10, i64 32}
!33 = !{!14, !10, i64 44}
!34 = !{!12, !10, i64 372}
!35 = !{!12, !6, i64 408}
!36 = !{!14, !10, i64 168}
!37 = !{!13, !13, i64 0}
!38 = !{!12, !6, i64 424}
!39 = !{!12, !10, i64 380}
!40 = !{!12, !6, i64 656}
!41 = !{!12, !6, i64 480}
!42 = !{!12, !6, i64 432}
!43 = !{!14, !13, i64 70}


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

@TIFFWriteEncodedTile.module = external hidden constant [21 x i8], align 16
@.str.3 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TIFFWriteCheck(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @TIFFWriteBufferSetup(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @TIFFErrorExt(ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare void @TIFFReverseBits(ptr noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @TIFFWriteEncodedTile(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = and i32 %6, 64
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %8, label %10

8:                                                ; preds = %4
  %9 = tail call i32 @TIFFWriteCheck(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @TIFFWriteEncodedTile.module)
  %.not78 = icmp eq i32 %9, 0
  br i1 %.not78, label %110, label %10

10:                                               ; preds = %8, %4
  %11 = getelementptr inbounds i8, ptr %0, i64 220
  %12 = load i32, ptr %11, align 4, !tbaa !18
  %.not79 = icmp ugt i32 %12, %1
  br i1 %.not79, label %19, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 608
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  %16 = load ptr, ptr %0, align 8, !tbaa !20
  %17 = zext i32 %1 to i64
  %18 = zext i32 %12 to i64
  tail call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %15, ptr noundef nonnull @TIFFWriteEncodedTile.module, ptr noundef nonnull @.str.3, ptr noundef %16, i64 noundef %17, i64 noundef %18) #3
  br label %110

19:                                               ; preds = %10
  %20 = load i32, ptr %5, align 8, !tbaa !5
  %21 = and i32 %20, 16
  %.not80 = icmp eq i32 %21, 0
  br i1 %.not80, label %25, label %22

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %0, i64 544
  %24 = load ptr, ptr %23, align 8, !tbaa !21
  %.not81 = icmp eq ptr %24, null
  br i1 %.not81, label %25, label %27

25:                                               ; preds = %22, %19
  %26 = tail call i32 @TIFFWriteBufferSetup(ptr noundef nonnull %0, ptr noundef null, i32 noundef -1)
  %.not82 = icmp eq i32 %26, 0
  br i1 %.not82, label %110, label %._crit_edge

._crit_edge:                                      ; preds = %25
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 544
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !21
  br label %27

27:                                               ; preds = %._crit_edge, %22
  %28 = phi ptr [ %.pre, %._crit_edge ], [ %24, %22 ]
  %29 = getelementptr inbounds i8, ptr %0, i64 376
  store i32 %1, ptr %29, align 8, !tbaa !22
  %30 = getelementptr inbounds i8, ptr %0, i64 568
  store i32 0, ptr %30, align 8, !tbaa !23
  %31 = getelementptr inbounds i8, ptr %0, i64 544
  %32 = getelementptr inbounds i8, ptr %0, i64 560
  store ptr %28, ptr %32, align 8, !tbaa !24
  %33 = getelementptr inbounds i8, ptr %0, i64 232
  %34 = load ptr, ptr %33, align 8, !tbaa !25
  %35 = zext i32 %1 to i64
  %36 = getelementptr inbounds i32, ptr %34, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !26
  %.not83 = icmp eq i32 %37, 0
  br i1 %.not83, label %40, label %38

38:                                               ; preds = %27
  store i32 0, ptr %36, align 4, !tbaa !26
  %39 = getelementptr inbounds i8, ptr %0, i64 356
  store i32 0, ptr %39, align 4, !tbaa !27
  br label %40

40:                                               ; preds = %38, %27
  %41 = getelementptr inbounds i8, ptr %0, i64 84
  %42 = load i32, ptr %41, align 4, !tbaa !28
  %43 = getelementptr inbounds i8, ptr %0, i64 96
  %44 = load i32, ptr %43, align 8, !tbaa !29
  %45 = add i32 %42, -1
  %46 = add i32 %45, %44
  %47 = udiv i32 %46, %44
  %48 = urem i32 %1, %47
  %49 = mul i32 %48, %44
  %50 = getelementptr inbounds i8, ptr %0, i64 344
  store i32 %49, ptr %50, align 8, !tbaa !30
  %51 = getelementptr inbounds i8, ptr %0, i64 80
  %52 = load i32, ptr %51, align 8, !tbaa !31
  %53 = getelementptr inbounds i8, ptr %0, i64 92
  %54 = load i32, ptr %53, align 4, !tbaa !32
  %55 = add i32 %52, -1
  %56 = add i32 %55, %54
  %57 = udiv i32 %56, %54
  %58 = urem i32 %1, %57
  %59 = mul i32 %58, %54
  %60 = getelementptr inbounds i8, ptr %0, i64 372
  store i32 %59, ptr %60, align 4, !tbaa !33
  %61 = load i32, ptr %5, align 8, !tbaa !5
  %62 = and i32 %61, 32
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %71

64:                                               ; preds = %40
  %65 = getelementptr inbounds i8, ptr %0, i64 408
  %66 = load ptr, ptr %65, align 8, !tbaa !34
  %67 = tail call i32 %66(ptr noundef nonnull %0) #3
  %.not84 = icmp eq i32 %67, 0
  br i1 %.not84, label %110, label %68

68:                                               ; preds = %64
  %69 = load i32, ptr %5, align 8, !tbaa !5
  %70 = or i32 %69, 32
  br label %71

71:                                               ; preds = %68, %40
  %72 = phi i32 [ %70, %68 ], [ %61, %40 ]
  %73 = and i32 %72, -4097
  store i32 %73, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %0, i64 216
  %75 = load i32, ptr %74, align 8, !tbaa !35
  %76 = udiv i32 %1, %75
  %77 = trunc i32 %76 to i16
  %78 = getelementptr inbounds i8, ptr %0, i64 424
  %79 = load ptr, ptr %78, align 8, !tbaa !36
  %80 = tail call i32 %79(ptr noundef nonnull %0, i16 noundef zeroext %77) #3
  %.not85 = icmp eq i32 %80, 0
  br i1 %.not85, label %110, label %._crit_edge91

._crit_edge91:                                    ; preds = %71
  %81 = icmp slt i32 %3, 1
  %.phi.trans.insert92 = getelementptr inbounds i8, ptr %0, i64 380
  %.pre93 = load i32, ptr %.phi.trans.insert92, align 4, !tbaa !37
  %spec.select = tail call i32 @llvm.smin.i32(i32 %.pre93, i32 %3)
  %.073 = select i1 %81, i32 %.pre93, i32 %spec.select
  %82 = getelementptr inbounds i8, ptr %0, i64 656
  %83 = load ptr, ptr %82, align 8, !tbaa !38
  tail call void %83(ptr noundef nonnull %0, ptr noundef %2, i32 noundef %.073) #3
  %84 = getelementptr inbounds i8, ptr %0, i64 480
  %85 = load ptr, ptr %84, align 8, !tbaa !39
  %86 = tail call i32 %85(ptr noundef nonnull %0, ptr noundef %2, i32 noundef %.073, i16 noundef zeroext %77) #3
  %.not86 = icmp eq i32 %86, 0
  br i1 %.not86, label %110, label %87

87:                                               ; preds = %._crit_edge91
  %88 = getelementptr inbounds i8, ptr %0, i64 432
  %89 = load ptr, ptr %88, align 8, !tbaa !40
  %90 = tail call i32 %89(ptr noundef nonnull %0) #3
  %.not87 = icmp eq i32 %90, 0
  br i1 %.not87, label %110, label %91

91:                                               ; preds = %87
  %92 = load i32, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds i8, ptr %0, i64 118
  %94 = load i16, ptr %93, align 2, !tbaa !41
  %95 = or i16 %94, 256
  %96 = zext i16 %95 to i32
  %97 = and i32 %92, %96
  %or.cond = icmp eq i32 %97, 0
  br i1 %or.cond, label %98, label %102

98:                                               ; preds = %91
  %99 = load ptr, ptr %31, align 8, !tbaa !21
  %100 = load i32, ptr %30, align 8, !tbaa !23
  %101 = sext i32 %100 to i64
  tail call void @TIFFReverseBits(ptr noundef %99, i64 noundef %101) #3
  br label %102

102:                                              ; preds = %98, %91
  %103 = load i32, ptr %30, align 8, !tbaa !23
  %104 = icmp sgt i32 %103, 0
  br i1 %104, label %105, label %108

105:                                              ; preds = %102
  %106 = load ptr, ptr %31, align 8, !tbaa !21
  %107 = tail call i32 @TIFFAppendToStrip(ptr noundef nonnull %0, i32 noundef %1, ptr noundef %106, i32 noundef %103)
  %.not89 = icmp eq i32 %107, 0
  br i1 %.not89, label %110, label %108

108:                                              ; preds = %105, %102
  store i32 0, ptr %30, align 8, !tbaa !23
  %109 = load ptr, ptr %31, align 8, !tbaa !21
  store ptr %109, ptr %32, align 8, !tbaa !24
  br label %110

110:                                              ; preds = %105, %87, %._crit_edge91, %71, %64, %25, %8, %108, %13
  %.0 = phi i32 [ -1, %13 ], [ %.073, %108 ], [ -1, %8 ], [ -1, %25 ], [ -1, %64 ], [ -1, %71 ], [ 0, %._crit_edge91 ], [ -1, %87 ], [ -1, %105 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"tiff", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 32, !11, i64 40, !12, i64 48, !15, i64 320, !7, i64 328, !7, i64 336, !10, i64 344, !11, i64 348, !10, i64 352, !10, i64 356, !10, i64 360, !11, i64 364, !10, i64 368, !10, i64 372, !10, i64 376, !10, i64 380, !10, i64 384, !7, i64 392, !7, i64 400, !7, i64 408, !10, i64 416, !7, i64 424, !7, i64 432, !7, i64 440, !7, i64 448, !7, i64 456, !7, i64 464, !7, i64 472, !7, i64 480, !7, i64 488, !7, i64 496, !7, i64 504, !7, i64 512, !7, i64 520, !7, i64 528, !10, i64 536, !10, i64 540, !7, i64 544, !10, i64 552, !7, i64 560, !10, i64 568, !7, i64 576, !10, i64 584, !7, i64 592, !7, i64 600, !7, i64 608, !7, i64 616, !7, i64 624, !7, i64 632, !7, i64 640, !7, i64 648, !7, i64 656, !7, i64 664, !16, i64 672, !7, i64 680, !17, i64 688, !7, i64 712}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"", !8, i64 0, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !11, i64 60, !11, i64 62, !11, i64 64, !11, i64 66, !11, i64 68, !11, i64 70, !11, i64 72, !11, i64 74, !10, i64 76, !11, i64 80, !11, i64 82, !13, i64 88, !13, i64 96, !14, i64 104, !14, i64 108, !11, i64 112, !11, i64 114, !14, i64 116, !14, i64 120, !8, i64 124, !8, i64 128, !8, i64 152, !11, i64 156, !7, i64 160, !10, i64 168, !10, i64 172, !7, i64 176, !7, i64 184, !10, i64 192, !11, i64 196, !7, i64 200, !8, i64 208, !11, i64 212, !8, i64 216, !10, i64 240, !7, i64 248, !10, i64 256, !7, i64 264}
!13 = !{!"double", !8, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!"", !11, i64 0, !11, i64 2, !10, i64 4}
!16 = !{!"long", !8, i64 0}
!17 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!18 = !{!12, !10, i64 172}
!19 = !{!6, !7, i64 608}
!20 = !{!6, !7, i64 0}
!21 = !{!6, !7, i64 544}
!22 = !{!6, !10, i64 376}
!23 = !{!6, !10, i64 568}
!24 = !{!6, !7, i64 560}
!25 = !{!12, !7, i64 184}
!26 = !{!10, !10, i64 0}
!27 = !{!6, !10, i64 356}
!28 = !{!12, !10, i64 36}
!29 = !{!12, !10, i64 48}
!30 = !{!6, !10, i64 344}
!31 = !{!12, !10, i64 32}
!32 = !{!12, !10, i64 44}
!33 = !{!6, !10, i64 372}
!34 = !{!6, !7, i64 408}
!35 = !{!12, !10, i64 168}
!36 = !{!6, !7, i64 424}
!37 = !{!6, !10, i64 380}
!38 = !{!6, !7, i64 656}
!39 = !{!6, !7, i64 480}
!40 = !{!6, !7, i64 432}
!41 = !{!12, !11, i64 70}


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