; LLVM IR from ermig1979/Simd :: src/Simd (SimdBaseImageSave)

; 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.Simd::ImageSaverParam" = type { i64, i64, i32, i32, i32, i32 }
%"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 }

; 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 uwtable
declare dso_local noundef ptr @_ZN4Simd4Base16CreateImageSaverERKNS_15ImageSaverParamE(ptr noundef nonnull align 8 dereferenceable(32)) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN4Simd4Base17ImageSaveToMemoryEPKhmmm19SimdPixelFormatType17SimdImageFileTypeiPm(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, ptr noundef %7) #1 personality ptr @__gxx_personality_v0 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca %"struct.Simd::ImageSaverParam", align 8
  %19 = alloca %"class.std::unique_ptr", align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store i64 %1, ptr %11, align 8, !tbaa !9
  store i64 %2, ptr %12, align 8, !tbaa !9
  store i64 %3, ptr %13, align 8, !tbaa !9
  store i32 %4, ptr %14, align 4, !tbaa !11
  store i32 %5, ptr %15, align 4, !tbaa !13
  store i32 %6, ptr %16, align 4, !tbaa !15
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %18) #5
  %23 = load i64, ptr %12, align 8, !tbaa !9
  %24 = load i64, ptr %13, align 8, !tbaa !9
  %25 = load i32, ptr %14, align 4, !tbaa !11
  %26 = load i32, ptr %15, align 4, !tbaa !13
  %27 = load i32, ptr %16, align 4, !tbaa !15
  call void @_ZN4Simd15ImageSaverParamC2Emm19SimdPixelFormatType17SimdImageFileTypei(ptr noundef nonnull align 8 dereferenceable(32) %18, i64 noundef %23, i64 noundef %24, i32 noundef %25, i32 noundef %26, i32 noundef %27)
  %28 = call noundef zeroext i1 @_ZN4Simd15ImageSaverParam8ValidateEv(ptr noundef nonnull align 8 dereferenceable(32) %18)
  br i1 %28, label %29, label %55

29:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %30 = call noundef ptr @_ZN4Simd4Base16CreateImageSaverERKNS_15ImageSaverParamE(ptr noundef nonnull align 8 dereferenceable(32) %18)
  call void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEC2IS3_vEEPS1_(ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef %30) #5
  %31 = call noundef zeroext i1 @_ZNKSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEcvbEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #5
  br i1 %31, label %32, label %51

32:                                               ; preds = %29
  %33 = call noundef ptr @_ZNKSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #5
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = load i64, ptr %11, align 8, !tbaa !9
  %36 = load ptr, ptr %33, align 8, !tbaa !17
  %37 = getelementptr inbounds ptr, ptr %36, i64 2
  %38 = load ptr, ptr %37, align 8
  %39 = invoke noundef zeroext i1 %38(ptr noundef nonnull align 8 dereferenceable(96) %33, ptr noundef %34, i64 noundef %35)
          to label %40 unwind label %46

40:                                               ; preds = %32
  br i1 %39, label %41, label %50

41:                                               ; preds = %40
  %42 = call noundef ptr @_ZNKSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %19) #5
  %43 = load ptr, ptr %17, align 8, !tbaa !5
  %44 = invoke noundef ptr @_ZN4Simd10ImageSaver7ReleaseEPm(ptr noundef nonnull align 8 dereferenceable(96) %42, ptr noundef %43)
          to label %45 unwind label %46

45:                                               ; preds = %41
  store ptr %44, ptr %9, align 8
  store i32 1, ptr %22, align 4
  br label %52

46:                                               ; preds = %41, %32
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %20, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %21, align 4
  call void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  br label %58

50:                                               ; preds = %40
  br label %51

51:                                               ; preds = %50, %29
  store i32 0, ptr %22, align 4
  br label %52

52:                                               ; preds = %51, %45
  call void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  %53 = load i32, ptr %22, align 4
  switch i32 %53, label %56 [
    i32 0, label %54
  ]

