; 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.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 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@photoTag = external hidden constant [26 x i8], align 16
@.str.3 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 x i8], align 1

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

17:                                               ; preds = %2
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %18, ptr noundef @.str) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

20:                                               ; preds = %2
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.TIFFDirectory, ptr %21, i32 0, i32 8
  %23 = load i16, ptr %22, align 4, !tbaa !19
  %24 = zext i16 %23 to i32
  switch i32 %24, label %26 [
    i32 1, label %25
    i32 2, label %25
    i32 4, label %25
    i32 8, label %25
    i32 16, label %25
  ]

25:                                               ; preds = %20, %20, %20, %20, %20
  br label %33

26:                                               ; preds = %20
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.TIFFDirectory, ptr %28, i32 0, i32 8
  %30 = load i16, ptr %29, align 4, !tbaa !19
  %31 = zext i16 %30 to i32
  %32 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %27, ptr noundef @.str.1, i32 noundef %31) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

33:                                               ; preds = %25
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.TIFFDirectory, ptr %34, i32 0, i32 15
  %36 = load i16, ptr %35, align 2, !tbaa !20
  %37 = zext i16 %36 to i32
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TIFFDirectory, ptr %38, i32 0, i32 30
  %40 = load i16, ptr %39, align 4, !tbaa !21
  %41 = zext i16 %40 to i32
  %42 = sub nsw i32 %37, %41
  store i32 %42, ptr %8, align 4, !tbaa !22
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call i32 (ptr, i32, ...) @TIFFGetField(ptr noundef %43, i32 noundef 262, ptr noundef %7)
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %54, label %46

46:                                               ; preds = %33
  %47 = load i32, ptr %8, align 4, !tbaa !22
  switch i32 %47, label %50 [
    i32 1, label %48
    i32 3, label %49
  ]

48:                                               ; preds = %46
  store i16 1, ptr %7, align 2, !tbaa !23
  br label %53

49:                                               ; preds = %46
  store i16 2, ptr %7, align 2, !tbaa !23
  br label %53

50:                                               ; preds = %46
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %51, ptr noundef @.str.2, ptr noundef @photoTag) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

53:                                               ; preds = %49, %48
  br label %54

54:                                               ; preds = %53, %33
  %55 = load i16, ptr %7, align 2, !tbaa !23
  %56 = zext i16 %55 to i32
  switch i32 %56, label %177 [
    i32 0, label %57
    i32 1, label %57
    i32 3, label %57
    i32 6, label %89
    i32 2, label %103
    i32 5, label %111
    i32 32844, label %138
    i32 32845, label %148
    i32 8, label %182
  ]

57:                                               ; preds = %54, %54, %54
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.TIFFDirectory, ptr %58, i32 0, i32 24
  %60 = load i16, ptr %59, align 2, !tbaa !24
  %61 = zext i16 %60 to i32
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %88

63:                                               ; preds = %57
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.TIFFDirectory, ptr %64, i32 0, i32 15
  %66 = load i16, ptr %65, align 2, !tbaa !20
  %67 = zext i16 %66 to i32
  %68 = icmp ne i32 %67, 1
  br i1 %68, label %69, label %88

69:                                               ; preds = %63
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.TIFFDirectory, ptr %70, i32 0, i32 8
  %72 = load i16, ptr %71, align 4, !tbaa !19
  %73 = zext i16 %72 to i32
  %74 = icmp slt i32 %73, 8
  br i1 %74, label %75, label %88

75:                                               ; preds = %69
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = load i16, ptr %7, align 2, !tbaa !23
  %78 = zext i16 %77 to i32
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.TIFFDirectory, ptr %79, i32 0, i32 15
  %81 = load i16, ptr %80, align 2, !tbaa !20
  %82 = zext i16 %81 to i32
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.TIFFDirectory, ptr %83, i32 0, i32 8
  %85 = load i16, ptr %84, align 4, !tbaa !19
  %86 = zext i16 %85 to i32
  %87 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %76, ptr noundef @.str.3, ptr noundef @photoTag, i32 noundef %78, ptr noundef @.str.4, i32 noundef %82, i32 noundef %86) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

