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

; 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.Material = type <{ %class.MaterialTag, %"class.std::shared_ptr", %class.Color, %class.Color, %class.Color, i16, [2 x i8], double, i8, [7 x i8] }>
%class.MaterialTag = type { %"class.std::__cxx11::basic_string" }
%"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.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%class.Color = type { %"struct.std::array" }
%"struct.std::array" = type { [4 x i8] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8Material16checkTransparentEv(ptr noundef nonnull align 8 dereferenceable(73) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.Material, ptr %3, i32 0, i32 1
  %5 = call noundef zeroext i1 @_ZNKSt12__shared_ptrI7TextureLN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  br i1 %5, label %6, label %18

6:                                                ; preds = %1
  %7 = getelementptr inbounds %class.Material, ptr %3, i32 0, i32 1
  %8 = call noundef ptr @_ZNKSt19__shared_ptr_accessI7TextureLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %7) #3
  %9 = call noundef zeroext i1 @_ZNK7Texture13isTransparentEv(ptr noundef nonnull align 8 dereferenceable(65) %8)
  br i1 %9, label %14, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds %class.Material, ptr %3, i32 0, i32 7
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = fcmp olt double %12, 0x3FEFFFFFFFFEA028
  br label %14

14:                                               ; preds = %10, %6
  %15 = phi i1 [ true, %6 ], [ %13, %10 ]
  %16 = getelementptr inbounds %class.Material, ptr %3, i32 0, i32 8
  %17 = zext i1 %15 to i8
  store i8 %17, ptr %16, align 8, !tbaa !23
  br label %31

18:                                               ; preds = %1
  %19 = getelementptr inbounds %class.Material, ptr %3, i32 0, i32 2
  %20 = call noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4) %19)
  %21 = zext i8 %20 to i32
  %22 = icmp ne i32 %21, 255
  br i1 %22, label %27, label %23

23:                                               ; preds = %18
  %24 = getelementptr inbounds %class.Material, ptr %3, i32 0, i32 7
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = fcmp olt double %25, 0x3FEFFFFFFFFEA028
  br label %27

27:                                               ; preds = %23, %18
  %28 = phi i1 [ true, %18 ], [ %26, %23 ]
  %29 = getelementptr inbounds %class.Material, ptr %3, i32 0, i32 8
  %30 = zext i1 %28 to i8
  store i8 %30, ptr %29, align 8, !tbaa !23
  br label %31

31:                                               ; preds = %27, %14
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessI7TextureLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Texture13isTransparentEv(ptr noundef nonnull align 8 dereferenceable(65)) #1 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

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 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 = { 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, !21, i64 64}
!10 = !{!"_ZTS8Material", !11, i64 0, !15, i64 32, !18, i64 48, !18, i64 52, !18, i64 56, !20, i64 60, !21, i64 64, !22, i64 72}
!11 = !{!"_ZTS11MaterialTag", !12, i64 0}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !14, i64 8, !7, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSSt10shared_ptrI7TextureE", !16, i64 0}
!16 = !{!"_ZTSSt12__shared_ptrI7TextureLN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !17, i64 8}
!17 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!18 = !{!"_ZTS5Color", !19, i64 0}
!19 = !{!"_ZTSSt5arrayIhLm4EE", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!"double", !7, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = !{!10, !22, i64 72}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8Material16checkTransparentEv(ptr noundef nonnull align 8 dereferenceable(73) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = tail call noundef zeroext i1 @_ZNKSt12__shared_ptrI7TextureLN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %2) #2
  br i1 %3, label %4, label %7

4:                                                ; preds = %1
  %5 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI7TextureLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %2) #2
  %6 = tail call noundef zeroext i1 @_ZNK7Texture13isTransparentEv(ptr noundef nonnull align 8 dereferenceable(65) %5)
  br label %10

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = tail call noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4) %8)
  %.not = icmp ne i8 %9, -1
  br label %10

10:                                               ; preds = %7, %4
  %.not.sink = phi i1 [ %.not, %7 ], [ %6, %4 ]
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = load double, ptr %11, align 8
  %13 = fcmp olt double %12, 0x3FEFFFFFFFFEA028
  %narrow = select i1 %.not.sink, i1 true, i1 %13
  %.sink = zext i1 %narrow to i8
  %14 = getelementptr inbounds i8, ptr %0, i64 72
  store i8 %.sink, ptr %14, align 8
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessI7TextureLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7Texture13isTransparentEv(ptr noundef nonnull align 8 dereferenceable(65)) 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 #1 align 2

attributes #0 = { 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 #1 = { 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 #2 = { 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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass