; LLVM IR from vectozavr/3dzavr :: engine/io/Image.ll (ZN5Image8save2pngERK8FilePatht)

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

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%class.Image = type { i16, i16, ptr, i8, %class.FilePath }
%class.FilePath = type { %"class.std::filesystem::__cxx11::path" }
%"class.std::filesystem::__cxx11::path" = type { %"class.std::__cxx11::basic_string", %"struct.std::filesystem::__cxx11::path::_List" }
%"struct.std::filesystem::__cxx11::path::_List" = type { %"class.std::unique_ptr" }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.2" }
%"struct.std::_Head_base.2" = type { ptr }

@.str.19 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [3 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 i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8FilePath3strB5cxx11Ev(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 8 dereferenceable(40)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

declare noalias ptr @png_create_info_struct(ptr noundef) #3

declare void @png_init_io(ptr noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #5

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #6

declare i32 @fclose(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5Image8save2pngERK8FilePatht(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(40) %1, i16 noundef zeroext %2) #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca ptr, align 8
  %9 = alloca %"class.std::__cxx11::basic_string", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i16 %2, ptr %7, align 2, !tbaa !9
  %17 = load ptr, ptr %5, align 8
  %18 = call noundef zeroext i1 @_ZNK5Image7isValidEv(ptr noundef nonnull align 8 dereferenceable(64) %17)
  br i1 %18, label %20, label %19

19:                                               ; preds = %3
  store i32 4, ptr %4, align 4
  br label %103

20:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #7
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZNK8FilePath3strB5cxx11Ev(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %9, ptr noundef nonnull align 8 dereferenceable(40) %21)
  %22 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %9) #7
  %23 = invoke noalias ptr @fopen(ptr noundef %22, ptr noundef @.str.20)
          to label %24 unwind label %28

24:                                               ; preds = %20
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #7
  store ptr %23, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %32, label %27

27:                                               ; preds = %24
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %102

28:                                               ; preds = %20
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %10, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %11, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %105

32:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %33 = call noalias ptr @png_create_write_struct(ptr noundef @.str.19, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %33, ptr %13, align 8, !tbaa !5
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 2, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %101

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %38 = load ptr, ptr %13, align 8, !tbaa !5
  %39 = call noalias ptr @png_create_info_struct(ptr noundef %38)
  store ptr %39, ptr %14, align 8, !tbaa !5
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %43, label %42

42:                                               ; preds = %37
  call void @png_destroy_write_struct(ptr noundef %13, ptr noundef null)
  store i32 3, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %100

43:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %44 = getelementptr inbounds %class.Image, ptr %17, i32 0, i32 1
  %45 = load i16, ptr %44, align 2, !tbaa !11
  %46 = zext i16 %45 to i64
  %47 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %46, i64 8)
  %48 = extractvalue { i64, i1 } %47, 1
  %49 = extractvalue { i64, i1 } %47, 0
  %50 = select i1 %48, i64 -1, i64 %49
  %51 = call noalias noundef nonnull ptr @_Znam(i64 noundef %50) #8
  store ptr %51, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  store i64 0, ptr %16, align 8, !tbaa !26
  br label %52

52:                                               ; preds = %72, %43
  %53 = load i64, ptr %16, align 8, !tbaa !26
  %54 = getelementptr inbounds %class.Image, ptr %17, i32 0, i32 1
  %55 = load i16, ptr %54, align 2, !tbaa !11
  %56 = zext i16 %55 to i64
  %57 = icmp ult i64 %53, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %52
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %75

59:                                               ; preds = %52
  %60 = getelementptr inbounds %class.Image, ptr %17, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !27
  %62 = load i64, ptr %16, align 8, !tbaa !26
  %63 = getelementptr inbounds %class.Image, ptr %17, i32 0, i32 0
  %64 = load i16, ptr %63, align 8, !tbaa !28
  %65 = zext i16 %64 to i64
  %66 = mul i64 %62, %65
  %67 = mul i64 %66, 4
  %68 = getelementptr inbounds i8, ptr %61, i64 %67
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = load i64, ptr %16, align 8, !tbaa !26
  %71 = getelementptr inbounds ptr, ptr %69, i64 %70
  store ptr %68, ptr %71, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %59
  %73 = load i64, ptr %16, align 8, !tbaa !26
  %74 = add i64 %73, 1
  store i64 %74, ptr %16, align 8, !tbaa !26
  br label %52, !llvm.loop !29

75:                                               ; preds = %58
  %76 = load ptr, ptr %13, align 8, !tbaa !5
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  call void @png_init_io(ptr noundef %76, ptr noundef %77)
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  %79 = load ptr, ptr %14, align 8, !tbaa !5
  %80 = getelementptr inbounds %class.Image, ptr %17, i32 0, i32 0
  %81 = load i16, ptr %80, align 8, !tbaa !28
  %82 = zext i16 %81 to i32
  %83 = getelementptr inbounds %class.Image, ptr %17, i32 0, i32 1
  %84 = load i16, ptr %83, align 2, !tbaa !11
  %85 = zext i16 %84 to i32
  %86 = load i16, ptr %7, align 2, !tbaa !9
  %87 = zext i16 %86 to i32
  call void @png_set_IHDR(ptr noundef %78, ptr noundef %79, i32 noundef %82, i32 noundef %85, i32 noundef %87, i32 noundef 6, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  call void @png_write_info(ptr noundef %88, ptr noundef %89)
  %90 = load ptr, ptr %13, align 8, !tbaa !5
  %91 = load ptr, ptr %15, align 8, !tbaa !5
  call void @png_write_image(ptr noundef %90, ptr noundef %91)
  %92 = load ptr, ptr %13, align 8, !tbaa !5
  %93 = load ptr, ptr %14, align 8, !tbaa !5
  call void @png_write_end(ptr noundef %92, ptr noundef %93)
  call void @png_destroy_write_struct(ptr noundef %13, ptr noundef %14)
  %94 = load ptr, ptr %15, align 8, !tbaa !5
  %95 = icmp eq ptr %94, null
  br i1 %95, label %97, label %96

96:                                               ; preds = %75
  call void @_ZdaPv(ptr noundef %94) #9
  br label %97

97:                                               ; preds = %96, %75
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = call i32 @fclose(ptr noundef %98)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %100

100:                                              ; preds = %97, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %101

101:                                              ; preds = %100, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %102

102:                                              ; preds = %101, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %103

103:                                              ; preds = %102, %19
  %104 = load i32, ptr %4, align 4
  ret i32 %104

105:                                              ; preds = %28
  %106 = load ptr, ptr %10, align 8
  %107 = load i32, ptr %11, align 4
  %108 = insertvalue { ptr, i32 } poison, ptr %106, 0
  %109 = insertvalue { ptr, i32 } %108, i32 %107, 1
  resume { ptr, i32 } %109
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5Image7isValidEv(ptr noundef nonnull align 8 dereferenceable(64)) #1 align 2

declare noalias ptr @png_create_write_struct(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare void @png_destroy_write_struct(ptr noundef, ptr noundef) #3

declare void @png_set_IHDR(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare void @png_write_info(ptr noundef, ptr noundef) #3

declare void @png_write_image(ptr noundef, ptr noundef) #3

declare void @png_write_end(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { nobuiltin allocsize(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 #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 = { mustprogress 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nobuiltin 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !10, i64 2}
!12 = !{!"_ZTS5Image", !10, i64 0, !10, i64 2, !6, i64 8, !13, i64 16, !14, i64 24}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS8FilePath", !15, i64 0}
!15 = !{!"_ZTSNSt10filesystem7__cxx114pathE", !16, i64 0, !19, i64 32}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSNSt10filesystem7__cxx114path5_ListE", !20, i64 0}
!20 = !{!"_ZTSSt10unique_ptrINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !21, i64 0}
!21 = !{!"_ZTSSt15__uniq_ptr_dataINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterELb1ELb1EE", !22, i64 0}
!22 = !{!"_ZTSSt15__uniq_ptr_implINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !23, i64 0}
!23 = !{!"_ZTSSt5tupleIJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !24, i64 0}
!24 = !{!"_ZTSSt11_Tuple_implILm0EJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !25, i64 0}
!25 = !{!"_ZTSSt10_Head_baseILm0EPNSt10filesystem7__cxx114path5_List5_ImplELb0EE", !6, i64 0}
!26 = !{!18, !18, i64 0}
!27 = !{!12, !6, i64 8}
!28 = !{!12, !10, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"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"

%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str.19 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [3 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 i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK8FilePath3strB5cxx11Ev(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

declare noalias ptr @png_create_info_struct(ptr noundef) local_unnamed_addr #5

declare void @png_init_io(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 5) i32 @_ZN5Image8save2pngERK8FilePatht(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(40) %1, i16 noundef zeroext %2) local_unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::__cxx11::basic_string", align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = tail call noundef zeroext i1 @_ZNK5Image7isValidEv(ptr noundef nonnull align 8 dereferenceable(64) %0)
  br i1 %7, label %8, label %55

8:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #7
  call void @_ZNK8FilePath3strB5cxx11Ev(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %4, ptr noundef nonnull align 8 dereferenceable(40) %1)
  %9 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %4) #7
  %10 = call noalias ptr @fopen(ptr noundef %9, ptr noundef nonnull @.str.20)
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #7
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %55, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %12 = call noalias ptr @png_create_write_struct(ptr noundef nonnull @.str.19, ptr noundef null, ptr noundef null, ptr noundef null)
  store ptr %12, ptr %5, align 8, !tbaa !5
  %.not15 = icmp eq ptr %12, null
  br i1 %.not15, label %54, label %13

13:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  %14 = call noalias ptr @png_create_info_struct(ptr noundef nonnull %12)
  store ptr %14, ptr %6, align 8, !tbaa !5
  %.not16 = icmp eq ptr %14, null
  br i1 %.not16, label %15, label %16

15:                                               ; preds = %13
  call void @png_destroy_write_struct(ptr noundef nonnull %5, ptr noundef null)
  br label %53

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %0, i64 2
  %18 = load i16, ptr %17, align 2, !tbaa !9
  %19 = zext i16 %18 to i64
  %20 = shl nuw nsw i64 %19, 3
  %21 = call noalias noundef nonnull ptr @_Znam(i64 noundef %20) #8
  %.not18 = icmp eq i16 %18, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %16
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !25
  %24 = load i16, ptr %0, align 8, !tbaa !26
  %25 = zext i16 %24 to i64
  %factor.op.mul = shl nuw nsw i64 %25, 2
  %xtraiter = and i64 %19, 3
  %26 = icmp ult i16 %18, 4
  br i1 %26, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %19, 65532
  br label %40

._crit_edge.loopexit.unr-lcssa:                   ; preds = %40, %.lr.ph
  %.017.unr = phi i64 [ 0, %.lr.ph ], [ %52, %40 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %.017.epil = phi i64 [ %29, %.epil.preheader ], [ %.017.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %.reass.epil = mul nuw nsw i64 %.017.epil, %factor.op.mul
  %27 = getelementptr inbounds i8, ptr %23, i64 %.reass.epil
  %28 = getelementptr inbounds ptr, ptr %21, i64 %.017.epil
  store ptr %27, ptr %28, align 8, !tbaa !5
  %29 = add nuw nsw i64 %.017.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !27

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %16
  call void @png_init_io(ptr noundef nonnull %12, ptr noundef nonnull %10)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i16, ptr %0, align 8, !tbaa !26
  %32 = zext i16 %31 to i32
  %33 = load i16, ptr %17, align 2, !tbaa !9
  %34 = zext i16 %33 to i32
  %35 = zext i16 %2 to i32
  call void @png_set_IHDR(ptr noundef %30, ptr noundef nonnull %14, i32 noundef %32, i32 noundef %34, i32 noundef %35, i32 noundef 6, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_write_info(ptr noundef %36, ptr noundef nonnull %14)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_write_image(ptr noundef %37, ptr noundef nonnull %21)
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_write_end(ptr noundef %38, ptr noundef nonnull %14)
  call void @png_destroy_write_struct(ptr noundef nonnull %5, ptr noundef nonnull %6)
  call void @_ZdaPv(ptr noundef nonnull %21) #9
  %39 = call i32 @fclose(ptr noundef nonnull %10)
  br label %53

40:                                               ; preds = %40, %.lr.ph.new
  %.017 = phi i64 [ 0, %.lr.ph.new ], [ %52, %40 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %40 ]
  %.reass = mul nuw nsw i64 %.017, %factor.op.mul
  %41 = getelementptr inbounds i8, ptr %23, i64 %.reass
  %42 = getelementptr inbounds ptr, ptr %21, i64 %.017
  store ptr %41, ptr %42, align 8, !tbaa !5
  %43 = or disjoint i64 %.017, 1
  %.reass.1 = mul nuw nsw i64 %43, %factor.op.mul
  %44 = getelementptr inbounds i8, ptr %23, i64 %.reass.1
  %45 = getelementptr inbounds ptr, ptr %21, i64 %43
  store ptr %44, ptr %45, align 8, !tbaa !5
  %46 = or disjoint i64 %.017, 2
  %.reass.2 = mul nuw nsw i64 %46, %factor.op.mul
  %47 = getelementptr inbounds i8, ptr %23, i64 %.reass.2
  %48 = getelementptr inbounds ptr, ptr %21, i64 %46
  store ptr %47, ptr %48, align 8, !tbaa !5
  %49 = or disjoint i64 %.017, 3
  %.reass.3 = mul nuw nsw i64 %49, %factor.op.mul
  %50 = getelementptr inbounds i8, ptr %23, i64 %.reass.3
  %51 = getelementptr inbounds ptr, ptr %21, i64 %49
  store ptr %50, ptr %51, align 8, !tbaa !5
  %52 = add nuw nsw i64 %.017, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %40, !llvm.loop !29

53:                                               ; preds = %._crit_edge, %15
  %.013 = phi i32 [ 0, %._crit_edge ], [ 3, %15 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br label %54

54:                                               ; preds = %11, %53
  %.1 = phi i32 [ %.013, %53 ], [ 2, %11 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  br label %55

55:                                               ; preds = %54, %8, %3
  %.3 = phi i32 [ 4, %3 ], [ %.1, %54 ], [ 1, %8 ]
  ret i32 %.3
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5Image7isValidEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #1 align 2

declare noalias ptr @png_create_write_struct(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @png_destroy_write_struct(ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @png_set_IHDR(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #5

declare void @png_write_info(ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @png_write_image(ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @png_write_end(ptr noundef, ptr noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { nobuiltin allocsize(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 #3 = { 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 #4 = { mustprogress 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 #5 = { "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 #6 = { nobuiltin 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 #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { builtin 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++ TBAA"}
!9 = !{!10, !11, i64 2}
!10 = !{!"_ZTS5Image", !11, i64 0, !11, i64 2, !6, i64 8, !12, i64 16, !13, i64 24}
!11 = !{!"short", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTS8FilePath", !14, i64 0}
!14 = !{!"_ZTSNSt10filesystem7__cxx114pathE", !15, i64 0, !18, i64 32}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSNSt10filesystem7__cxx114path5_ListE", !19, i64 0}
!19 = !{!"_ZTSSt10unique_ptrINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !20, i64 0}
!20 = !{!"_ZTSSt15__uniq_ptr_dataINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterELb1ELb1EE", !21, i64 0}
!21 = !{!"_ZTSSt15__uniq_ptr_implINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !22, i64 0}
!22 = !{!"_ZTSSt5tupleIJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !23, i64 0}
!23 = !{!"_ZTSSt11_Tuple_implILm0EJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !24, i64 0}
!24 = !{!"_ZTSSt10_Head_baseILm0EPNSt10filesystem7__cxx114path5_List5_ImplELb0EE", !6, i64 0}
!25 = !{!10, !6, i64 8}
!26 = !{!10, !11, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.unroll.disable"}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


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