; LLVM IR from tyoma/agge :: src/agge.text/richtext.ll (ZN4agge5style10foregroundENS_5colorE)

; 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.agge::style_modifier" = type { %"struct.agge::font_descriptor", %"struct.agge::color", i16, [2 x i8] }
%"struct.agge::font_descriptor" = type <{ %"class.std::__cxx11::basic_string", i32, [4 x i8] }>
%"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.agge::color" = type { i8, i8, i8, i8 }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4agge14style_modifierD2Ev(ptr noundef nonnull align 8 dereferenceable(46)) unnamed_addr #1 align 2

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

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

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) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4agge5style10foregroundENS_5colorE(ptr dead_on_unwind noalias writable sret(%"struct.agge::style_modifier") align 8 %0, i32 %1) #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca %"struct.agge::color", align 1
  %5 = alloca %"struct.agge::style_modifier", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store i32 %1, ptr %4, align 1
  call void @llvm.lifetime.start.p0(i64 48, ptr %5) #6
  %8 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 0
  %9 = getelementptr inbounds %"struct.agge::font_descriptor", ptr %8, i32 0, i32 0
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #6
  %10 = getelementptr inbounds %"struct.agge::font_descriptor", ptr %8, i32 0, i32 1
  %11 = load i32, ptr %10, align 8
  %12 = and i32 %11, -1048576
  %13 = or i32 %12, 0
  store i32 %13, ptr %10, align 8
  %14 = getelementptr inbounds %"struct.agge::font_descriptor", ptr %8, i32 0, i32 1
  %15 = load i32, ptr %14, align 8
  %16 = and i32 %15, -15728641
  %17 = or i32 %16, 0
  store i32 %17, ptr %14, align 8
  %18 = getelementptr inbounds %"struct.agge::font_descriptor", ptr %8, i32 0, i32 1
  %19 = load i32, ptr %18, align 8
  %20 = and i32 %19, -16777217
  %21 = or i32 %20, 0
  store i32 %21, ptr %18, align 8
  %22 = getelementptr inbounds %"struct.agge::font_descriptor", ptr %8, i32 0, i32 1
  %23 = load i32, ptr %22, align 8
  %24 = and i32 %23, -100663297
  %25 = or i32 %24, 0
  store i32 %25, ptr %22, align 8
  %26 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 1
  %27 = getelementptr inbounds %"struct.agge::color", ptr %26, i32 0, i32 0
  store i8 0, ptr %27, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.agge::color", ptr %26, i32 0, i32 1
  store i8 0, ptr %28, align 1, !tbaa !9
  %29 = getelementptr inbounds %"struct.agge::color", ptr %26, i32 0, i32 2
  store i8 0, ptr %29, align 2, !tbaa !10
  %30 = getelementptr inbounds %"struct.agge::color", ptr %26, i32 0, i32 3
  store i8 0, ptr %30, align 1, !tbaa !11
  %31 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 2
  %32 = load i16, ptr %31, align 4
  %33 = and i16 %32, -4
  %34 = or i16 %33, 0
  store i16 %34, ptr %31, align 4
  %35 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 2
  %36 = load i16, ptr %35, align 4
  %37 = and i16 %36, -29
  %38 = or i16 %37, 0
  store i16 %38, ptr %35, align 4
  %39 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 2
  %40 = load i16, ptr %39, align 4
  %41 = and i16 %40, -97
  %42 = or i16 %41, 0
  store i16 %42, ptr %39, align 4
  %43 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 2
  %44 = load i16, ptr %43, align 4
  %45 = and i16 %44, -385
  %46 = or i16 %45, 0
  store i16 %46, ptr %43, align 4
  %47 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 2
  %48 = load i16, ptr %47, align 4
  %49 = and i16 %48, -1537
  %50 = or i16 %49, 0
  store i16 %50, ptr %47, align 4
  %51 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 2
  %52 = load i16, ptr %51, align 4
  %53 = and i16 %52, -6145
  %54 = or i16 %53, 0
  store i16 %54, ptr %51, align 4
  %55 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %55, ptr align 1 %4, i64 4, i1 false), !tbaa.struct !12
  %56 = getelementptr inbounds %"struct.agge::style_modifier", ptr %5, i32 0, i32 2
  %57 = load i16, ptr %56, align 4
  %58 = and i16 %57, -6145
  %59 = or i16 %58, 2048
  store i16 %59, ptr %56, align 4
  invoke void @_ZN4agge14style_modifierC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(46) %0, ptr noundef nonnull align 8 dereferenceable(46) %5)
          to label %60 unwind label %61

60:                                               ; preds = %2
  call void @_ZN4agge14style_modifierD2Ev(ptr noundef nonnull align 8 dereferenceable(46) %5) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %5) #6
  ret void

61:                                               ; preds = %2
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %6, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %7, align 4
  call void @_ZN4agge14style_modifierD2Ev(ptr noundef nonnull align 8 dereferenceable(46) %5) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %5) #6
  br label %65

65:                                               ; preds = %61
  %66 = load ptr, ptr %6, align 8
  %67 = load i32, ptr %7, align 4
  %68 = insertvalue { ptr, i32 } poison, ptr %66, 0
  %69 = insertvalue { ptr, i32 } %68, i32 %67, 1
  resume { ptr, i32 } %69
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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 nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 0}
!6 = !{!"_ZTSN4agge5colorE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!6, !7, i64 1}
!10 = !{!6, !7, i64 2}
!11 = !{!6, !7, i64 3}
!12 = !{i64 0, i64 1, !13, i64 1, i64 1, !13, i64 2, i64 1, !13, i64 3, i64 1, !13}
!13 = !{!7, !7, 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.agge::style_modifier" = type { %"struct.agge::font_descriptor", %"struct.agge::color", i16, [2 x i8] }
%"struct.agge::font_descriptor" = type <{ %"class.std::__cxx11::basic_string", i32, [4 x i8] }>
%"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.agge::color" = type { i8, i8, i8, i8 }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4agge14style_modifierD2Ev(ptr noundef nonnull align 8 dereferenceable(46)) unnamed_addr #1 align 2

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

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

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) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4agge5style10foregroundENS_5colorE(ptr dead_on_unwind noalias writable sret(%"struct.agge::style_modifier") align 8 %0, i32 %1) local_unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.agge::style_modifier", align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %3) #5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  %4 = getelementptr inbounds i8, ptr %3, i64 32
  %5 = load i32, ptr %4, align 8
  %6 = and i32 %5, -134217728
  store i32 %6, ptr %4, align 8
  %7 = getelementptr inbounds i8, ptr %3, i64 40
  %8 = getelementptr inbounds i8, ptr %3, i64 44
  %9 = load i16, ptr %8, align 4
  %10 = and i16 %9, -8192
  store i32 %1, ptr %7, align 8
  %11 = or disjoint i16 %10, 2048
  store i16 %11, ptr %8, align 4
  invoke void @_ZN4agge14style_modifierC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(46) %0, ptr noundef nonnull align 8 dereferenceable(46) %3)
          to label %12 unwind label %13

12:                                               ; preds = %2
  call void @_ZN4agge14style_modifierD2Ev(ptr noundef nonnull align 8 dereferenceable(46) %3) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #5
  ret void

13:                                               ; preds = %2
  %14 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4agge14style_modifierD2Ev(ptr noundef nonnull align 8 dereferenceable(46) %3) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #5
  resume { ptr, i32 } %14
}

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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 = { 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: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass