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

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

@TIFFRewriteDirectory.module = external hidden constant [21 x i8], align 16
@.str = external hidden unnamed_addr constant [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [29 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @TIFFRewriteDirectory(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.tiff, ptr %8, i32 0, i32 4
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %15

12:                                               ; preds = %1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call i32 @TIFFWriteDirectory(ptr noundef %13)
  store i32 %14, ptr %2, align 4
  br label %178

15:                                               ; preds = %1
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.tiff, ptr %16, i32 0, i32 9
  %18 = getelementptr inbounds %struct.TIFFHeader, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 4, !tbaa !19
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.tiff, ptr %20, i32 0, i32 4
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = icmp eq i32 %19, %22
  br i1 %23, label %24, label %56

24:                                               ; preds = %15
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.tiff, ptr %25, i32 0, i32 9
  %27 = getelementptr inbounds %struct.TIFFHeader, ptr %26, i32 0, i32 2
  store i32 0, ptr %27, align 4, !tbaa !19
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.tiff, ptr %28, i32 0, i32 4
  store i32 0, ptr %29, align 4, !tbaa !9
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.tiff, ptr %30, i32 0, i32 54
  %32 = load ptr, ptr %31, align 8, !tbaa !20
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.tiff, ptr %33, i32 0, i32 51
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = call i32 %32(ptr noundef %35, i32 noundef 4, i32 noundef 0)
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.tiff, ptr %37, i32 0, i32 53
  %39 = load ptr, ptr %38, align 8, !tbaa !22
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.tiff, ptr %40, i32 0, i32 51
  %42 = load ptr, ptr %41, align 8, !tbaa !21
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tiff, ptr %43, i32 0, i32 9
  %45 = getelementptr inbounds %struct.TIFFHeader, ptr %44, i32 0, i32 2
  %46 = call i32 %39(ptr noundef %42, ptr noundef %45, i32 noundef 4)
  %47 = icmp eq i32 %46, 4
  br i1 %47, label %55, label %48

48:                                               ; preds = %24
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.tiff, ptr %49, i32 0, i32 51
  %51 = load ptr, ptr %50, align 8, !tbaa !21
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.tiff, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !23
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %51, ptr noundef %54, ptr noundef @.str)
  store i32 0, ptr %2, align 4
  br label %178

55:                                               ; preds = %24
  br label %175

56:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.tiff, ptr %57, i32 0, i32 9
  %59 = getelementptr inbounds %struct.TIFFHeader, ptr %58, i32 0, i32 2
  %60 = load i32, ptr %59, align 4, !tbaa !19
  store i32 %60, ptr %4, align 4, !tbaa !24
  br label %61

61:                                               ; preds = %136, %56
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #3
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.tiff, ptr %62, i32 0, i32 54
  %64 = load ptr, ptr %63, align 8, !tbaa !20
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.tiff, ptr %65, i32 0, i32 51
  %67 = load ptr, ptr %66, align 8, !tbaa !21
  %68 = load i32, ptr %4, align 4, !tbaa !24
  %69 = call i32 %64(ptr noundef %67, i32 noundef %68, i32 noundef 0)
  %70 = load i32, ptr %4, align 4, !tbaa !24
  %71 = icmp eq i32 %69, %70
  br i1 %71, label %72, label %81

72:                                               ; preds = %61
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.tiff, ptr %73, i32 0, i32 52
  %75 = load ptr, ptr %74, align 8, !tbaa !25
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.tiff, ptr %76, i32 0, i32 51
  %78 = load ptr, ptr %77, align 8, !tbaa !21
  %79 = call i32 %75(ptr noundef %78, ptr noundef %6, i32 noundef 2)
  %80 = icmp eq i32 %79, 2
  br i1 %80, label %85, label %81

81:                                               ; preds = %72, %61
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.tiff, ptr %82, i32 0, i32 51
  %84 = load ptr, ptr %83, align 8, !tbaa !21
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %84, ptr noundef @TIFFRewriteDirectory.module, ptr noundef @.str.1)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %124

85:                                               ; preds = %72
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.tiff, ptr %86, i32 0, i32 3
  %88 = load i32, ptr %87, align 8, !tbaa !26
  %89 = and i32 %88, 128
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %92

91:                                               ; preds = %85
  call void @TIFFSwabShort(ptr noundef %6)
  br label %92

92:                                               ; preds = %91, %85
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.tiff, ptr %93, i32 0, i32 54
  %95 = load ptr, ptr %94, align 8, !tbaa !20
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.tiff, ptr %96, i32 0, i32 51
  %98 = load ptr, ptr %97, align 8, !tbaa !21
  %99 = load i16, ptr %6, align 2, !tbaa !27
  %100 = zext i16 %99 to i64
  %101 = mul i64 %100, 12
  %102 = trunc i64 %101 to i32
  %103 = call i32 %95(ptr noundef %98, i32 noundef %102, i32 noundef 1)
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.tiff, ptr %104, i32 0, i32 52
  %106 = load ptr, ptr %105, align 8, !tbaa !25
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.tiff, ptr %107, i32 0, i32 51
  %109 = load ptr, ptr %108, align 8, !tbaa !21
  %110 = call i32 %106(ptr noundef %109, ptr noundef %4, i32 noundef 4)
  %111 = icmp eq i32 %110, 4
  br i1 %111, label %116, label %112

112:                                              ; preds = %92
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.tiff, ptr %113, i32 0, i32 51
  %115 = load ptr, ptr %114, align 8, !tbaa !21
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %115, ptr noundef @TIFFRewriteDirectory.module, ptr noundef @.str.2)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %124

116:                                              ; preds = %92
  %117 = load ptr, ptr %3, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.tiff, ptr %117, i32 0, i32 3
  %119 = load i32, ptr %118, align 8, !tbaa !26
  %120 = and i32 %119, 128
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %123

122:                                              ; preds = %116
  call void @TIFFSwabLong(ptr noundef %4)
  br label %123

123:                                              ; preds = %122, %116
  store i32 0, ptr %7, align 4
  br label %124

124:                                              ; preds = %123, %112, %81
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #3
  %125 = load i32, ptr %7, align 4
  switch i32 %125, label %172 [
    i32 0, label %126
  ]

126:                                              ; preds = %124
  br label %127

127:                                              ; preds = %126
  %128 = load i32, ptr %4, align 4, !tbaa !24
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.tiff, ptr %129, i32 0, i32 4
  %131 = load i32, ptr %130, align 4, !tbaa !9
  %132 = icmp ne i32 %128, %131
  br i1 %132, label %133, label %136

133:                                              ; preds = %127
  %134 = load i32, ptr %4, align 4, !tbaa !24
  %135 = icmp ne i32 %134, 0
  br label %136

136:                                              ; preds = %133, %127
  %137 = phi i1 [ false, %127 ], [ %135, %133 ]
  br i1 %137, label %61, label %138, !llvm.loop !28

138:                                              ; preds = %136
  %139 = load ptr, ptr %3, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.tiff, ptr %139, i32 0, i32 54
  %141 = load ptr, ptr %140, align 8, !tbaa !20
  %142 = load ptr, ptr %3, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.tiff, ptr %142, i32 0, i32 51
  %144 = load ptr, ptr %143, align 8, !tbaa !21
  %145 = call i32 %141(ptr noundef %144, i32 noundef 0, i32 noundef 1)
  store i32 %145, ptr %5, align 4, !tbaa !24
  %146 = load ptr, ptr %3, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.tiff, ptr %146, i32 0, i32 54
  %148 = load ptr, ptr %147, align 8, !tbaa !20
  %149 = load ptr, ptr %3, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.tiff, ptr %149, i32 0, i32 51
  %151 = load ptr, ptr %150, align 8, !tbaa !21
  %152 = load i32, ptr %5, align 4, !tbaa !24
  %153 = sub i32 %152, 4
  %154 = call i32 %148(ptr noundef %151, i32 noundef %153, i32 noundef 0)
  %155 = load ptr, ptr %3, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.tiff, ptr %155, i32 0, i32 4
  store i32 0, ptr %156, align 4, !tbaa !9
  %157 = load ptr, ptr %3, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.tiff, ptr %157, i32 0, i32 53
  %159 = load ptr, ptr %158, align 8, !tbaa !22
  %160 = load ptr, ptr %3, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.tiff, ptr %160, i32 0, i32 51
  %162 = load ptr, ptr %161, align 8, !tbaa !21
  %163 = load ptr, ptr %3, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.tiff, ptr %163, i32 0, i32 4
  %165 = call i32 %159(ptr noundef %162, ptr noundef %164, i32 noundef 4)
  %166 = icmp eq i32 %165, 4
  br i1 %166, label %171, label %167

167:                                              ; preds = %138
  %168 = load ptr, ptr %3, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.tiff, ptr %168, i32 0, i32 51
  %170 = load ptr, ptr %169, align 8, !tbaa !21
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %170, ptr noundef @TIFFRewriteDirectory.module, ptr noundef @.str.3)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %172

171:                                              ; preds = %138
  store i32 0, ptr %7, align 4
  br label %172

172:                                              ; preds = %171, %167, %124
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %173 = load i32, ptr %7, align 4
  switch i32 %173, label %180 [
    i32 0, label %174
    i32 1, label %178
  ]

174:                                              ; preds = %172
  br label %175

175:                                              ; preds = %174, %55
  %176 = load ptr, ptr %3, align 8, !tbaa !5
  %177 = call i32 @TIFFWriteDirectory(ptr noundef %176)
  store i32 %177, ptr %2, align 4
  br label %178

178:                                              ; preds = %175, %172, %48, %12
  %179 = load i32, ptr %2, align 4
  ret i32 %179

180:                                              ; preds = %172
  unreachable
}

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

declare void @TIFFSwabShort(ptr noundef) #2

declare void @TIFFSwabLong(ptr 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 = { 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 20}
!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 = !{!10, !11, i64 324}
!20 = !{!10, !6, i64 632}
!21 = !{!10, !6, i64 608}
!22 = !{!10, !6, i64 624}
!23 = !{!10, !6, i64 0}
!24 = !{!11, !11, i64 0}
!25 = !{!10, !6, i64 616}
!26 = !{!10, !11, i64 16}
!27 = !{!12, !12, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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

@TIFFRewriteDirectory.module = external hidden constant [21 x i8], align 16
@.str = external hidden unnamed_addr constant [27 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TIFFWriteDirectory(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

; 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
define dso_local i32 @TIFFRewriteDirectory(ptr noundef %0) local_unnamed_addr #0 {
  %2 = alloca i32, align 4
  %3 = alloca i16, align 2
  %4 = getelementptr inbounds i8, ptr %0, i64 20
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %1
  %8 = tail call i32 @TIFFWriteDirectory(ptr noundef nonnull %0)
  br label %87

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 324
  %11 = load i32, ptr %10, align 4, !tbaa !18
  %12 = icmp eq i32 %11, %5
  %13 = getelementptr inbounds i8, ptr %0, i64 632
  br i1 %12, label %14, label %27

14:                                               ; preds = %9
  store i32 0, ptr %10, align 4, !tbaa !18
  store i32 0, ptr %4, align 4, !tbaa !5
  %15 = load ptr, ptr %13, align 8, !tbaa !19
  %16 = getelementptr inbounds i8, ptr %0, i64 608
  %17 = load ptr, ptr %16, align 8, !tbaa !20
  %18 = tail call i32 %15(ptr noundef %17, i32 noundef 4, i32 noundef 0) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 624
  %20 = load ptr, ptr %19, align 8, !tbaa !21
  %21 = load ptr, ptr %16, align 8, !tbaa !20
  %22 = tail call i32 %20(ptr noundef %21, ptr noundef nonnull %10, i32 noundef 4) #3
  %23 = icmp eq i32 %22, 4
  br i1 %23, label %85, label %24

24:                                               ; preds = %14
  %25 = load ptr, ptr %16, align 8, !tbaa !20
  %26 = load ptr, ptr %0, align 8, !tbaa !22
  tail call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %25, ptr noundef %26, ptr noundef nonnull @.str) #3
  br label %87

27:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  store i32 %11, ptr %2, align 4, !tbaa !23
  %28 = getelementptr inbounds i8, ptr %0, i64 608
  %29 = getelementptr inbounds i8, ptr %0, i64 616
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  br label %31

31:                                               ; preds = %62, %27
  %32 = phi i32 [ %63, %62 ], [ %11, %27 ]
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #3
  %33 = load ptr, ptr %13, align 8, !tbaa !19
  %34 = load ptr, ptr %28, align 8, !tbaa !20
  %35 = call i32 %33(ptr noundef %34, i32 noundef %32, i32 noundef 0) #3
  %36 = load i32, ptr %2, align 4, !tbaa !23
  %37 = icmp eq i32 %35, %36
  br i1 %37, label %38, label %.critedge

38:                                               ; preds = %31
  %39 = load ptr, ptr %29, align 8, !tbaa !24
  %40 = load ptr, ptr %28, align 8, !tbaa !20
  %41 = call i32 %39(ptr noundef %40, ptr noundef nonnull %3, i32 noundef 2) #3
  %42 = icmp eq i32 %41, 2
  br i1 %42, label %43, label %.critedge

43:                                               ; preds = %38
  %44 = load i32, ptr %30, align 8, !tbaa !25
  %45 = and i32 %44, 128
  %.not = icmp eq i32 %45, 0
  br i1 %.not, label %47, label %46

46:                                               ; preds = %43
  call void @TIFFSwabShort(ptr noundef nonnull %3) #3
  br label %47

47:                                               ; preds = %46, %43
  %48 = load ptr, ptr %13, align 8, !tbaa !19
  %49 = load ptr, ptr %28, align 8, !tbaa !20
  %50 = load i16, ptr %3, align 2, !tbaa !26
  %51 = zext i16 %50 to i32
  %52 = mul nuw nsw i32 %51, 12
  %53 = call i32 %48(ptr noundef %49, i32 noundef %52, i32 noundef 1) #3
  %54 = load ptr, ptr %29, align 8, !tbaa !24
  %55 = load ptr, ptr %28, align 8, !tbaa !20
  %56 = call i32 %54(ptr noundef %55, ptr noundef nonnull %2, i32 noundef 4) #3
  %57 = icmp eq i32 %56, 4
  br i1 %57, label %58, label %.critedge

58:                                               ; preds = %47
  %59 = load i32, ptr %30, align 8, !tbaa !25
  %60 = and i32 %59, 128
  %.not43 = icmp eq i32 %60, 0
  br i1 %.not43, label %62, label %61

61:                                               ; preds = %58
  call void @TIFFSwabLong(ptr noundef nonnull %2) #3
  br label %62

62:                                               ; preds = %58, %61
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #3
  %63 = load i32, ptr %2, align 4
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = icmp ne i32 %63, %64
  %66 = icmp ne i32 %63, 0
  %67 = and i1 %66, %65
  br i1 %67, label %31, label %68, !llvm.loop !27

68:                                               ; preds = %62
  %69 = load ptr, ptr %13, align 8, !tbaa !19
  %70 = load ptr, ptr %28, align 8, !tbaa !20
  %71 = call i32 %69(ptr noundef %70, i32 noundef 0, i32 noundef 1) #3
  %72 = load ptr, ptr %13, align 8, !tbaa !19
  %73 = load ptr, ptr %28, align 8, !tbaa !20
  %74 = add i32 %71, -4
  %75 = call i32 %72(ptr noundef %73, i32 noundef %74, i32 noundef 0) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %0, i64 624
  %77 = load ptr, ptr %76, align 8, !tbaa !21
  %78 = load ptr, ptr %28, align 8, !tbaa !20
  %79 = call i32 %77(ptr noundef %78, ptr noundef nonnull %4, i32 noundef 4) #3
  %80 = icmp eq i32 %79, 4
  br i1 %80, label %84, label %81

81:                                               ; preds = %68
  %82 = load ptr, ptr %28, align 8, !tbaa !20
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %82, ptr noundef nonnull @TIFFRewriteDirectory.module, ptr noundef nonnull @.str.3) #3
  br label %.thread

.critedge:                                        ; preds = %47, %31, %38
  %.str.1.sink = phi ptr [ @.str.1, %38 ], [ @.str.1, %31 ], [ @.str.2, %47 ]
  %83 = load ptr, ptr %28, align 8, !tbaa !20
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %83, ptr noundef nonnull @TIFFRewriteDirectory.module, ptr noundef nonnull %.str.1.sink) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #3
  br label %.thread

.thread:                                          ; preds = %81, %.critedge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %87

84:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %85

85:                                               ; preds = %84, %14
  %86 = call i32 @TIFFWriteDirectory(ptr noundef nonnull %0)
  br label %87

87:                                               ; preds = %.thread, %85, %24, %7
  %.3 = phi i32 [ %8, %7 ], [ %86, %85 ], [ 0, %24 ], [ 0, %.thread ]
  ret i32 %.3
}

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

declare void @TIFFSwabShort(ptr noundef) local_unnamed_addr #2

declare void @TIFFSwabLong(ptr 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 = { 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 20}
!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 = !{!6, !10, i64 324}
!19 = !{!6, !7, i64 632}
!20 = !{!6, !7, i64 608}
!21 = !{!6, !7, i64 624}
!22 = !{!6, !7, i64 0}
!23 = !{!10, !10, i64 0}
!24 = !{!6, !7, i64 616}
!25 = !{!6, !10, i64 16}
!26 = !{!11, !11, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


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