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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare void @_ZN3rmg8internal7PendingD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg8Sprite2DC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(144) %1) unnamed_addr #2 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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3rmg8Object2DC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(108) %7, ptr noundef nonnull align 8 dereferenceable(108) %8)
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN3rmg8Sprite2DE, i32 0, i32 0, i32 2), ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %7, i32 0, i32 1
  store ptr null, ptr %9, align 8, !tbaa !11
  %10 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %7, i32 0, i32 2
  store ptr null, ptr %10, align 8, !tbaa !25
  %11 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %7, i32 0, i32 3
  call void @_ZN3rmg8internal7PendingC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %12, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %7, i32 0, i32 1
  store ptr %14, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !25
  %19 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %7, i32 0, i32 2
  store ptr %18, ptr %19, align 8, !tbaa !25
  %20 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %7, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !25
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %28

23:                                               ; preds = %2
  %24 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %7, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !25
  %26 = load i32, ptr %25, align 4, !tbaa !26
  %27 = add i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !26
  br label %28

28:                                               ; preds = %23, %2
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %29, i32 0, i32 3
  %31 = getelementptr inbounds %"class.rmg::Sprite2D", ptr %7, i32 0, i32 3
  %32 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg8internal7PendingaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %31, ptr noundef nonnull align 8 dereferenceable(16) %30)
          to label %33 unwind label %34

33:                                               ; preds = %28
  ret void

34:                                               ; preds = %28
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %5, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %6, align 4
  call void @_ZN3rmg8internal7PendingD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #5
  call void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(108) %7) #5
  br label %38

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg8internal7PendingaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 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 = { nounwind "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 = { 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 = { "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)"}
!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, !6, i64 112}
!12 = !{!"_ZTSN3rmg8Sprite2DE", !13, i64 0, !6, i64 112, !6, i64 120, !24, i64 128}
!13 = !{!"_ZTSN3rmg8Object2DE", !14, i64 0, !7, i64 48, !20, i64 52, !21, i64 56, !22, i64 60, !17, i64 96, !23, i64 100}
!14 = !{!"_ZTSN3rmg6ObjectE", !15, i64 8, !6, i64 16, !16, i64 24, !18, i64 40, !19, i64 44}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSN3rmg9ColorRGBAE", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12}
!17 = !{!"float", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"_ZTSN3rmg10ObjectTypeE", !7, i64 0}
!20 = !{!"_ZTSN3rmg9AlignmentE", !7, i64 0}
!21 = !{!"_ZTSN3rmg12Object2DTypeE", !7, i64 0}
!22 = !{!"_ZTSN3rmg4Mat3E", !7, i64 0}
!23 = !{!"_ZTSN3rmg4Vec2E", !7, i64 0}
!24 = !{!"_ZTSN3rmg8internal7PendingE", !6, i64 0, !6, i64 8}
!25 = !{!12, !6, i64 120}
!26 = !{!27, !27, i64 0}
!27 = !{!"int", !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"

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare void @_ZN3rmg8internal7PendingD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg8Sprite2DC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(144) %1) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN3rmg8Object2DC2ERKS0_(ptr noundef nonnull align 8 dereferenceable(108) %0, ptr noundef nonnull align 8 dereferenceable(108) %1)
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN3rmg8Sprite2DE, i64 16), ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 112
  %4 = getelementptr inbounds i8, ptr %0, i64 120
  %5 = getelementptr inbounds i8, ptr %0, i64 128
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  tail call void @_ZN3rmg8internal7PendingC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  %6 = getelementptr inbounds i8, ptr %1, i64 112
  %7 = load ptr, ptr %6, align 8, !tbaa !8
  store ptr %7, ptr %3, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %1, i64 120
  %9 = load ptr, ptr %8, align 8, !tbaa !24
  store ptr %9, ptr %4, align 8, !tbaa !24
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %13, label %10

10:                                               ; preds = %2
  %11 = load i32, ptr %9, align 4, !tbaa !25
  %12 = add i32 %11, 1
  store i32 %12, ptr %9, align 4, !tbaa !25
  br label %13

13:                                               ; preds = %10, %2
  %14 = getelementptr inbounds i8, ptr %1, i64 128
  %15 = invoke noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg8internal7PendingaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %14)
          to label %16 unwind label %17

16:                                               ; preds = %13
  ret void

17:                                               ; preds = %13
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN3rmg8internal7PendingD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  tail call void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(108) %0) #6
  resume { ptr, i32 } %18
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg8internal7PendingaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, 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 = { nounwind "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 = { 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 = { "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: write) }
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, !14, i64 112}
!9 = !{!"_ZTSN3rmg8Sprite2DE", !10, i64 0, !14, i64 112, !14, i64 120, !23, i64 128}
!10 = !{!"_ZTSN3rmg8Object2DE", !11, i64 0, !13, i64 48, !19, i64 52, !20, i64 56, !21, i64 60, !16, i64 96, !22, i64 100}
!11 = !{!"_ZTSN3rmg6ObjectE", !12, i64 8, !14, i64 16, !15, i64 24, !17, i64 40, !18, i64 44}
!12 = !{!"long", !13, i64 0}
!13 = !{!"omnipotent char", !7, i64 0}
!14 = !{!"any pointer", !13, i64 0}
!15 = !{!"_ZTSN3rmg9ColorRGBAE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12}
!16 = !{!"float", !13, i64 0}
!17 = !{!"bool", !13, i64 0}
!18 = !{!"_ZTSN3rmg10ObjectTypeE", !13, i64 0}
!19 = !{!"_ZTSN3rmg9AlignmentE", !13, i64 0}
!20 = !{!"_ZTSN3rmg12Object2DTypeE", !13, i64 0}
!21 = !{!"_ZTSN3rmg4Mat3E", !13, i64 0}
!22 = !{!"_ZTSN3rmg4Vec2E", !13, i64 0}
!23 = !{!"_ZTSN3rmg8internal7PendingE", !14, i64 0, !14, i64 8}
!24 = !{!9, !14, i64 120}
!25 = !{!26, !26, i64 0}
!26 = !{!"int", !13, i64 0}


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