88:                                               ; preds = %69, %63, %57
  br label %182

89:                                               ; preds = %54
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.TIFFDirectory, ptr %90, i32 0, i32 24
  %92 = load i16, ptr %91, align 2, !tbaa !24
  %93 = zext i16 %92 to i32
  %94 = icmp ne i32 %93, 1
  br i1 %94, label %95, label %102

95:                                               ; preds = %89
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.TIFFDirectory, ptr %97, i32 0, i32 24
  %99 = load i16, ptr %98, align 2, !tbaa !24
  %100 = zext i16 %99 to i32
  %101 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %96, ptr noundef @.str.5, ptr noundef @.str.6, i32 noundef %100) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

102:                                              ; preds = %89
  br label %182

103:                                              ; preds = %54
  %104 = load i32, ptr %8, align 4, !tbaa !22
  %105 = icmp slt i32 %104, 3
  br i1 %105, label %106, label %110

106:                                              ; preds = %103
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = load i32, ptr %8, align 4, !tbaa !22
  %109 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %107, ptr noundef @.str.7, ptr noundef @.str.8, i32 noundef %108) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

110:                                              ; preds = %103
  br label %182

111:                                              ; preds = %54
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #4
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = call i32 (ptr, i32, ...) @TIFFGetFieldDefaulted(ptr noundef %112, i32 noundef 332, ptr noundef %10)
  %114 = load i16, ptr %10, align 2, !tbaa !23
  %115 = zext i16 %114 to i32
  %116 = icmp ne i32 %115, 1
  br i1 %116, label %117, label %122

117:                                              ; preds = %111
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = load i16, ptr %10, align 2, !tbaa !23
  %120 = zext i16 %119 to i32
  %121 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %118, ptr noundef @.str.9, ptr noundef @.str.10, i32 noundef %120) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %136

122:                                              ; preds = %111
  %123 = load ptr, ptr %6, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.TIFFDirectory, ptr %123, i32 0, i32 15
  %125 = load i16, ptr %124, align 2, !tbaa !20
  %126 = zext i16 %125 to i32
  %127 = icmp slt i32 %126, 4
  br i1 %127, label %128, label %135

128:                                              ; preds = %122
  %129 = load ptr, ptr %5, align 8, !tbaa !5
  %130 = load ptr, ptr %6, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.TIFFDirectory, ptr %130, i32 0, i32 15
  %132 = load i16, ptr %131, align 2, !tbaa !20
  %133 = zext i16 %132 to i32
  %134 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %129, ptr noundef @.str.9, ptr noundef @.str.4, i32 noundef %133) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %136

135:                                              ; preds = %122
  store i32 4, ptr %9, align 4
  br label %136

136:                                              ; preds = %135, %128, %117
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #4
  %137 = load i32, ptr %9, align 4
  switch i32 %137, label %183 [
    i32 4, label %182
  ]

138:                                              ; preds = %54
  %139 = load ptr, ptr %6, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.TIFFDirectory, ptr %139, i32 0, i32 10
  %141 = load i16, ptr %140, align 8, !tbaa !25
  %142 = zext i16 %141 to i32
  %143 = icmp ne i32 %142, 34676
  br i1 %143, label %144, label %147

144:                                              ; preds = %138
  %145 = load ptr, ptr %5, align 8, !tbaa !5
  %146 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %145, ptr noundef @.str.11, ptr noundef @.str.12, i32 noundef 34676) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

147:                                              ; preds = %138
  br label %182

148:                                              ; preds = %54
  %149 = load ptr, ptr %6, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.TIFFDirectory, ptr %149, i32 0, i32 10
  %151 = load i16, ptr %150, align 8, !tbaa !25
  %152 = zext i16 %151 to i32
  %153 = icmp ne i32 %152, 34676
  br i1 %153, label %154, label %163

154:                                              ; preds = %148
  %155 = load ptr, ptr %6, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.TIFFDirectory, ptr %155, i32 0, i32 10
  %157 = load i16, ptr %156, align 8, !tbaa !25
  %158 = zext i16 %157 to i32
  %159 = icmp ne i32 %158, 34677
  br i1 %159, label %160, label %163

160:                                              ; preds = %154
  %161 = load ptr, ptr %5, align 8, !tbaa !5
  %162 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %161, ptr noundef @.str.13, ptr noundef @.str.12, i32 noundef 34676, i32 noundef 34677) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

163:                                              ; preds = %154, %148
  %164 = load ptr, ptr %6, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.TIFFDirectory, ptr %164, i32 0, i32 24
  %166 = load i16, ptr %165, align 2, !tbaa !24
  %167 = zext i16 %166 to i32
  %168 = icmp ne i32 %167, 1
  br i1 %168, label %169, label %176

169:                                              ; preds = %163
  %170 = load ptr, ptr %5, align 8, !tbaa !5
  %171 = load ptr, ptr %6, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.TIFFDirectory, ptr %171, i32 0, i32 24
  %173 = load i16, ptr %172, align 2, !tbaa !24
  %174 = zext i16 %173 to i32
  %175 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %170, ptr noundef @.str.14, ptr noundef @.str.6, i32 noundef %174) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

176:                                              ; preds = %163
  br label %182

177:                                              ; preds = %54
  %178 = load ptr, ptr %5, align 8, !tbaa !5
  %179 = load i16, ptr %7, align 2, !tbaa !23
  %180 = zext i16 %179 to i32
  %181 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %178, ptr noundef @.str.15, ptr noundef @photoTag, i32 noundef %180) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

182:                                              ; preds = %176, %147, %136, %110, %102, %88, %54
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %183

183:                                              ; preds = %182, %177, %169, %160, %144, %136, %106, %95, %75, %50, %26, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %184 = load i32, ptr %3, align 4
  ret i32 %184
}

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

declare i32 @TIFFGetField(ptr noundef, i32 noundef, ...) #3

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

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

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 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 384}
!10 = !{!"tiff", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !12, i64 40, !13, i64 48, !16, i64 320, !6, i64 328, !6, i64 336, !11, i64 344, !12, i64 348, !11, i64 352, !11, i64 356, !11, i64 360, !12, i64 364, !11, i64 368, !11, i64 372, !11, i64 376, !11, i64 380, !11, i64 384, !6, i64 392, !6, i64 400, !6, i64 408, !11, 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, !11, i64 536, !11, i64 540, !6, i64 544, !11, i64 552, !6, i64 560, !11, i64 568, !6, i64 576, !11, 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, !17, i64 672, !6, i64 680, !18, i64 688, !6, i64 712}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"", !7, i64 0, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !12, i64 60, !12, i64 62, !12, i64 64, !12, i64 66, !12, i64 68, !12, i64 70, !12, i64 72, !12, i64 74, !11, i64 76, !12, i64 80, !12, i64 82, !14, i64 88, !14, i64 96, !15, i64 104, !15, i64 108, !12, i64 112, !12, i64 114, !15, i64 116, !15, i64 120, !7, i64 124, !7, i64 128, !7, i64 152, !12, i64 156, !6, i64 160, !11, i64 168, !11, i64 172, !6, i64 176, !6, i64 184, !11, i64 192, !12, i64 196, !6, i64 200, !7, i64 208, !12, i64 212, !7, i64 216, !11, i64 240, !6, i64 248, !11, i64 256, !6, i64 264}
!14 = !{!"double", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!"", !12, i64 0, !12, i64 2, !11, i64 4}
!17 = !{!"long", !7, i64 0}
!18 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!13, !12, i64 60}
!20 = !{!13, !12, i64 74}
!21 = !{!13, !12, i64 156}
!22 = !{!11, !11, i64 0}
!23 = !{!12, !12, i64 0}
!24 = !{!13, !12, i64 114}
!25 = !{!13, !12, i64 64}


