; LLVM IR from achilles288/robot-monitor-graphics :: src/base/object2d.ll (ZN3rmg8Object2DC2EPNS_7ContextE)

; 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.rmg::Mat3" = type { %union.anon }
%union.anon = type { [3 x [3 x float]] }
%"struct.rmg::Vec2" = type { %union.anon.0 }
%union.anon.0 = type { %struct.anon }
%struct.anon = type { float, float }
%"class.rmg::Object2D" = type <{ %"class.rmg::Object", i8, [3 x i8], i32, i32, %"struct.rmg::Mat3", float, %"struct.rmg::Vec2", [4 x i8] }>
%"class.rmg::Object" = type { ptr, i64, ptr, %"struct.rmg::ColorRGBA", i8, i32 }
%"struct.rmg::ColorRGBA" = type { float, float, float, float }

@_ZTVN3rmg8Object2DE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

declare void @_ZN3rmg4Mat3C1Ev(ptr noundef nonnull align 4 dereferenceable(36)) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8)) 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: 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) #3

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg8Object2DC2EPNS_7ContextE(ptr noundef nonnull align 8 dereferenceable(108) %0, ptr noundef %1) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"struct.rmg::Mat3", align 4
  %8 = alloca %"struct.rmg::Vec2", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3rmg6ObjectC2EPNS_7ContextE(ptr noundef nonnull align 8 dereferenceable(48) %9, ptr noundef %10)
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN3rmg8Object2DE, i32 0, i32 0, i32 2), ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.rmg::Object2D", ptr %9, i32 0, i32 1
  store i8 0, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.rmg::Object2D", ptr %9, i32 0, i32 3
  store i32 4, ptr %12, align 4, !tbaa !23
  %13 = getelementptr inbounds %"class.rmg::Object2D", ptr %9, i32 0, i32 4
  store i32 0, ptr %13, align 8, !tbaa !24
  %14 = getelementptr inbounds %"class.rmg::Object2D", ptr %9, i32 0, i32 5
  invoke void @_ZN3rmg4Mat3C1Ev(ptr noundef nonnull align 4 dereferenceable(36) %14)
          to label %15 unwind label %24

15:                                               ; preds = %2
  %16 = getelementptr inbounds %"class.rmg::Object2D", ptr %9, i32 0, i32 7
  invoke void @_ZN3rmg4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %16)
          to label %17 unwind label %24

17:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 36, ptr %7) #6
  invoke void @_ZN3rmg4Mat3C1Ev(ptr noundef nonnull align 4 dereferenceable(36) %7)
          to label %18 unwind label %28

18:                                               ; preds = %17
  %19 = getelementptr inbounds %"class.rmg::Object2D", ptr %9, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %7, i64 36, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.end.p0(i64 36, ptr %7) #6
  %20 = getelementptr inbounds %"class.rmg::Object2D", ptr %9, i32 0, i32 6
  store float 0.000000e+00, ptr %20, align 8, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  invoke void @_ZN3rmg4Vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %8, float noundef 1.000000e+00, float noundef 1.000000e+00)
          to label %21 unwind label %32

21:                                               ; preds = %18
  %22 = getelementptr inbounds %"class.rmg::Object2D", ptr %9, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !28
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %23 = getelementptr inbounds %"class.rmg::Object", ptr %9, i32 0, i32 5
  store i32 1, ptr %23, align 4, !tbaa !29
  ret void

24:                                               ; preds = %15, %2
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %5, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %6, align 4
  br label %36

28:                                               ; preds = %17
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %5, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 36, ptr %7) #6
  br label %36

32:                                               ; preds = %18
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %5, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %36

36:                                               ; preds = %32, %28, %24
  call void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %9) #6
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %5, align 8
  %39 = load i32, ptr %6, align 4
  %40 = insertvalue { ptr, i32 } poison, ptr %38, 0
  %41 = insertvalue { ptr, i32 } %40, i32 %39, 1
  resume { ptr, i32 } %41
}

declare void @_ZN3rmg6ObjectC2EPNS_7ContextE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) unnamed_addr #0

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

attributes #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !7, i64 48}
!12 = !{!"_ZTSN3rmg8Object2DE", !13, i64 0, !7, i64 48, !19, i64 52, !20, i64 56, !21, i64 60, !16, i64 96, !22, i64 100}
!13 = !{!"_ZTSN3rmg6ObjectE", !14, i64 8, !6, i64 16, !15, i64 24, !17, i64 40, !18, i64 44}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN3rmg9ColorRGBAE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12}
!16 = !{!"float", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSN3rmg10ObjectTypeE", !7, i64 0}
!19 = !{!"_ZTSN3rmg9AlignmentE", !7, i64 0}
!20 = !{!"_ZTSN3rmg12Object2DTypeE", !7, i64 0}
!21 = !{!"_ZTSN3rmg4Mat3E", !7, i64 0}
!22 = !{!"_ZTSN3rmg4Vec2E", !7, i64 0}
!23 = !{!12, !19, i64 52}
!24 = !{!12, !20, i64 56}
!25 = !{i64 0, i64 36, !26}
!26 = !{!7, !7, i64 0}
!27 = !{!12, !16, i64 96}
!28 = !{i64 0, i64 8, !26}
!29 = !{!13, !18, i64 44}


; 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.rmg::Mat3" = type { %union.anon }
%union.anon = type { [3 x [3 x float]] }
%"struct.rmg::Vec2" = type { %union.anon.0 }
%union.anon.0 = type { %struct.anon }
%struct.anon = type { float, float }

@_ZTVN3rmg8Object2DE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

declare void @_ZN3rmg4Mat3C1Ev(ptr noundef nonnull align 4 dereferenceable(36)) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8)) 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: mustprogress 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) #3

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg8Object2DC2EPNS_7ContextE(ptr noundef nonnull align 8 dereferenceable(108) %0, ptr noundef %1) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.rmg::Mat3", align 4
  %4 = alloca %"struct.rmg::Vec2", align 8
  tail call void @_ZN3rmg6ObjectC2EPNS_7ContextE(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1)
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN3rmg8Object2DE, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  store i8 0, ptr %5, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 4, ptr %6, align 4, !tbaa !22
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 0, ptr %7, align 8, !tbaa !23
  %8 = getelementptr inbounds i8, ptr %0, i64 60
  invoke void @_ZN3rmg4Mat3C1Ev(ptr noundef nonnull align 4 dereferenceable(36) %8)
          to label %9 unwind label %15

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 100
  tail call void @_ZN3rmg4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %10)
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %3) #6
  invoke void @_ZN3rmg4Mat3C1Ev(ptr noundef nonnull align 4 dereferenceable(36) %3)
          to label %11 unwind label %17

11:                                               ; preds = %9
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(36) %8, ptr noundef nonnull align 4 dereferenceable(36) %3, i64 36, i1 false), !tbaa.struct !24
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %3) #6
  %12 = getelementptr inbounds i8, ptr %0, i64 96
  store float 0.000000e+00, ptr %12, align 8, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @_ZN3rmg4Vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %4, float noundef 1.000000e+00, float noundef 1.000000e+00)
  %13 = load i64, ptr %4, align 8, !tbaa !25
  store i64 %13, ptr %10, align 4, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %14 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 1, ptr %14, align 4, !tbaa !27
  ret void

15:                                               ; preds = %2
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %19

17:                                               ; preds = %9
  %18 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %3) #6
  br label %19

19:                                               ; preds = %17, %15
  %.pn = phi { ptr, i32 } [ %18, %17 ], [ %16, %15 ]
  call void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0) #6
  resume { ptr, i32 } %.pn
}

declare void @_ZN3rmg6ObjectC2EPNS_7ContextE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) unnamed_addr #0

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

attributes #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 48}
!9 = !{!"_ZTSN3rmg8Object2DE", !10, i64 0, !12, i64 48, !18, i64 52, !19, i64 56, !20, i64 60, !15, i64 96, !21, i64 100}
!10 = !{!"_ZTSN3rmg6ObjectE", !11, i64 8, !13, i64 16, !14, i64 24, !16, i64 40, !17, i64 44}
!11 = !{!"long", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"any pointer", !12, i64 0}
!14 = !{!"_ZTSN3rmg9ColorRGBAE", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!15 = !{!"float", !12, i64 0}
!16 = !{!"bool", !12, i64 0}
!17 = !{!"_ZTSN3rmg10ObjectTypeE", !12, i64 0}
!18 = !{!"_ZTSN3rmg9AlignmentE", !12, i64 0}
!19 = !{!"_ZTSN3rmg12Object2DTypeE", !12, i64 0}
!20 = !{!"_ZTSN3rmg4Mat3E", !12, i64 0}
!21 = !{!"_ZTSN3rmg4Vec2E", !12, i64 0}
!22 = !{!9, !18, i64 52}
!23 = !{!9, !19, i64 56}
!24 = !{i64 0, i64 36, !25}
!25 = !{!12, !12, i64 0}
!26 = !{!9, !15, i64 96}
!27 = !{!10, !17, i64 44}


; Effective O3 passes: EarlyCSEPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass