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

; 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._TIFFRGBAImage = type { ptr, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, ptr, ptr, ptr, ptr, %union.anon, ptr, ptr, ptr, ptr, ptr, i32, i32 }
%union.anon = type { ptr }
%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 }

@.str.23 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [71 x i8], align 1

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

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

declare i32 @TIFFGetFieldDefaulted(ptr noundef, i32 noundef, ...) #2

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

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

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

declare i32 @TIFFIsTiled(ptr noundef) #2

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

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

declare ptr @TIFFFileName(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @TIFFReadRGBATile(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca [1024 x i8], align 16
  %11 = alloca %struct._TIFFRGBAImage, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %10) #5
  call void @llvm.memset.p0.i64(ptr align 16 %10, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 128, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call i32 @TIFFIsTiled(ptr noundef %19)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %28, label %22

22:                                               ; preds = %4
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.tiff, ptr %23, i32 0, i32 51
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call ptr @TIFFFileName(ptr noundef %26)
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %25, ptr noundef %27, ptr noundef @.str.23)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %184

28:                                               ; preds = %4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call i32 (ptr, i32, ...) @TIFFGetFieldDefaulted(ptr noundef %29, i32 noundef 322, ptr noundef %13)
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call i32 (ptr, i32, ...) @TIFFGetFieldDefaulted(ptr noundef %31, i32 noundef 323, ptr noundef %14)
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = load i32, ptr %13, align 4, !tbaa !9
  %35 = urem i32 %33, %34
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %42, label %37

37:                                               ; preds = %28
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load i32, ptr %14, align 4, !tbaa !9
  %40 = urem i32 %38, %39
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %48

42:                                               ; preds = %37, %28
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tiff, ptr %43, i32 0, i32 51
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = call ptr @TIFFFileName(ptr noundef %46)
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %45, ptr noundef %47, ptr noundef @.str.24)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %184

48:                                               ; preds = %37
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds [1024 x i8], ptr %10, i64 0, i64 0
  %51 = call i32 @TIFFRGBAImageOK(ptr noundef %49, ptr noundef %50)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %58

53:                                               ; preds = %48
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds [1024 x i8], ptr %10, i64 0, i64 0
  %56 = call i32 @TIFFRGBAImageBegin(ptr noundef %11, ptr noundef %54, i32 noundef 0, ptr noundef %55)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %65, label %58

58:                                               ; preds = %53, %48
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.tiff, ptr %59, i32 0, i32 51
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = call ptr @TIFFFileName(ptr noundef %62)
  %64 = getelementptr inbounds [1024 x i8], ptr %10, i64 0, i64 0
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %61, ptr noundef %63, ptr noundef %64)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %184

65:                                               ; preds = %53
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = load i32, ptr %14, align 4, !tbaa !9
  %68 = add i32 %66, %67
  %69 = getelementptr inbounds %struct._TIFFRGBAImage, ptr %11, i32 0, i32 5
  %70 = load i32, ptr %69, align 8, !tbaa !20
  %71 = icmp ugt i32 %68, %70
  br i1 %71, label %72, label %77

72:                                               ; preds = %65
  %73 = getelementptr inbounds %struct._TIFFRGBAImage, ptr %11, i32 0, i32 5
  %74 = load i32, ptr %73, align 8, !tbaa !20
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = sub i32 %74, %75
  store i32 %76, ptr %16, align 4, !tbaa !9
  br label %79

77:                                               ; preds = %65
  %78 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %78, ptr %16, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %77, %72
  %80 = load i32, ptr %7, align 4, !tbaa !9
  %81 = load i32, ptr %13, align 4, !tbaa !9
  %82 = add i32 %80, %81
  %83 = getelementptr inbounds %struct._TIFFRGBAImage, ptr %11, i32 0, i32 4
  %84 = load i32, ptr %83, align 4, !tbaa !22
  %85 = icmp ugt i32 %82, %84
  br i1 %85, label %86, label %91

86:                                               ; preds = %79
  %87 = getelementptr inbounds %struct._TIFFRGBAImage, ptr %11, i32 0, i32 4
  %88 = load i32, ptr %87, align 4, !tbaa !22
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = sub i32 %88, %89
  store i32 %90, ptr %15, align 4, !tbaa !9
  br label %93

91:                                               ; preds = %79
  %92 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %92, ptr %15, align 4, !tbaa !9
  br label %93

93:                                               ; preds = %91, %86
  %94 = load i32, ptr %8, align 4, !tbaa !9
  %95 = getelementptr inbounds %struct._TIFFRGBAImage, ptr %11, i32 0, i32 21
  store i32 %94, ptr %95, align 8, !tbaa !23
  %96 = load i32, ptr %7, align 4, !tbaa !9
  %97 = getelementptr inbounds %struct._TIFFRGBAImage, ptr %11, i32 0, i32 22
  store i32 %96, ptr %97, align 4, !tbaa !24
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = load i32, ptr %15, align 4, !tbaa !9
  %100 = load i32, ptr %16, align 4, !tbaa !9
  %101 = call i32 @TIFFRGBAImageGet(ptr noundef %11, ptr noundef %98, i32 noundef %99, i32 noundef %100)
  store i32 %101, ptr %12, align 4, !tbaa !9
  call void @TIFFRGBAImageEnd(ptr noundef %11)
  %102 = load i32, ptr %15, align 4, !tbaa !9
  %103 = load i32, ptr %13, align 4, !tbaa !9
  %104 = icmp eq i32 %102, %103
  br i1 %104, label %105, label %111

105:                                              ; preds = %93
  %106 = load i32, ptr %16, align 4, !tbaa !9
  %107 = load i32, ptr %14, align 4, !tbaa !9
  %108 = icmp eq i32 %106, %107
  br i1 %108, label %109, label %111

109:                                              ; preds = %105
  %110 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %110, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %184

111:                                              ; preds = %105, %93
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %112

112:                                              ; preds = %156, %111
  %113 = load i32, ptr %17, align 4, !tbaa !9
  %114 = load i32, ptr %16, align 4, !tbaa !9
  %115 = icmp ult i32 %113, %114
  br i1 %115, label %116, label %159

116:                                              ; preds = %112
  %117 = load ptr, ptr %9, align 8, !tbaa !5
  %118 = load i32, ptr %14, align 4, !tbaa !9
  %119 = load i32, ptr %17, align 4, !tbaa !9
  %120 = sub i32 %118, %119
  %121 = sub i32 %120, 1
  %122 = load i32, ptr %13, align 4, !tbaa !9
  %123 = mul i32 %121, %122
  %124 = zext i32 %123 to i64
  %125 = getelementptr inbounds i32, ptr %117, i64 %124
  %126 = load ptr, ptr %9, align 8, !tbaa !5
  %127 = load i32, ptr %16, align 4, !tbaa !9
  %128 = load i32, ptr %17, align 4, !tbaa !9
  %129 = sub i32 %127, %128
  %130 = sub i32 %129, 1
  %131 = load i32, ptr %15, align 4, !tbaa !9
  %132 = mul i32 %130, %131
  %133 = zext i32 %132 to i64
  %134 = getelementptr inbounds i32, ptr %126, i64 %133
  %135 = load i32, ptr %15, align 4, !tbaa !9
  %136 = zext i32 %135 to i64
  %137 = mul i64 %136, 4
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %125, ptr align 4 %134, i64 %137, i1 false)
  %138 = load ptr, ptr %9, align 8, !tbaa !5
  %139 = load i32, ptr %14, align 4, !tbaa !9
  %140 = load i32, ptr %17, align 4, !tbaa !9
  %141 = sub i32 %139, %140
  %142 = sub i32 %141, 1
  %143 = load i32, ptr %13, align 4, !tbaa !9
  %144 = mul i32 %142, %143
  %145 = zext i32 %144 to i64
  %146 = getelementptr inbounds i32, ptr %138, i64 %145
  %147 = load i32, ptr %15, align 4, !tbaa !9
  %148 = zext i32 %147 to i64
  %149 = getelementptr inbounds i32, ptr %146, i64 %148
  %150 = load i32, ptr %13, align 4, !tbaa !9
  %151 = load i32, ptr %15, align 4, !tbaa !9
  %152 = sub i32 %150, %151
  %153 = zext i32 %152 to i64
  %154 = mul i64 4, %153
  %155 = trunc i64 %154 to i32
  call void @_TIFFmemset(ptr noundef %149, i32 noundef 0, i32 noundef %155)
  br label %156

