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

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

@TIFFUnlinkDirectory.module = external hidden constant [20 x i8], align 16
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @TIFFFreeDirectory(ptr noundef) #1

declare void @_TIFFfree(ptr noundef) #2

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

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

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

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tiff, ptr %15, i32 0, i32 51
  %17 = load ptr, ptr %16, align 8, !tbaa !20
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %17, ptr noundef @TIFFUnlinkDirectory.module, ptr noundef @.str)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %123

18:                                               ; preds = %2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.tiff, ptr %19, i32 0, i32 9
  %21 = getelementptr inbounds %struct.TIFFHeader, ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 4, !tbaa !21
  store i32 %22, ptr %6, align 4, !tbaa !22
  store i32 4, ptr %7, align 4, !tbaa !22
  %23 = load i16, ptr %5, align 2, !tbaa !9
  %24 = zext i16 %23 to i32
  %25 = sub nsw i32 %24, 1
  %26 = trunc i32 %25 to i16
  store i16 %26, ptr %8, align 2, !tbaa !9
  br label %27

27:                                               ; preds = %46, %18
  %28 = load i16, ptr %8, align 2, !tbaa !9
  %29 = zext i16 %28 to i32
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %31, label %49

31:                                               ; preds = %27
  %32 = load i32, ptr %6, align 4, !tbaa !22
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %40

34:                                               ; preds = %31
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.tiff, ptr %35, i32 0, i32 51
  %37 = load ptr, ptr %36, align 8, !tbaa !20
  %38 = load i16, ptr %5, align 2, !tbaa !9
  %39 = zext i16 %38 to i32
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %37, ptr noundef @TIFFUnlinkDirectory.module, ptr noundef @.str.1, i32 noundef %39)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %123

40:                                               ; preds = %31
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call i32 @TIFFAdvanceDirectory(ptr noundef %41, ptr noundef %6, ptr noundef %7)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %123

45:                                               ; preds = %40
  br label %46

46:                                               ; preds = %45
  %47 = load i16, ptr %8, align 2, !tbaa !9
  %48 = add i16 %47, -1
  store i16 %48, ptr %8, align 2, !tbaa !9
  br label %27, !llvm.loop !23

49:                                               ; preds = %27
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call i32 @TIFFAdvanceDirectory(ptr noundef %50, ptr noundef %6, ptr noundef null)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %123

54:                                               ; preds = %49
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.tiff, ptr %55, i32 0, i32 54
  %57 = load ptr, ptr %56, align 8, !tbaa !25
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.tiff, ptr %58, i32 0, i32 51
  %60 = load ptr, ptr %59, align 8, !tbaa !20
  %61 = load i32, ptr %7, align 4, !tbaa !22
  %62 = call i32 %57(ptr noundef %60, i32 noundef %61, i32 noundef 0)
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.tiff, ptr %63, i32 0, i32 3
  %65 = load i32, ptr %64, align 8, !tbaa !26
  %66 = and i32 %65, 128
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %54
  call void @TIFFSwabLong(ptr noundef %6)
  br label %69

69:                                               ; preds = %68, %54
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.tiff, ptr %70, i32 0, i32 53
  %72 = load ptr, ptr %71, align 8, !tbaa !27
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.tiff, ptr %73, i32 0, i32 51
  %75 = load ptr, ptr %74, align 8, !tbaa !20
  %76 = call i32 %72(ptr noundef %75, ptr noundef %6, i32 noundef 4)
  %77 = icmp eq i32 %76, 4
  br i1 %77, label %82, label %78

78:                                               ; preds = %69
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.tiff, ptr %79, i32 0, i32 51
  %81 = load ptr, ptr %80, align 8, !tbaa !20
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %81, ptr noundef @TIFFUnlinkDirectory.module, ptr noundef @.str.2)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %123

82:                                               ; preds = %69
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.tiff, ptr %83, i32 0, i32 37
  %85 = load ptr, ptr %84, align 8, !tbaa !28
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  call void %85(ptr noundef %86)
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.tiff, ptr %87, i32 0, i32 3
  %89 = load i32, ptr %88, align 8, !tbaa !26
  %90 = and i32 %89, 512
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %105

92:                                               ; preds = %82
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.tiff, ptr %93, i32 0, i32 43
  %95 = load ptr, ptr %94, align 8, !tbaa !29
  %96 = icmp ne ptr %95, null
  br i1 %96, label %97, label %105

97:                                               ; preds = %92
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.tiff, ptr %98, i32 0, i32 43
  %100 = load ptr, ptr %99, align 8, !tbaa !29
  call void @_TIFFfree(ptr noundef %100)
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.tiff, ptr %101, i32 0, i32 43
  store ptr null, ptr %102, align 8, !tbaa !29
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.tiff, ptr %103, i32 0, i32 46
  store i32 0, ptr %104, align 8, !tbaa !30
  br label %105

