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

; 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

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

12:                                               ; preds = %1
  %13 = getelementptr inbounds %"class.rmg::Object2D", ptr %7, i32 0, i32 7
  invoke void @_ZN3rmg4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %13)
          to label %14 unwind label %20

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

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

18:                                               ; preds = %15
  %19 = getelementptr inbounds %"class.rmg::Object2D", ptr %7, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !28
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  ret void

20:                                               ; preds = %12, %1
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %3, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %4, align 4
  br label %32

24:                                               ; preds = %14
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %3, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 36, ptr %5) #6
  br label %32

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

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

33:                                               ; preds = %32
  %34 = load ptr, ptr %3, align 8
  %35 = load i32, ptr %4, align 4
  %36 = insertvalue { ptr, i32 } poison, ptr %34, 0
  %37 = insertvalue { ptr, i32 } %36, i32 %35, 1
  resume { ptr, i32 } %37
}

declare void @_ZN3rmg6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1

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

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

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

; 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) #4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #5 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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}


; 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

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

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

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

13:                                               ; preds = %1
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %17

15:                                               ; preds = %8
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %2) #6
  br label %17

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

declare void @_ZN3rmg6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1

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

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

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

; 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) #4

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #5 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 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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}


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