156:                                              ; preds = %116
  %157 = load i32, ptr %17, align 4, !tbaa !9
  %158 = add i32 %157, 1
  store i32 %158, ptr %17, align 4, !tbaa !9
  br label %112, !llvm.loop !25

159:                                              ; preds = %112
  %160 = load i32, ptr %16, align 4, !tbaa !9
  store i32 %160, ptr %17, align 4, !tbaa !9
  br label %161

161:                                              ; preds = %179, %159
  %162 = load i32, ptr %17, align 4, !tbaa !9
  %163 = load i32, ptr %14, align 4, !tbaa !9
  %164 = icmp ult i32 %162, %163
  br i1 %164, label %165, label %182

165:                                              ; preds = %161
  %166 = load ptr, ptr %9, align 8, !tbaa !5
  %167 = load i32, ptr %14, align 4, !tbaa !9
  %168 = load i32, ptr %17, align 4, !tbaa !9
  %169 = sub i32 %167, %168
  %170 = sub i32 %169, 1
  %171 = load i32, ptr %13, align 4, !tbaa !9
  %172 = mul i32 %170, %171
  %173 = zext i32 %172 to i64
  %174 = getelementptr inbounds i32, ptr %166, i64 %173
  %175 = load i32, ptr %13, align 4, !tbaa !9
  %176 = zext i32 %175 to i64
  %177 = mul i64 4, %176
  %178 = trunc i64 %177 to i32
  call void @_TIFFmemset(ptr noundef %174, i32 noundef 0, i32 noundef %178)
  br label %179

179:                                              ; preds = %165
  %180 = load i32, ptr %17, align 4, !tbaa !9
  %181 = add i32 %180, 1
  store i32 %181, ptr %17, align 4, !tbaa !9
  br label %161, !llvm.loop !27

182:                                              ; preds = %161
  %183 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %183, ptr %5, align 4
  store i32 1, ptr %18, align 4
  br label %184

184:                                              ; preds = %182, %109, %58, %42, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %10) #5
  %185 = load i32, ptr %5, align 4
  ret i32 %185
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #4

declare void @_TIFFmemset(ptr noundef, i32 noundef, i32 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 608}
!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 = !{!21, !10, i64 24}
!21 = !{!"_TIFFRGBAImage", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !13, i64 28, !13, i64 30, !13, i64 32, !13, i64 34, !13, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !7, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !10, i64 120, !10, i64 124}
!22 = !{!21, !10, i64 20}
!23 = !{!21, !10, i64 120}
!24 = !{!21, !10, i64 124}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !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"

%struct._TIFFRGBAImage = type { ptr, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, ptr, ptr, ptr, ptr, %union.anon, ptr, ptr, ptr, ptr, ptr, i32, i32 }
%union.anon = type { ptr }

@.str.23 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [71 x i8], align 1

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

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

declare i32 @TIFFGetFieldDefaulted(ptr noundef, i32 noundef, ...) local_unnamed_addr #2

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

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

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

declare i32 @TIFFIsTiled(ptr noundef) local_unnamed_addr #2

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

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

declare ptr @TIFFFileName(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @TIFFReadRGBATile(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca [1024 x i8], align 16
  %6 = alloca %struct._TIFFRGBAImage, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %5) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1024) %5, i8 0, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #5
  %9 = tail call i32 @TIFFIsTiled(ptr noundef %0) #5
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %14

10:                                               ; preds = %4
  %11 = getelementptr inbounds i8, ptr %0, i64 608
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = tail call ptr @TIFFFileName(ptr noundef %0) #5
  tail call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %12, ptr noundef %13, ptr noundef nonnull @.str.23) #5
  br label %.loopexit

14:                                               ; preds = %4
  %15 = call i32 (ptr, i32, ...) @TIFFGetFieldDefaulted(ptr noundef %0, i32 noundef 322, ptr noundef nonnull %7) #5
  %16 = call i32 (ptr, i32, ...) @TIFFGetFieldDefaulted(ptr noundef %0, i32 noundef 323, ptr noundef nonnull %8) #5
  %17 = load i32, ptr %7, align 4, !tbaa !18
  %18 = urem i32 %1, %17
  %.not51 = icmp eq i32 %18, 0
  br i1 %.not51, label %19, label %22

19:                                               ; preds = %14
  %20 = load i32, ptr %8, align 4, !tbaa !18
  %21 = urem i32 %2, %20
  %.not52 = icmp eq i32 %21, 0
  br i1 %.not52, label %26, label %22

22:                                               ; preds = %19, %14
  %23 = getelementptr inbounds i8, ptr %0, i64 608
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = call ptr @TIFFFileName(ptr noundef %0) #5
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %24, ptr noundef %25, ptr noundef nonnull @.str.24) #5
  br label %.loopexit

26:                                               ; preds = %19
  %27 = call i32 @TIFFRGBAImageOK(ptr noundef %0, ptr noundef nonnull %5)
  %.not53 = icmp eq i32 %27, 0
  br i1 %.not53, label %30, label %28

28:                                               ; preds = %26
  %29 = call i32 @TIFFRGBAImageBegin(ptr noundef nonnull %6, ptr noundef %0, i32 noundef 0, ptr noundef nonnull %5)
  %.not54 = icmp eq i32 %29, 0
  br i1 %.not54, label %30, label %34

30:                                               ; preds = %28, %26
  %31 = getelementptr inbounds i8, ptr %0, i64 608
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = call ptr @TIFFFileName(ptr noundef %0) #5
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %32, ptr noundef %33, ptr noundef nonnull %5) #5
  br label %.loopexit

34:                                               ; preds = %28
  %35 = load i32, ptr %8, align 4, !tbaa !18
  %36 = add i32 %35, %2
  %37 = getelementptr inbounds i8, ptr %6, i64 24
  %38 = load i32, ptr %37, align 8, !tbaa !19
  %39 = icmp ugt i32 %36, %38
  %40 = sub i32 %38, %2
  %.045 = select i1 %39, i32 %40, i32 %35
  %41 = load i32, ptr %7, align 4, !tbaa !18
  %42 = add i32 %41, %1
  %43 = getelementptr inbounds i8, ptr %6, i64 20
  %44 = load i32, ptr %43, align 4, !tbaa !21
  %45 = icmp ugt i32 %42, %44
  %46 = sub i32 %44, %1
  %.046 = select i1 %45, i32 %46, i32 %41
  %47 = getelementptr inbounds i8, ptr %6, i64 120
  store i32 %2, ptr %47, align 8, !tbaa !22
  %48 = getelementptr inbounds i8, ptr %6, i64 124
  store i32 %1, ptr %48, align 4, !tbaa !23
  %49 = call i32 @TIFFRGBAImageGet(ptr noundef nonnull %6, ptr noundef %3, i32 noundef %.046, i32 noundef %.045)
  call void @TIFFRGBAImageEnd(ptr noundef nonnull %6)
  %50 = load i32, ptr %7, align 4, !tbaa !18
  %51 = icmp eq i32 %.046, %50
  %52 = load i32, ptr %8, align 4
  %53 = icmp eq i32 %.045, %52
  %or.cond = select i1 %51, i1 %53, i1 false
  br i1 %or.cond, label %.loopexit, label %.preheader56