; 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 [54 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [22 x i8], align 1
@photoTag = external hidden constant [26 x i8], align 16
@.str.3 = external hidden unnamed_addr constant [79 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @TIFFRGBAImageOK(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = alloca i16, align 2
  %4 = alloca i16, align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 384
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %9

7:                                                ; preds = %2
  %8 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str) #4
  br label %.thread56

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 108
  %11 = load i16, ptr %10, align 4, !tbaa !18
  switch i16 %11, label %12 [
    i16 1, label %15
    i16 2, label %15
    i16 4, label %15
    i16 8, label %15
    i16 16, label %15
  ]

12:                                               ; preds = %9
  %13 = zext i16 %11 to i32
  %14 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %13) #4
  br label %.thread56

15:                                               ; preds = %9, %9, %9, %9, %9
  %16 = getelementptr inbounds i8, ptr %0, i64 122
  %17 = load i16, ptr %16, align 2, !tbaa !19
  %18 = zext i16 %17 to i32
  %19 = getelementptr inbounds i8, ptr %0, i64 204
  %20 = load i16, ptr %19, align 4, !tbaa !20
  %21 = zext i16 %20 to i32
  %22 = sub nsw i32 %18, %21
  %23 = call i32 (ptr, i32, ...) @TIFFGetField(ptr noundef nonnull %0, i32 noundef 262, ptr noundef nonnull %3) #4
  %.not47 = icmp eq i32 %23, 0
  br i1 %.not47, label %24, label %27

24:                                               ; preds = %15
  switch i32 %22, label %25 [
    i32 1, label %.thread
    i32 3, label %.thread56
  ]

.thread:                                          ; preds = %24
  store i16 1, ptr %3, align 2, !tbaa !21
  br label %28

25:                                               ; preds = %24
  %26 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull @photoTag) #4
  br label %.thread56

27:                                               ; preds = %15
  %.pr = load i16, ptr %3, align 2, !tbaa !21
  switch i16 %.pr, label %77 [
    i16 0, label %28
    i16 1, label %28
    i16 3, label %28
    i16 6, label %43
    i16 2, label %49
    i16 5, label %53
    i16 -32692, label %60
    i16 -32691, label %65
    i16 8, label %.thread56
  ]

28:                                               ; preds = %.thread, %27, %27, %27
  %29 = phi i16 [ 1, %.thread ], [ %.pr, %27 ], [ %.pr, %27 ], [ %.pr, %27 ]
  %30 = getelementptr inbounds i8, ptr %0, i64 162
  %31 = load i16, ptr %30, align 2, !tbaa !22
  %32 = icmp eq i16 %31, 1
  br i1 %32, label %33, label %.thread56

33:                                               ; preds = %28
  %34 = load i16, ptr %16, align 2, !tbaa !19
  %35 = zext i16 %34 to i32
  %.not54 = icmp eq i16 %34, 1
  br i1 %.not54, label %.thread56, label %36

36:                                               ; preds = %33
  %37 = load i16, ptr %10, align 4, !tbaa !18
  %38 = icmp ult i16 %37, 8
  br i1 %38, label %39, label %.thread56

39:                                               ; preds = %36
  %40 = zext nneg i16 %37 to i32
  %41 = zext nneg i16 %29 to i32
  %42 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef nonnull @photoTag, i32 noundef %41, ptr noundef nonnull @.str.4, i32 noundef %35, i32 noundef %40) #4
  br label %.thread56

43:                                               ; preds = %27
  %44 = getelementptr inbounds i8, ptr %0, i64 162
  %45 = load i16, ptr %44, align 2, !tbaa !22
  %.not53 = icmp eq i16 %45, 1
  br i1 %.not53, label %.thread56, label %46

46:                                               ; preds = %43
  %47 = zext i16 %45 to i32
  %48 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef nonnull @.str.6, i32 noundef %47) #4
  br label %.thread56