105:                                              ; preds = %97, %92, %82
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.tiff, ptr %106, i32 0, i32 3
  %108 = load i32, ptr %107, align 8, !tbaa !26
  %109 = and i32 %108, -4177
  store i32 %109, ptr %107, align 8, !tbaa !26
  %110 = load ptr, ptr %4, align 8, !tbaa !5
  call void @TIFFFreeDirectory(ptr noundef %110)
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = call i32 @TIFFDefaultDirectory(ptr noundef %111)
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.tiff, ptr %113, i32 0, i32 4
  store i32 0, ptr %114, align 4, !tbaa !31
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.tiff, ptr %115, i32 0, i32 5
  store i32 0, ptr %116, align 8, !tbaa !32
  %117 = load ptr, ptr %4, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.tiff, ptr %117, i32 0, i32 15
  store i32 0, ptr %118, align 4, !tbaa !33
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.tiff, ptr %119, i32 0, i32 12
  store i32 -1, ptr %120, align 8, !tbaa !34
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.tiff, ptr %121, i32 0, i32 14
  store i32 -1, ptr %122, align 8, !tbaa !35
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %123

123:                                              ; preds = %105, %78, %53, %44, %34, %14
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %124 = load i32, ptr %3, align 4
  ret i32 %124
}

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

declare void @TIFFSwabLong(ptr noundef) #2

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 = !{!"short", !7, i64 0}
!11 = !{!12, !13, i64 12}
!12 = !{!"tiff", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !6, i64 32, !10, i64 40, !14, i64 48, !17, i64 320, !6, i64 328, !6, i64 336, !13, i64 344, !10, i64 348, !13, i64 352, !13, i64 356, !13, i64 360, !10, i64 364, !13, i64 368, !13, i64 372, !13, i64 376, !13, i64 380, !13, i64 384, !6, i64 392, !6, i64 400, !6, i64 408, !13, 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, !13, i64 536, !13, i64 540, !6, i64 544, !13, i64 552, !6, i64 560, !13, i64 568, !6, i64 576, !13, 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 = !{!"int", !7, i64 0}
!14 = !{!"", !7, i64 0, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !10, i64 60, !10, i64 62, !10, i64 64, !10, i64 66, !10, i64 68, !10, i64 70, !10, i64 72, !10, i64 74, !13, i64 76, !10, i64 80, !10, i64 82, !15, i64 88, !15, i64 96, !16, i64 104, !16, i64 108, !10, i64 112, !10, i64 114, !16, i64 116, !16, i64 120, !7, i64 124, !7, i64 128, !7, i64 152, !10, i64 156, !6, i64 160, !13, i64 168, !13, i64 172, !6, i64 176, !6, i64 184, !13, i64 192, !10, i64 196, !6, i64 200, !7, i64 208, !10, i64 212, !7, i64 216, !13, i64 240, !6, i64 248, !13, i64 256, !6, i64 264}
!15 = !{!"double", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!"", !10, i64 0, !10, i64 2, !13, i64 4}
!18 = !{!"long", !7, i64 0}
!19 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!12, !6, i64 608}
!21 = !{!12, !13, i64 324}
!22 = !{!13, !13, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!12, !6, i64 632}
!26 = !{!12, !13, i64 16}
!27 = !{!12, !6, i64 624}
!28 = !{!12, !6, i64 504}
!29 = !{!12, !6, i64 544}
!30 = !{!12, !13, i64 568}
!31 = !{!12, !13, i64 20}
!32 = !{!12, !13, i64 24}
!33 = !{!12, !13, i64 356}
!34 = !{!12, !13, i64 344}
!35 = !{!12, !13, i64 352}


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

@TIFFUnlinkDirectory.module = external hidden constant [20 x i8], align 16
@.str = external hidden unnamed_addr constant [43 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1

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

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

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

declare void @_TIFFfree(ptr noundef) local_unnamed_addr #2

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

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

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

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 608
  %10 = load ptr, ptr %9, align 8, !tbaa !18
  tail call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %10, ptr noundef nonnull @TIFFUnlinkDirectory.module, ptr noundef nonnull @.str) #3
  br label %.loopexit

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %0, i64 324
  %13 = load i32, ptr %12, align 4, !tbaa !19
  store i32 %13, ptr %3, align 4, !tbaa !20
  store i32 4, ptr %4, align 4, !tbaa !20
  %14 = zext i16 %1 to i32
  br label %15

15:                                               ; preds = %22, %11
  %.0.in = phi i16 [ %1, %11 ], [ %.0, %22 ]
  %.0 = add i16 %.0.in, -1
  %.not = icmp eq i16 %.0, 0
  br i1 %.not, label %24, label %16

16:                                               ; preds = %15
  %17 = load i32, ptr %3, align 4, !tbaa !20
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 608
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %21, ptr noundef nonnull @TIFFUnlinkDirectory.module, ptr noundef nonnull @.str.1, i32 noundef %14) #3
  br label %.loopexit

22:                                               ; preds = %16
  %23 = call i32 @TIFFAdvanceDirectory(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %.not37 = icmp eq i32 %23, 0
  br i1 %.not37, label %.loopexit, label %15, !llvm.loop !21

24:                                               ; preds = %15
  %25 = call i32 @TIFFAdvanceDirectory(ptr noundef %0, ptr noundef nonnull %3, ptr noundef null)
  %.not33 = icmp eq i32 %25, 0
  br i1 %.not33, label %.loopexit, label %26

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %0, i64 632
  %28 = load ptr, ptr %27, align 8, !tbaa !23
  %29 = getelementptr inbounds i8, ptr %0, i64 608
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = load i32, ptr %4, align 4, !tbaa !20
  %32 = call i32 %28(ptr noundef %30, i32 noundef %31, i32 noundef 0) #3
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  %34 = load i32, ptr %33, align 8, !tbaa !24
  %35 = and i32 %34, 128
  %.not34 = icmp eq i32 %35, 0
  br i1 %.not34, label %37, label %36

36:                                               ; preds = %26
  call void @TIFFSwabLong(ptr noundef nonnull %3) #3
  br label %37

37:                                               ; preds = %36, %26
  %38 = getelementptr inbounds i8, ptr %0, i64 624
  %39 = load ptr, ptr %38, align 8, !tbaa !25
  %40 = load ptr, ptr %29, align 8, !tbaa !18
  %41 = call i32 %39(ptr noundef %40, ptr noundef nonnull %3, i32 noundef 4) #3
  %42 = icmp eq i32 %41, 4
  br i1 %42, label %45, label %43

43:                                               ; preds = %37
  %44 = load ptr, ptr %29, align 8, !tbaa !18
  call void (ptr, ptr, ptr, ...) @TIFFErrorExt(ptr noundef %44, ptr noundef nonnull @TIFFUnlinkDirectory.module, ptr noundef nonnull @.str.2) #3
  br label %.loopexit

45:                                               ; preds = %37
  %46 = getelementptr inbounds i8, ptr %0, i64 504
  %47 = load ptr, ptr %46, align 8, !tbaa !26
  call void %47(ptr noundef nonnull %0) #3
  %48 = load i32, ptr %33, align 8, !tbaa !24
  %49 = and i32 %48, 512
  %.not35 = icmp eq i32 %49, 0
  br i1 %.not35, label %55, label %50

50:                                               ; preds = %45
  %51 = getelementptr inbounds i8, ptr %0, i64 544
  %52 = load ptr, ptr %51, align 8, !tbaa !27
  %.not36 = icmp eq ptr %52, null
  br i1 %.not36, label %55, label %53

53:                                               ; preds = %50
  call void @_TIFFfree(ptr noundef nonnull %52) #3
  store ptr null, ptr %51, align 8, !tbaa !27
  %54 = getelementptr inbounds i8, ptr %0, i64 568
  store i32 0, ptr %54, align 8, !tbaa !28
  %.pre = load i32, ptr %33, align 8, !tbaa !24
  br label %55

55:                                               ; preds = %53, %50, %45
  %56 = phi i32 [ %.pre, %53 ], [ %48, %50 ], [ %48, %45 ]
  %57 = and i32 %56, -4177
  store i32 %57, ptr %33, align 8, !tbaa !24
  call void @TIFFFreeDirectory(ptr noundef nonnull %0)
  %58 = call i32 @TIFFDefaultDirectory(ptr noundef nonnull %0)
  %59 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 0, ptr %59, align 4, !tbaa !29
  %60 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 0, ptr %60, align 8, !tbaa !30
  %61 = getelementptr inbounds i8, ptr %0, i64 356
  store i32 0, ptr %61, align 4, !tbaa !31
  %62 = getelementptr inbounds i8, ptr %0, i64 344
  store i32 -1, ptr %62, align 8, !tbaa !32
  %63 = getelementptr inbounds i8, ptr %0, i64 352
  store i32 -1, ptr %63, align 8, !tbaa !33
  br label %.loopexit

.loopexit:                                        ; preds = %22, %24, %55, %43, %19, %8
  %.031 = phi i32 [ 0, %8 ], [ 0, %19 ], [ 1, %55 ], [ 0, %43 ], [ 0, %24 ], [ 0, %22 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i32 %.031
}

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

declare void @TIFFSwabLong(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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, !10, i64 12}
!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, !7, i64 608}
!19 = !{!6, !10, i64 324}
!20 = !{!10, !10, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!6, !7, i64 632}
!24 = !{!6, !10, i64 16}
!25 = !{!6, !7, i64 624}
!26 = !{!6, !7, i64 504}
!27 = !{!6, !7, i64 544}
!28 = !{!6, !10, i64 568}
!29 = !{!6, !10, i64 20}
!30 = !{!6, !10, i64 24}
!31 = !{!6, !10, i64 356}
!32 = !{!6, !10, i64 344}
!33 = !{!6, !10, i64 352}


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