.preheader56:                                     ; preds = %34
  %.not60 = icmp eq i32 %.045, 0
  br i1 %.not60, label %.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader56
  %54 = zext i32 %.046 to i64
  %55 = shl nuw nsw i64 %54, 2
  %56 = zext i32 %.045 to i64
  br label %59

.preheader.loopexit:                              ; preds = %59
  %.pre = load i32, ptr %8, align 4, !tbaa !18
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.preheader56
  %57 = phi i32 [ %.pre, %.preheader.loopexit ], [ %52, %.preheader56 ]
  %58 = icmp ult i32 %.045, %57
  br i1 %58, label %.lr.ph59, label %.loopexit

59:                                               ; preds = %.lr.ph, %59
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %59 ]
  %60 = load i32, ptr %8, align 4, !tbaa !18
  %61 = trunc nuw i64 %indvars.iv to i32
  %62 = xor i32 %61, -1
  %63 = add i32 %60, %62
  %64 = load i32, ptr %7, align 4, !tbaa !18
  %65 = mul i32 %63, %64
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds i32, ptr %3, i64 %66
  %68 = add i32 %.045, %62
  %69 = mul i32 %68, %.046
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds i32, ptr %3, i64 %70
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %67, ptr align 4 %71, i64 %55, i1 false)
  %72 = getelementptr inbounds i32, ptr %67, i64 %54
  %73 = sub i32 %64, %.046
  %74 = shl i32 %73, 2
  call void @_TIFFmemset(ptr noundef %72, i32 noundef 0, i32 noundef %74) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %75 = icmp ult i64 %indvars.iv.next, %56
  br i1 %75, label %59, label %.preheader.loopexit, !llvm.loop !24

.lr.ph59:                                         ; preds = %.preheader, %.lr.ph59
  %76 = phi i32 [ %85, %.lr.ph59 ], [ %57, %.preheader ]
  %.158 = phi i32 [ %84, %.lr.ph59 ], [ %.045, %.preheader ]
  %77 = xor i32 %.158, -1
  %78 = add i32 %76, %77
  %79 = load i32, ptr %7, align 4, !tbaa !18
  %80 = mul i32 %79, %78
  %81 = zext i32 %80 to i64
  %82 = getelementptr inbounds i32, ptr %3, i64 %81
  %83 = shl i32 %79, 2
  call void @_TIFFmemset(ptr noundef %82, i32 noundef 0, i32 noundef %83) #5
  %84 = add nuw i32 %.158, 1
  %85 = load i32, ptr %8, align 4, !tbaa !18
  %86 = icmp ult i32 %84, %85
  br i1 %86, label %.lr.ph59, label %.loopexit, !llvm.loop !26

.loopexit:                                        ; preds = %.lr.ph59, %.preheader, %34, %30, %22, %10
  %.047 = phi i32 [ 0, %22 ], [ 0, %30 ], [ 0, %10 ], [ %49, %34 ], [ %49, %.preheader ], [ %49, %.lr.ph59 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %5) #5
  ret i32 %.047
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #4

declare void @_TIFFmemset(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 608}
!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 = !{!10, !10, i64 0}
!19 = !{!20, !10, i64 24}
!20 = !{!"_TIFFRGBAImage", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !11, i64 28, !11, i64 30, !11, i64 32, !11, i64 34, !11, i64 36, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !8, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !10, i64 120, !10, i64 124}
!21 = !{!20, !10, i64 20}
!22 = !{!20, !10, i64 120}
!23 = !{!20, !10, i64 124}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}


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