49:                                               ; preds = %27
  %50 = icmp slt i32 %22, 3
  br i1 %50, label %51, label %.thread56

51:                                               ; preds = %49
  %52 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef nonnull @.str.8, i32 noundef %22) #4
  br label %.thread56

53:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %4) #4
  %54 = call i32 (ptr, i32, ...) @TIFFGetFieldDefaulted(ptr noundef nonnull %0, i32 noundef 332, ptr noundef nonnull %4) #4
  %55 = load i16, ptr %4, align 2, !tbaa !21
  %.not52 = icmp eq i16 %55, 1
  br i1 %.not52, label %56, label %.critedge

56:                                               ; preds = %53
  %57 = load i16, ptr %16, align 2, !tbaa !19
  %58 = icmp ult i16 %57, 4
  br i1 %58, label %.critedge, label %59

59:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #4
  br label %.thread56

60:                                               ; preds = %27
  %61 = getelementptr inbounds i8, ptr %0, i64 112
  %62 = load i16, ptr %61, align 8, !tbaa !23
  %.not51 = icmp eq i16 %62, -30860
  br i1 %.not51, label %.thread56, label %63

63:                                               ; preds = %60
  %64 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef nonnull @.str.12, i32 noundef 34676) #4
  br label %.thread56

65:                                               ; preds = %27
  %66 = getelementptr inbounds i8, ptr %0, i64 112
  %67 = load i16, ptr %66, align 8, !tbaa !23
  %68 = and i16 %67, -2
  %switch = icmp eq i16 %68, -30860
  br i1 %switch, label %71, label %69

69:                                               ; preds = %65
  %70 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.13, ptr noundef nonnull @.str.12, i32 noundef 34676, i32 noundef 34677) #4
  br label %.thread56

71:                                               ; preds = %65
  %72 = getelementptr inbounds i8, ptr %0, i64 162
  %73 = load i16, ptr %72, align 2, !tbaa !22
  %.not50 = icmp eq i16 %73, 1
  br i1 %.not50, label %.thread56, label %74

74:                                               ; preds = %71
  %75 = zext i16 %73 to i32
  %76 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.14, ptr noundef nonnull @.str.6, i32 noundef %75) #4
  br label %.thread56

77:                                               ; preds = %27
  %78 = zext i16 %.pr to i32
  %79 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.15, ptr noundef nonnull @photoTag, i32 noundef %78) #4
  br label %.thread56

.critedge:                                        ; preds = %56, %53
  %.sink57 = phi i16 [ %55, %53 ], [ %57, %56 ]
  %.str.4.sink = phi ptr [ @.str.10, %53 ], [ @.str.4, %56 ]
  %80 = zext i16 %.sink57 to i32
  %81 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.9, ptr noundef nonnull %.str.4.sink, i32 noundef %80) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #4
  br label %.thread56

.thread56:                                        ; preds = %24, %27, %36, %33, %28, %43, %49, %60, %71, %59, %.critedge, %77, %74, %69, %63, %51, %46, %39, %25, %12, %7
  %.1 = phi i32 [ 0, %12 ], [ 0, %77 ], [ 0, %69 ], [ 0, %74 ], [ 0, %63 ], [ 0, %51 ], [ 0, %46 ], [ 0, %39 ], [ 0, %25 ], [ 0, %7 ], [ 0, %.critedge ], [ 1, %59 ], [ 1, %71 ], [ 1, %60 ], [ 1, %49 ], [ 1, %43 ], [ 1, %28 ], [ 1, %33 ], [ 1, %36 ], [ 1, %27 ], [ 1, %24 ]
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #4
  ret i32 %.1
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare i32 @TIFFGetField(ptr noundef, i32 noundef, ...) local_unnamed_addr #3

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

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

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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !10, i64 384}
!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, !11, i64 60}
!19 = !{!12, !11, i64 74}
!20 = !{!12, !11, i64 156}
!21 = !{!11, !11, i64 0}
!22 = !{!12, !11, i64 114}
!23 = !{!12, !11, i64 64}


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