; LLVM IR from vectozavr/3dzavr :: engine/components/props/Texture.ll (ZN7Texture17checkTransparencyEv)

; 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.Color = type { %"struct.std::array" }
%"struct.std::array" = type { [4 x i8] }
%class.Texture = type <{ %"class.std::vector", %class.FilePath, i8, [7 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Image, std::allocator<Image>>::_Vector_impl" }
%"struct.std::_Vector_base<Image, std::allocator<Image>>::_Vector_impl" = type { %"struct.std::_Vector_base<Image, std::allocator<Image>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Image, std::allocator<Image>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%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" }
%"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] }
%"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.4" }
%"struct.std::_Head_base.4" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Texture17checkTransparencyEv(ptr noundef nonnull align 8 dereferenceable(65) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %class.Color, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %41, %1
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = call noundef zeroext i16 @_ZNK7Texture5widthEv(ptr noundef nonnull align 8 dereferenceable(65) %7)
  %11 = zext i16 %10 to i32
  %12 = icmp slt i32 %9, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %8
  store i32 2, ptr %4, align 4
  br label %44

14:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %35, %14
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = call noundef zeroext i16 @_ZNK7Texture6heightEv(ptr noundef nonnull align 8 dereferenceable(65) %7)
  %18 = zext i16 %17 to i32
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  store i32 5, ptr %4, align 4
  br label %38

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = trunc i32 %22 to i16
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = trunc i32 %24 to i16
  call void @_ZNK7Texture9get_pixelEtt(ptr dead_on_unwind writable sret(%class.Color) align 1 %6, ptr noundef nonnull align 8 dereferenceable(65) %7, i16 noundef zeroext %23, i16 noundef zeroext %25)
  %26 = call noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4) %6)
  %27 = zext i8 %26 to i32
  %28 = icmp ne i32 %27, 255
  br i1 %28, label %29, label %31

29:                                               ; preds = %21
  %30 = getelementptr inbounds %class.Texture, ptr %7, i32 0, i32 2
  store i8 1, ptr %30, align 8, !tbaa !11
  store i32 1, ptr %4, align 4
  br label %32

31:                                               ; preds = %21
  store i32 0, ptr %4, align 4
  br label %32

32:                                               ; preds = %31, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %33 = load i32, ptr %4, align 4
  switch i32 %33, label %38 [
    i32 0, label %34
  ]

34:                                               ; preds = %32
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %5, align 4, !tbaa !9
  br label %15, !llvm.loop !30

38:                                               ; preds = %32, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  %39 = load i32, ptr %4, align 4
  switch i32 %39, label %44 [
    i32 5, label %40
  ]

40:                                               ; preds = %38
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %3, align 4, !tbaa !9
  br label %8, !llvm.loop !32

44:                                               ; preds = %38, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %45 = load i32, ptr %4, align 4
  switch i32 %45, label %47 [
    i32 2, label %46
    i32 1, label %46
  ]

46:                                               ; preds = %44, %44
  ret void

47:                                               ; preds = %44
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i16 @_ZNK7Texture5widthEv(ptr noundef nonnull align 8 dereferenceable(65)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i16 @_ZNK7Texture6heightEv(ptr noundef nonnull align 8 dereferenceable(65)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7Texture9get_pixelEtt(ptr dead_on_unwind noalias writable sret(%class.Color) align 1, ptr noundef nonnull align 8 dereferenceable(65), i16 noundef zeroext, i16 noundef zeroext) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4)) #2 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !29, i64 64}
!12 = !{!"_ZTS7Texture", !13, i64 0, !17, i64 24, !29, i64 64}
!13 = !{!"_ZTSSt6vectorI5ImageSaIS0_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseI5ImageSaIS0_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseI5ImageSaIS0_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseI5ImageSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"_ZTS8FilePath", !18, i64 0}
!18 = !{!"_ZTSNSt10filesystem7__cxx114pathE", !19, i64 0, !22, i64 32}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !21, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSNSt10filesystem7__cxx114path5_ListE", !23, i64 0}
!23 = !{!"_ZTSSt10unique_ptrINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !24, i64 0}
!24 = !{!"_ZTSSt15__uniq_ptr_dataINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterELb1ELb1EE", !25, i64 0}
!25 = !{!"_ZTSSt15__uniq_ptr_implINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !26, i64 0}
!26 = !{!"_ZTSSt5tupleIJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !27, i64 0}
!27 = !{!"_ZTSSt11_Tuple_implILm0EJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !28, i64 0}
!28 = !{!"_ZTSSt10_Head_baseILm0EPNSt10filesystem7__cxx114path5_List5_ImplELb0EE", !6, i64 0}
!29 = !{!"bool", !7, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = distinct !{!32, !31}


; 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.Color = type { %"struct.std::array" }
%"struct.std::array" = type { [4 x i8] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Texture17checkTransparencyEv(ptr noundef nonnull align 8 dereferenceable(65) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %class.Color, align 1
  %3 = tail call noundef zeroext i16 @_ZNK7Texture5widthEv(ptr noundef nonnull align 8 dereferenceable(65) %0)
  %.not17 = icmp eq i16 %3, 0
  br i1 %.not17, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %1, %.critedge13
  %.01016 = phi i32 [ %14, %.critedge13 ], [ 0, %1 ]
  %4 = call noundef zeroext i16 @_ZNK7Texture6heightEv(ptr noundef nonnull align 8 dereferenceable(65) %0)
  %.not1114.not = icmp eq i16 %4, 0
  br i1 %.not1114.not, label %.critedge13, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %5 = trunc i32 %.01016 to i16
  br label %6

6:                                                ; preds = %.lr.ph, %.critedge
  %.015 = phi i32 [ 0, %.lr.ph ], [ %11, %.critedge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %7 = trunc i32 %.015 to i16
  call void @_ZNK7Texture9get_pixelEtt(ptr dead_on_unwind nonnull writable sret(%class.Color) align 1 %2, ptr noundef nonnull align 8 dereferenceable(65) %0, i16 noundef zeroext %5, i16 noundef zeroext %7)
  %8 = call noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4) %2)
  %.not = icmp eq i8 %8, -1
  br i1 %.not, label %.critedge, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  store i8 1, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %.loopexit

.critedge:                                        ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  %11 = add nuw nsw i32 %.015, 1
  %12 = call noundef zeroext i16 @_ZNK7Texture6heightEv(ptr noundef nonnull align 8 dereferenceable(65) %0)
  %13 = zext i16 %12 to i32
  %.not11 = icmp ult i32 %11, %13
  br i1 %.not11, label %6, label %.critedge13, !llvm.loop !27

.critedge13:                                      ; preds = %.critedge, %.preheader
  %14 = add nuw nsw i32 %.01016, 1
  %15 = call noundef zeroext i16 @_ZNK7Texture5widthEv(ptr noundef nonnull align 8 dereferenceable(65) %0)
  %16 = zext i16 %15 to i32
  %17 = icmp ult i32 %14, %16
  br i1 %17, label %.preheader, label %.loopexit, !llvm.loop !29

.loopexit:                                        ; preds = %.critedge13, %1, %9
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i16 @_ZNK7Texture5widthEv(ptr noundef nonnull align 8 dereferenceable(65)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i16 @_ZNK7Texture6heightEv(ptr noundef nonnull align 8 dereferenceable(65)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7Texture9get_pixelEtt(ptr dead_on_unwind noalias writable sret(%class.Color) align 1, ptr noundef nonnull align 8 dereferenceable(65), i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4)) local_unnamed_addr #2 align 2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { 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, !26, i64 64}
!6 = !{!"_ZTS7Texture", !7, i64 0, !14, i64 24, !26, i64 64}
!7 = !{!"_ZTSSt6vectorI5ImageSaIS0_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseI5ImageSaIS0_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseI5ImageSaIS0_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseI5ImageSaIS0_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!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, !12, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !11, i64 0}
!18 = !{!"long", !12, 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", !11, i64 0}
!26 = !{!"bool", !12, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = distinct !{!29, !28}


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