54:                                               ; preds = %52
  br label %55

55:                                               ; preds = %54, %8
  store ptr null, ptr %9, align 8
  store i32 1, ptr %22, align 4
  br label %56

56:                                               ; preds = %55, %52
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  %57 = load ptr, ptr %9, align 8
  ret ptr %57

58:                                               ; preds = %46
  %59 = load ptr, ptr %20, align 8
  %60 = load i32, ptr %21, align 4
  %61 = insertvalue { ptr, i32 } poison, ptr %59, 0
  %62 = insertvalue { ptr, i32 } %61, i32 %60, 1
  resume { ptr, i32 } %62
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN4Simd15ImageSaverParamC2Emm19SimdPixelFormatType17SimdImageFileTypei(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4Simd15ImageSaverParam8ValidateEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEC2IS3_vEEPS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN4Simd10ImageSaver7ReleaseEPm(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { alwaysinline 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 #3 = { 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 #4 = { alwaysinline 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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS19SimdPixelFormatType", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTS17SimdImageFileType", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !8, i64 0}


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

%"struct.Simd::ImageSaverParam" = type { i64, i64, i32, i32, i32, i32 }
%"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 }

; 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 uwtable
declare dso_local noundef ptr @_ZN4Simd4Base16CreateImageSaverERKNS_15ImageSaverParamE(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN4Simd4Base17ImageSaveToMemoryEPKhmmm19SimdPixelFormatType17SimdImageFileTypeiPm(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, ptr noundef %7) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %9 = alloca %"struct.Simd::ImageSaverParam", align 8
  %10 = alloca %"class.std::unique_ptr", align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #5
  call void @_ZN4Simd15ImageSaverParamC2Emm19SimdPixelFormatType17SimdImageFileTypei(ptr noundef nonnull align 8 dereferenceable(32) %9, i64 noundef %2, i64 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6)
  %11 = call noundef zeroext i1 @_ZN4Simd15ImageSaverParam8ValidateEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  br i1 %11, label %12, label %28

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  %13 = call noundef ptr @_ZN4Simd4Base16CreateImageSaverERKNS_15ImageSaverParamE(ptr noundef nonnull align 8 dereferenceable(32) %9)
  call void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEC2IS3_vEEPS1_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef %13) #5
  %14 = call noundef zeroext i1 @_ZNKSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEcvbEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  br i1 %14, label %15, label %.thread

15:                                               ; preds = %12
  %16 = call noundef ptr @_ZNKSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = load ptr, ptr %18, align 8
  %20 = invoke noundef zeroext i1 %19(ptr noundef nonnull align 8 dereferenceable(96) %16, ptr noundef %0, i64 noundef %1)
          to label %21 unwind label %25

21:                                               ; preds = %15
  br i1 %20, label %22, label %.thread

22:                                               ; preds = %21
  %23 = call noundef ptr @_ZNKSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  %24 = invoke noundef ptr @_ZN4Simd10ImageSaver7ReleaseEPm(ptr noundef nonnull align 8 dereferenceable(96) %23, ptr noundef %7)
          to label %27 unwind label %25

25:                                               ; preds = %22, %15
  %26 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #5
  resume { ptr, i32 } %26

.thread:                                          ; preds = %21, %12
  call void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  br label %28

27:                                               ; preds = %22
  call void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  br label %28

28:                                               ; preds = %8, %.thread, %27
  %.1 = phi ptr [ %24, %27 ], [ null, %.thread ], [ null, %8 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #5
  ret ptr %.1
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN4Simd15ImageSaverParamC2Emm19SimdPixelFormatType17SimdImageFileTypei(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4Simd15ImageSaverParam8ValidateEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEC2IS3_vEEPS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef ptr @_ZN4Simd10ImageSaver7ReleaseEPm(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10unique_ptrIN4Simd10ImageSaverESt14default_deleteIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { alwaysinline 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 #3 = { 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 #4 = { alwaysinline 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass