; LLVM IR from rdguez-mariano/fast_imas_IPOL :: io_png/libs/png (pngread)

; 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.png_info_struct = type { i64, i64, i64, i64, ptr, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, [8 x i8], float, i8, i32, i32, ptr, %struct.png_time_struct, %struct.png_color_8_struct, ptr, %struct.png_color_16_struct, %struct.png_color_16_struct, i64, i64, i8, i64, i64, i8, ptr, float, float, float, float, float, float, float, float, ptr, i64, i64, ptr, ptr, i8, i8, i64, ptr, i64, ptr, ptr, i64, i8, ptr, i64, i8, double, double, ptr, ptr, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.png_time_struct = type { i16, i8, i8, i8, i8, i8 }
%struct.png_color_8_struct = type { i8, i8, i8, i8, i8 }
%struct.png_color_16_struct = type { i8, i16, i16, i16, i16 }
%struct.png_struct_def = type { [1 x %struct.__jmp_buf_tag], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i64, i64, i64, %struct.z_stream_s, ptr, i64, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, %struct.png_row_info_struct, i64, i64, ptr, i16, i16, [5 x i8], i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, i8, float, %struct.png_color_16_struct, %struct.png_color_16_struct, ptr, i64, i64, i32, float, float, ptr, ptr, ptr, ptr, ptr, ptr, %struct.png_color_8_struct, %struct.png_color_8_struct, ptr, %struct.png_color_16_struct, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64, i64, i32, i32, i64, i64, ptr, ptr, ptr, ptr, ptr, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr, ptr, i32, ptr, i8, i16, i16, i16, i64, i64, i8, i8, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i64, i64, %struct.png_unknown_chunk_t, i64, i64, ptr }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }
%struct.png_row_info_struct = type { i64, i64, i8, i8, i8, i8 }
%struct.png_unknown_chunk_t = type { [5 x i8], ptr, i64, i8 }

@.str.23 = external hidden unnamed_addr constant [49 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

declare void @png_error(ptr noundef, ptr noundef) #1

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

declare ptr @png_malloc(ptr noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @png_read_info(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @png_read_update_info(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @png_read_image(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @png_read_end(ptr noundef, ptr noundef) #3

declare void @png_free_data(ptr noundef, ptr noundef, i64 noundef, i32 noundef) #1

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

14:                                               ; preds = %4
  store i32 1, ptr %10, align 4
  br label %176

15:                                               ; preds = %4
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = and i32 %16, 1024
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_invert_alpha(ptr noundef %20)
  br label %21

21:                                               ; preds = %19, %15
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @png_read_info(ptr noundef %22, ptr noundef %23)
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.png_info_struct, ptr %24, i32 0, i32 1
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = icmp ugt i64 %26, 2305843009213693951
  br i1 %27, label %28, label %30

28:                                               ; preds = %21
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_error(ptr noundef %29, ptr noundef @.str.23)
  br label %30

30:                                               ; preds = %28, %21
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = and i32 %31, 1
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %30
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_strip_16(ptr noundef %35)
  br label %36

36:                                               ; preds = %34, %30
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = and i32 %37, 2
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %42

40:                                               ; preds = %36
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_strip_alpha(ptr noundef %41)
  br label %42

42:                                               ; preds = %40, %36
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = and i32 %43, 8
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %48

46:                                               ; preds = %42
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_packswap(ptr noundef %47)
  br label %48

48:                                               ; preds = %46, %42
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = and i32 %49, 16
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %72

52:                                               ; preds = %48
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.png_struct_def, ptr %53, i32 0, i32 50
  %55 = load i8, ptr %54, align 1, !tbaa !20
  %56 = zext i8 %55 to i32
  %57 = icmp slt i32 %56, 8
  br i1 %57, label %69, label %58

58:                                               ; preds = %52
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.png_struct_def, ptr %59, i32 0, i32 49
  %61 = load i8, ptr %60, align 2, !tbaa !25
  %62 = zext i8 %61 to i32
  %63 = icmp eq i32 %62, 3
  br i1 %63, label %69, label %64

64:                                               ; preds = %58
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = call i64 @png_get_valid(ptr noundef %65, ptr noundef %66, i64 noundef 16)
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %64, %58, %52
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_expand(ptr noundef %70)
  br label %71

71:                                               ; preds = %69, %64
  br label %72

72:                                               ; preds = %71, %48
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = and i32 %73, 32
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %78

76:                                               ; preds = %72
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_invert_mono(ptr noundef %77)
  br label %78

78:                                               ; preds = %76, %72
  %79 = load i32, ptr %7, align 4, !tbaa !9
  %80 = and i32 %79, 64
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %93

82:                                               ; preds = %78
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = call i64 @png_get_valid(ptr noundef %83, ptr noundef %84, i64 noundef 2)
  %86 = icmp ne i64 %85, 0
  br i1 %86, label %87, label %93

87:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = call i64 @png_get_sBIT(ptr noundef %88, ptr noundef %89, ptr noundef %11)
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  call void @png_set_shift(ptr noundef %91, ptr noundef %92)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %93

93:                                               ; preds = %87, %82, %78
  %94 = load i32, ptr %7, align 4, !tbaa !9
  %95 = and i32 %94, 128
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %99

97:                                               ; preds = %93
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_bgr(ptr noundef %98)
  br label %99

99:                                               ; preds = %97, %93
  %100 = load i32, ptr %7, align 4, !tbaa !9
  %101 = and i32 %100, 256
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %105

103:                                              ; preds = %99
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_swap_alpha(ptr noundef %104)
  br label %105

105:                                              ; preds = %103, %99
  %106 = load i32, ptr %7, align 4, !tbaa !9
  %107 = and i32 %106, 512
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %111

109:                                              ; preds = %105
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_swap(ptr noundef %110)
  br label %111

111:                                              ; preds = %109, %105
  %112 = load ptr, ptr %5, align 8, !tbaa !5
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  call void @png_read_update_info(ptr noundef %112, ptr noundef %113)
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  call void @png_free_data(ptr noundef %114, ptr noundef %115, i64 noundef 64, i32 noundef 0)
  %116 = load ptr, ptr %6, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.png_info_struct, ptr %116, i32 0, i32 62
  %118 = load ptr, ptr %117, align 8, !tbaa !26
  %119 = icmp eq ptr %118, null
  br i1 %119, label %120, label %163

120:                                              ; preds = %111
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.png_info_struct, ptr %122, i32 0, i32 1
  %124 = load i64, ptr %123, align 8, !tbaa !11
  %125 = mul i64 %124, 8
  %126 = call ptr @png_malloc(ptr noundef %121, i64 noundef %125)
  %127 = load ptr, ptr %6, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.png_info_struct, ptr %127, i32 0, i32 62
  store ptr %126, ptr %128, align 8, !tbaa !26
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.png_info_struct, ptr %129, i32 0, i32 62
  %131 = load ptr, ptr %130, align 8, !tbaa !26
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.png_info_struct, ptr %132, i32 0, i32 1
  %134 = load i64, ptr %133, align 8, !tbaa !11
  %135 = mul i64 %134, 8
  call void @llvm.memset.p0.i64(ptr align 8 %131, i8 0, i64 %135, i1 false)
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.png_info_struct, ptr %136, i32 0, i32 48
  %138 = load i64, ptr %137, align 8, !tbaa !27
  %139 = or i64 %138, 64
  store i64 %139, ptr %137, align 8, !tbaa !27
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %159, %120
  %141 = load i32, ptr %9, align 4, !tbaa !9
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.png_info_struct, ptr %142, i32 0, i32 1
  %144 = load i64, ptr %143, align 8, !tbaa !11
  %145 = trunc i64 %144 to i32
  %146 = icmp slt i32 %141, %145
  br i1 %146, label %147, label %162

147:                                              ; preds = %140
  %148 = load ptr, ptr %5, align 8, !tbaa !5
  %149 = load ptr, ptr %5, align 8, !tbaa !5
  %150 = load ptr, ptr %6, align 8, !tbaa !5
  %151 = call i64 @png_get_rowbytes(ptr noundef %149, ptr noundef %150)
  %152 = call ptr @png_malloc(ptr noundef %148, i64 noundef %151)
  %153 = load ptr, ptr %6, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.png_info_struct, ptr %153, i32 0, i32 62
  %155 = load ptr, ptr %154, align 8, !tbaa !26
  %156 = load i32, ptr %9, align 4, !tbaa !9
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds ptr, ptr %155, i64 %157
  store ptr %152, ptr %158, align 8, !tbaa !5
  br label %159

159:                                              ; preds = %147
  %160 = load i32, ptr %9, align 4, !tbaa !9
  %161 = add nsw i32 %160, 1
  store i32 %161, ptr %9, align 4, !tbaa !9
  br label %140, !llvm.loop !28

162:                                              ; preds = %140
  br label %163

163:                                              ; preds = %162, %111
  %164 = load ptr, ptr %5, align 8, !tbaa !5
  %165 = load ptr, ptr %6, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.png_info_struct, ptr %165, i32 0, i32 62
  %167 = load ptr, ptr %166, align 8, !tbaa !26
  call void @png_read_image(ptr noundef %164, ptr noundef %167)
  %168 = load ptr, ptr %6, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.png_info_struct, ptr %168, i32 0, i32 2
  %170 = load i64, ptr %169, align 8, !tbaa !30
  %171 = or i64 %170, 32768
  store i64 %171, ptr %169, align 8, !tbaa !30
  %172 = load ptr, ptr %5, align 8, !tbaa !5
  %173 = load ptr, ptr %6, align 8, !tbaa !5
  call void @png_read_end(ptr noundef %172, ptr noundef %173)
  %174 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %174, ptr %7, align 4, !tbaa !9
  %175 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %175, ptr %8, align 8, !tbaa !5
  store i32 0, ptr %10, align 4
  br label %176

176:                                              ; preds = %163, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %177 = load i32, ptr %10, align 4
  switch i32 %177, label %179 [
    i32 0, label %178
    i32 1, label %178
  ]

178:                                              ; preds = %176, %176
  ret void

179:                                              ; preds = %176
  unreachable
}

declare void @png_set_invert_alpha(ptr noundef) #1

declare void @png_set_strip_16(ptr noundef) #1

declare void @png_set_strip_alpha(ptr noundef) #1

declare void @png_set_packswap(ptr noundef) #1

declare i64 @png_get_valid(ptr noundef, ptr noundef, i64 noundef) #1

declare void @png_set_expand(ptr noundef) #1

declare void @png_set_invert_mono(ptr noundef) #1

declare i64 @png_get_sBIT(ptr noundef, ptr noundef, ptr noundef) #1

declare void @png_set_shift(ptr noundef, ptr noundef) #1

declare void @png_set_bgr(ptr noundef) #1

declare void @png_set_swap_alpha(ptr noundef) #1

declare void @png_set_swap(ptr noundef) #1

declare i64 @png_get_rowbytes(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"png_info_struct", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !6, i64 32, !14, i64 40, !14, i64 42, !7, i64 44, !7, i64 45, !7, i64 46, !7, i64 47, !7, i64 48, !7, i64 49, !7, i64 50, !7, i64 51, !7, i64 52, !15, i64 60, !7, i64 64, !10, i64 68, !10, i64 72, !6, i64 80, !16, i64 88, !17, i64 96, !6, i64 104, !18, i64 112, !18, i64 122, !13, i64 136, !13, i64 144, !7, i64 152, !13, i64 160, !13, i64 168, !7, i64 176, !6, i64 184, !15, i64 192, !15, i64 196, !15, i64 200, !15, i64 204, !15, i64 208, !15, i64 212, !15, i64 216, !15, i64 220, !6, i64 224, !13, i64 232, !13, i64 240, !6, i64 248, !6, i64 256, !7, i64 264, !7, i64 265, !13, i64 272, !6, i64 280, !13, i64 288, !6, i64 296, !6, i64 304, !13, i64 312, !7, i64 320, !6, i64 328, !13, i64 336, !7, i64 344, !19, i64 352, !19, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !13, i64 392, !13, i64 400, !13, i64 408, !13, i64 416, !13, i64 424, !13, i64 432, !13, i64 440, !13, i64 448, !13, i64 456}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!"png_time_struct", !14, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!17 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!18 = !{!"png_color_16_struct", !7, i64 0, !14, i64 2, !14, i64 4, !14, i64 6, !14, i64 8}
!19 = !{!"double", !7, i64 0}
!20 = !{!21, !7, i64 631}
!21 = !{!"png_struct_def", !7, i64 0, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !7, i64 272, !7, i64 273, !13, i64 280, !13, i64 288, !13, i64 296, !22, i64 304, !6, i64 416, !13, i64 424, !10, i64 432, !10, i64 436, !10, i64 440, !10, i64 444, !10, i64 448, !13, i64 456, !13, i64 464, !13, i64 472, !13, i64 480, !13, i64 488, !13, i64 496, !13, i64 504, !13, i64 512, !6, i64 520, !6, i64 528, !6, i64 536, !6, i64 544, !6, i64 552, !6, i64 560, !23, i64 568, !13, i64 592, !13, i64 600, !6, i64 608, !14, i64 616, !14, i64 618, !7, i64 620, !7, i64 625, !7, i64 626, !7, i64 627, !7, i64 628, !7, i64 629, !7, i64 630, !7, i64 631, !7, i64 632, !7, i64 633, !7, i64 634, !7, i64 635, !7, i64 636, !14, i64 638, !7, i64 640, !15, i64 644, !18, i64 648, !18, i64 658, !6, i64 672, !13, i64 680, !13, i64 688, !10, i64 696, !15, i64 700, !15, i64 704, !6, i64 712, !6, i64 720, !6, i64 728, !6, i64 736, !6, i64 744, !6, i64 752, !17, i64 760, !17, i64 765, !6, i64 776, !18, i64 784, !6, i64 800, !6, i64 808, !6, i64 816, !6, i64 824, !6, i64 832, !6, i64 840, !6, i64 848, !6, i64 856, !6, i64 864, !13, i64 872, !13, i64 880, !13, i64 888, !13, i64 896, !13, i64 904, !13, i64 912, !10, i64 920, !10, i64 924, !13, i64 928, !13, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !6, i64 976, !7, i64 984, !7, i64 985, !6, i64 992, !6, i64 1000, !6, i64 1008, !6, i64 1016, !6, i64 1024, !6, i64 1032, !13, i64 1040, !6, i64 1048, !6, i64 1056, !10, i64 1064, !6, i64 1072, !7, i64 1080, !14, i64 1082, !14, i64 1084, !14, i64 1086, !13, i64 1088, !13, i64 1096, !7, i64 1104, !7, i64 1105, !13, i64 1112, !13, i64 1120, !6, i64 1128, !6, i64 1136, !6, i64 1144, !6, i64 1152, !6, i64 1160, !6, i64 1168, !6, i64 1176, !7, i64 1184, !13, i64 1192, !13, i64 1200, !24, i64 1208, !13, i64 1240, !13, i64 1248, !6, i64 1256}
!22 = !{!"z_stream_s", !6, i64 0, !10, i64 8, !13, i64 16, !6, i64 24, !10, i64 32, !13, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !13, i64 96, !13, i64 104}
!23 = !{!"png_row_info_struct", !13, i64 0, !13, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19}
!24 = !{!"png_unknown_chunk_t", !7, i64 0, !6, i64 8, !13, i64 16, !7, i64 24}
!25 = !{!21, !7, i64 630}
!26 = !{!12, !6, i64 384}
!27 = !{!12, !13, i64 272}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!12, !13, i64 16}


; 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.23 = external hidden unnamed_addr constant [49 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

declare void @png_error(ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare ptr @png_malloc(ptr noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @png_read_info(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @png_read_update_info(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @png_read_image(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @png_read_end(ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local void @png_read_png(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr nocapture noundef readnone %3) local_unnamed_addr #3 {
  %5 = alloca ptr, align 8
  %6 = icmp eq ptr %0, null
  br i1 %6, label %83, label %7

7:                                                ; preds = %4
  %8 = and i32 %2, 1024
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %10, label %9

9:                                                ; preds = %7
  tail call void @png_set_invert_alpha(ptr noundef nonnull %0) #4
  br label %10

10:                                               ; preds = %9, %7
  tail call void @png_read_info(ptr noundef nonnull %0, ptr noundef %1)
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = icmp ugt i64 %12, 2305843009213693951
  br i1 %13, label %14, label %15

14:                                               ; preds = %10
  tail call void @png_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.23) #4
  br label %15

15:                                               ; preds = %14, %10
  %16 = and i32 %2, 1
  %.not59 = icmp eq i32 %16, 0
  br i1 %.not59, label %18, label %17

17:                                               ; preds = %15
  tail call void @png_set_strip_16(ptr noundef nonnull %0) #4
  br label %18

18:                                               ; preds = %17, %15
  %19 = and i32 %2, 2
  %.not60 = icmp eq i32 %19, 0
  br i1 %.not60, label %21, label %20

20:                                               ; preds = %18
  tail call void @png_set_strip_alpha(ptr noundef nonnull %0) #4
  br label %21

21:                                               ; preds = %20, %18
  %22 = and i32 %2, 8
  %.not61 = icmp eq i32 %22, 0
  br i1 %.not61, label %24, label %23

23:                                               ; preds = %21
  tail call void @png_set_packswap(ptr noundef nonnull %0) #4
  br label %24

24:                                               ; preds = %23, %21
  %25 = and i32 %2, 16
  %.not62 = icmp eq i32 %25, 0
  br i1 %.not62, label %37, label %26

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %0, i64 631
  %28 = load i8, ptr %27, align 1, !tbaa !18
  %29 = icmp ult i8 %28, 8
  br i1 %29, label %36, label %30

30:                                               ; preds = %26
  %31 = getelementptr inbounds i8, ptr %0, i64 630
  %32 = load i8, ptr %31, align 2, !tbaa !23
  %33 = icmp eq i8 %32, 3
  br i1 %33, label %36, label %34

34:                                               ; preds = %30
  %35 = tail call i64 @png_get_valid(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef 16) #4
  %.not63 = icmp eq i64 %35, 0
  br i1 %.not63, label %37, label %36

36:                                               ; preds = %34, %30, %26
  tail call void @png_set_expand(ptr noundef nonnull %0) #4
  br label %37

37:                                               ; preds = %34, %36, %24
  %38 = and i32 %2, 32
  %.not64 = icmp eq i32 %38, 0
  br i1 %.not64, label %40, label %39

39:                                               ; preds = %37
  tail call void @png_set_invert_mono(ptr noundef nonnull %0) #4
  br label %40

40:                                               ; preds = %39, %37
  %41 = and i32 %2, 64
  %.not65 = icmp eq i32 %41, 0
  br i1 %.not65, label %47, label %42

42:                                               ; preds = %40
  %43 = tail call i64 @png_get_valid(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef 2) #4
  %.not66 = icmp eq i64 %43, 0
  br i1 %.not66, label %47, label %44

44:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %45 = call i64 @png_get_sBIT(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %5) #4
  %46 = load ptr, ptr %5, align 8, !tbaa !24
  call void @png_set_shift(ptr noundef nonnull %0, ptr noundef %46) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %47

47:                                               ; preds = %44, %42, %40
  %48 = and i32 %2, 128
  %.not67 = icmp eq i32 %48, 0
  br i1 %.not67, label %50, label %49

49:                                               ; preds = %47
  call void @png_set_bgr(ptr noundef nonnull %0) #4
  br label %50

50:                                               ; preds = %49, %47
  %51 = and i32 %2, 256
  %.not68 = icmp eq i32 %51, 0
  br i1 %.not68, label %53, label %52

52:                                               ; preds = %50
  call void @png_set_swap_alpha(ptr noundef nonnull %0) #4
  br label %53

53:                                               ; preds = %52, %50
  %54 = and i32 %2, 512
  %.not69 = icmp eq i32 %54, 0
  br i1 %.not69, label %56, label %55

55:                                               ; preds = %53
  call void @png_set_swap(ptr noundef nonnull %0) #4
  br label %56

56:                                               ; preds = %55, %53
  call void @png_read_update_info(ptr noundef nonnull %0, ptr noundef nonnull %1)
  call void @png_free_data(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef 64, i32 noundef 0) #4
  %57 = getelementptr inbounds i8, ptr %1, i64 384
  %58 = load ptr, ptr %57, align 8, !tbaa !25
  %59 = icmp eq ptr %58, null
  br i1 %59, label %60, label %.loopexit

60:                                               ; preds = %56
  %61 = load i64, ptr %11, align 8, !tbaa !5
  %62 = shl i64 %61, 3
  %63 = call ptr @png_malloc(ptr noundef nonnull %0, i64 noundef %62) #4
  store ptr %63, ptr %57, align 8, !tbaa !25
  %64 = load i64, ptr %11, align 8, !tbaa !5
  %65 = shl i64 %64, 3
  call void @llvm.memset.p0.i64(ptr align 8 %63, i8 0, i64 %65, i1 false)
  %66 = getelementptr inbounds i8, ptr %1, i64 272
  %67 = load i64, ptr %66, align 8, !tbaa !26
  %68 = or i64 %67, 64
  store i64 %68, ptr %66, align 8, !tbaa !26
  %69 = load i64, ptr %11, align 8, !tbaa !5
  %70 = trunc i64 %69 to i32
  %71 = icmp sgt i32 %70, 0
  br i1 %71, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %60, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %60 ]
  %72 = call i64 @png_get_rowbytes(ptr noundef %0, ptr noundef nonnull %1) #4
  %73 = call ptr @png_malloc(ptr noundef %0, i64 noundef %72) #4
  %74 = load ptr, ptr %57, align 8, !tbaa !25
  %75 = getelementptr inbounds ptr, ptr %74, i64 %indvars.iv
  store ptr %73, ptr %75, align 8, !tbaa !24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %76 = load i64, ptr %11, align 8, !tbaa !5
  %sext = shl i64 %76, 32
  %77 = ashr exact i64 %sext, 32
  %78 = icmp slt i64 %indvars.iv.next, %77
  br i1 %78, label %.lr.ph, label %.loopexit, !llvm.loop !27

.loopexit:                                        ; preds = %.lr.ph, %60, %56
  %79 = load ptr, ptr %57, align 8, !tbaa !25
  call void @png_read_image(ptr noundef %0, ptr noundef %79)
  %80 = getelementptr inbounds i8, ptr %1, i64 16
  %81 = load i64, ptr %80, align 8, !tbaa !29
  %82 = or i64 %81, 32768
  store i64 %82, ptr %80, align 8, !tbaa !29
  call void @png_read_end(ptr noundef %0, ptr noundef nonnull %1)
  br label %83

83:                                               ; preds = %4, %.loopexit
  ret void
}

declare void @png_set_invert_alpha(ptr noundef) local_unnamed_addr #1

declare void @png_set_strip_16(ptr noundef) local_unnamed_addr #1

declare void @png_set_strip_alpha(ptr noundef) local_unnamed_addr #1

declare void @png_set_packswap(ptr noundef) local_unnamed_addr #1

declare i64 @png_get_valid(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @png_set_expand(ptr noundef) local_unnamed_addr #1

declare void @png_set_invert_mono(ptr noundef) local_unnamed_addr #1

declare i64 @png_get_sBIT(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @png_set_shift(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @png_set_bgr(ptr noundef) local_unnamed_addr #1

declare void @png_set_swap_alpha(ptr noundef) local_unnamed_addr #1

declare void @png_set_swap(ptr noundef) local_unnamed_addr #1

declare i64 @png_get_rowbytes(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #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, !7, i64 8}
!6 = !{!"png_info_struct", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !11, i64 42, !8, i64 44, !8, i64 45, !8, i64 46, !8, i64 47, !8, i64 48, !8, i64 49, !8, i64 50, !8, i64 51, !8, i64 52, !12, i64 60, !8, i64 64, !13, i64 68, !13, i64 72, !10, i64 80, !14, i64 88, !15, i64 96, !10, i64 104, !16, i64 112, !16, i64 122, !7, i64 136, !7, i64 144, !8, i64 152, !7, i64 160, !7, i64 168, !8, i64 176, !10, i64 184, !12, i64 192, !12, i64 196, !12, i64 200, !12, i64 204, !12, i64 208, !12, i64 212, !12, i64 216, !12, i64 220, !10, i64 224, !7, i64 232, !7, i64 240, !10, i64 248, !10, i64 256, !8, i64 264, !8, i64 265, !7, i64 272, !10, i64 280, !7, i64 288, !10, i64 296, !10, i64 304, !7, i64 312, !8, i64 320, !10, i64 328, !7, i64 336, !8, i64 344, !17, i64 352, !17, i64 360, !10, i64 368, !10, i64 376, !10, i64 384, !7, i64 392, !7, i64 400, !7, i64 408, !7, i64 416, !7, i64 424, !7, i64 432, !7, i64 440, !7, i64 448, !7, i64 456}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!"png_time_struct", !11, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6}
!15 = !{!"png_color_8_struct", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4}
!16 = !{!"png_color_16_struct", !8, i64 0, !11, i64 2, !11, i64 4, !11, i64 6, !11, i64 8}
!17 = !{!"double", !8, i64 0}
!18 = !{!19, !8, i64 631}
!19 = !{!"png_struct_def", !8, i64 0, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !8, i64 272, !8, i64 273, !7, i64 280, !7, i64 288, !7, i64 296, !20, i64 304, !10, i64 416, !7, i64 424, !13, i64 432, !13, i64 436, !13, i64 440, !13, i64 444, !13, 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, !10, i64 520, !10, i64 528, !10, i64 536, !10, i64 544, !10, i64 552, !10, i64 560, !21, i64 568, !7, i64 592, !7, i64 600, !10, i64 608, !11, i64 616, !11, i64 618, !8, i64 620, !8, i64 625, !8, i64 626, !8, i64 627, !8, i64 628, !8, i64 629, !8, i64 630, !8, i64 631, !8, i64 632, !8, i64 633, !8, i64 634, !8, i64 635, !8, i64 636, !11, i64 638, !8, i64 640, !12, i64 644, !16, i64 648, !16, i64 658, !10, i64 672, !7, i64 680, !7, i64 688, !13, i64 696, !12, i64 700, !12, i64 704, !10, i64 712, !10, i64 720, !10, i64 728, !10, i64 736, !10, i64 744, !10, i64 752, !15, i64 760, !15, i64 765, !10, i64 776, !16, i64 784, !10, i64 800, !10, i64 808, !10, i64 816, !10, i64 824, !10, i64 832, !10, i64 840, !10, i64 848, !10, i64 856, !10, i64 864, !7, i64 872, !7, i64 880, !7, i64 888, !7, i64 896, !7, i64 904, !7, i64 912, !13, i64 920, !13, i64 924, !7, i64 928, !7, i64 936, !10, i64 944, !10, i64 952, !10, i64 960, !10, i64 968, !10, i64 976, !8, i64 984, !8, i64 985, !10, i64 992, !10, i64 1000, !10, i64 1008, !10, i64 1016, !10, i64 1024, !10, i64 1032, !7, i64 1040, !10, i64 1048, !10, i64 1056, !13, i64 1064, !10, i64 1072, !8, i64 1080, !11, i64 1082, !11, i64 1084, !11, i64 1086, !7, i64 1088, !7, i64 1096, !8, i64 1104, !8, i64 1105, !7, i64 1112, !7, i64 1120, !10, i64 1128, !10, i64 1136, !10, i64 1144, !10, i64 1152, !10, i64 1160, !10, i64 1168, !10, i64 1176, !8, i64 1184, !7, i64 1192, !7, i64 1200, !22, i64 1208, !7, i64 1240, !7, i64 1248, !10, i64 1256}
!20 = !{!"z_stream_s", !10, i64 0, !13, i64 8, !7, i64 16, !10, i64 24, !13, i64 32, !7, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !13, i64 88, !7, i64 96, !7, i64 104}
!21 = !{!"png_row_info_struct", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 17, !8, i64 18, !8, i64 19}
!22 = !{!"png_unknown_chunk_t", !8, i64 0, !10, i64 8, !7, i64 16, !8, i64 24}
!23 = !{!19, !8, i64 630}
!24 = !{!10, !10, i64 0}
!25 = !{!6, !10, i64 384}
!26 = !{!6, !7, i64 272}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!6, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass