; LLVM IR from Aeternum-Veritas/Merry :: asm/src/codegen.ll (ZN4masm7CodeGen4excgEPNS_11NodeTwoRegrEm)

; 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.masm::GenBinary" = type { %union.anon.84 }
%union.anon.84 = type { i64 }
%struct.anon = type { i8, i8, i8, i8, i8, i8, i8, i8 }
%"struct.masm::NodeTwoRegr" = type { i32, i32 }
%"class.masm::CodeGen" = type { ptr, ptr, %"class.std::vector.79", ptr, ptr, %"class.std::vector.85", %"class.std::unordered_map.90", ptr, ptr }
%"class.std::vector.79" = type { %"struct.std::_Vector_base.80" }
%"struct.std::_Vector_base.80" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.85" = type { %"struct.std::_Vector_base.86" }
%"struct.std::_Vector_base.86" = type { %"struct.std::_Vector_base<masm::GenBinary, std::allocator<masm::GenBinary>>::_Vector_impl" }
%"struct.std::_Vector_base<masm::GenBinary, std::allocator<masm::GenBinary>>::_Vector_impl" = type { %"struct.std::_Vector_base<masm::GenBinary, std::allocator<masm::GenBinary>>::_Vector_impl_data" }
%"struct.std::_Vector_base<masm::GenBinary, std::allocator<masm::GenBinary>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::unordered_map.90" = type { %"class.std::_Hashtable.91" }
%"class.std::_Hashtable.91" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN4masm9GenBinaryESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4masm7CodeGen4excgEPNS_11NodeTwoRegrEm(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef %1, i64 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"struct.masm::GenBinary", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @_ZN4masm9GenBinaryC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  %9 = load i64, ptr %6, align 8, !tbaa !9
  %10 = trunc i64 %9 to i8
  %11 = getelementptr inbounds %"struct.masm::GenBinary", ptr %7, i32 0, i32 0
  %12 = getelementptr inbounds %struct.anon, ptr %11, i32 0, i32 7
  store i8 %10, ptr %12, align 1, !tbaa !11
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.masm::NodeTwoRegr", ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = trunc i32 %15 to i8
  %17 = getelementptr inbounds %"struct.masm::GenBinary", ptr %7, i32 0, i32 0
  %18 = getelementptr inbounds %struct.anon, ptr %17, i32 0, i32 0
  store i8 %16, ptr %18, align 8, !tbaa !11
  %19 = getelementptr inbounds %"struct.masm::GenBinary", ptr %7, i32 0, i32 0
  %20 = getelementptr inbounds %struct.anon, ptr %19, i32 0, i32 0
  %21 = load i8, ptr %20, align 8, !tbaa !11
  %22 = zext i8 %21 to i32
  %23 = shl i32 %22, 4
  %24 = trunc i32 %23 to i8
  store i8 %24, ptr %20, align 8, !tbaa !11
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.masm::NodeTwoRegr", ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !15
  %28 = getelementptr inbounds %"struct.masm::GenBinary", ptr %7, i32 0, i32 0
  %29 = getelementptr inbounds %struct.anon, ptr %28, i32 0, i32 0
  %30 = load i8, ptr %29, align 8, !tbaa !11
  %31 = zext i8 %30 to i32
  %32 = or i32 %31, %27
  %33 = trunc i32 %32 to i8
  store i8 %33, ptr %29, align 8, !tbaa !11
  %34 = getelementptr inbounds %"class.masm::CodeGen", ptr %8, i32 0, i32 5
  call void @_ZNSt6vectorIN4masm9GenBinaryESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %34, ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTSN4masm11NodeTwoRegrE", !14, i64 0, !14, i64 4}
!14 = !{!"_ZTSN4masm8RegisterE", !7, i64 0}
!15 = !{!13, !14, i64 4}


; 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.masm::GenBinary" = type { %union.anon.84 }
%union.anon.84 = type { i64 }

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN4masm9GenBinaryESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4masm7CodeGen4excgEPNS_11NodeTwoRegrEm(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %"struct.masm::GenBinary", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @_ZN4masm9GenBinaryC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  %5 = trunc i64 %2 to i8
  %6 = getelementptr inbounds i8, ptr %4, i64 7
  store i8 %5, ptr %6, align 1, !tbaa !5
  %7 = load i32, ptr %1, align 4, !tbaa !8
  %.tr = trunc i32 %7 to i8
  %8 = shl i8 %.tr, 4
  %9 = getelementptr inbounds i8, ptr %1, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = trunc i32 %10 to i8
  %12 = or i8 %8, %11
  store i8 %12, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 56
  call void @_ZNSt6vectorIN4masm9GenBinaryESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"_ZTSN4masm11NodeTwoRegrE", !10, i64 0, !10, i64 4}
!10 = !{!"_ZTSN4masm8RegisterE", !6, i64 0}
!11 = !{!9, !10, i64 4}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass