; LLVM IR from VTIvanov20/eight-ball-pool :: src/sprite.ll (ZN6Sprite4DrawEv)

; 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.Texture = type { i32, i32, i32, i32, i32 }
%struct.Vector2 = type { float, float }
%struct.Color = type { i8, i8, i8, i8 }
%class.Sprite = type { %"class.DrawableManager::Drawable.base", %struct.Vector2, %struct.Texture, float, float }
%"class.DrawableManager::Drawable.base" = type <{ ptr, i32 }>

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Sprite4DrawEv(ptr noundef nonnull align 8 dereferenceable(48) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.Texture, align 8
  %4 = alloca %struct.Vector2, align 4
  %5 = alloca %struct.Color, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = getelementptr inbounds %class.Sprite, ptr %6, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %7, i64 20, i1 false), !tbaa.struct !9
  %8 = getelementptr inbounds %struct.Vector2, ptr %4, i32 0, i32 0
  %9 = getelementptr inbounds %class.Sprite, ptr %6, i32 0, i32 1
  %10 = getelementptr inbounds %struct.Vector2, ptr %9, i32 0, i32 0
  %11 = load float, ptr %10, align 4, !tbaa !12
  store float %11, ptr %8, align 4, !tbaa !18
  %12 = getelementptr inbounds %struct.Vector2, ptr %4, i32 0, i32 1
  %13 = getelementptr inbounds %class.Sprite, ptr %6, i32 0, i32 1
  %14 = getelementptr inbounds %struct.Vector2, ptr %13, i32 0, i32 1
  %15 = load float, ptr %14, align 4, !tbaa !19
  store float %15, ptr %12, align 4, !tbaa !20
  %16 = getelementptr inbounds %class.Sprite, ptr %6, i32 0, i32 4
  %17 = load float, ptr %16, align 4, !tbaa !21
  %18 = getelementptr inbounds %class.Sprite, ptr %6, i32 0, i32 3
  %19 = load float, ptr %18, align 8, !tbaa !22
  %20 = getelementptr inbounds %struct.Color, ptr %5, i32 0, i32 0
  store i8 -1, ptr %20, align 1, !tbaa !23
  %21 = getelementptr inbounds %struct.Color, ptr %5, i32 0, i32 1
  store i8 -1, ptr %21, align 1, !tbaa !25
  %22 = getelementptr inbounds %struct.Color, ptr %5, i32 0, i32 2
  store i8 -1, ptr %22, align 1, !tbaa !26
  %23 = getelementptr inbounds %struct.Color, ptr %5, i32 0, i32 3
  store i8 -1, ptr %23, align 1, !tbaa !27
  %24 = load <2 x float>, ptr %4, align 4
  %25 = load i32, ptr %5, align 1
  call void @DrawTextureEx(ptr noundef byval(%struct.Texture) align 8 %3, <2 x float> %24, float noundef %17, float noundef %19, i32 %25)
  ret void
}

declare void @DrawTextureEx(ptr noundef byval(%struct.Texture) align 8, <2 x float>, float noundef, float noundef, i32) #1

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10, i64 12, i64 4, !10, i64 16, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !16, i64 12}
!13 = !{!"_ZTS6Sprite", !14, i64 0, !15, i64 12, !17, i64 20, !16, i64 40, !16, i64 44}
!14 = !{!"_ZTSN15DrawableManager8DrawableE", !11, i64 8}
!15 = !{!"_ZTS7Vector2", !16, i64 0, !16, i64 4}
!16 = !{!"float", !7, i64 0}
!17 = !{!"_ZTS7Texture", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!18 = !{!15, !16, i64 0}
!19 = !{!13, !16, i64 16}
!20 = !{!15, !16, i64 4}
!21 = !{!13, !16, i64 44}
!22 = !{!13, !16, i64 40}
!23 = !{!24, !7, i64 0}
!24 = !{!"_ZTS5Color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!25 = !{!24, !7, i64 1}
!26 = !{!24, !7, i64 2}
!27 = !{!24, !7, i64 3}


; 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.Texture = type { i32, i32, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Sprite4DrawEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0) unnamed_addr #0 align 2 {
  %2 = alloca %struct.Texture, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %2, ptr noundef nonnull align 4 dereferenceable(20) %3, i64 20, i1 false), !tbaa.struct !5
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load <4 x float>, ptr %4, align 4
  %.sroa.01.4.vec.insert = shufflevector <4 x float> %5, <4 x float> poison, <2 x i32> <i32 0, i32 1>
  %6 = getelementptr inbounds i8, ptr %0, i64 44
  %7 = load float, ptr %6, align 4, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = load float, ptr %8, align 8, !tbaa !16
  tail call void @DrawTextureEx(ptr noundef nonnull byval(%struct.Texture) align 8 %2, <2 x float> %.sroa.01.4.vec.insert, float noundef %7, float noundef %9, i32 -1)
  ret void
}

declare void @DrawTextureEx(ptr noundef byval(%struct.Texture) align 8, <2 x float>, float noundef, float noundef, i32) local_unnamed_addr #1

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 4, !6, i64 16, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !14, i64 44}
!11 = !{!"_ZTS6Sprite", !12, i64 0, !13, i64 12, !15, i64 20, !14, i64 40, !14, i64 44}
!12 = !{!"_ZTSN15DrawableManager8DrawableE", !7, i64 8}
!13 = !{!"_ZTS7Vector2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !8, i64 0}
!15 = !{!"_ZTS7Texture", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16}
!16 = !{!11, !14, i64 40}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass,VectorCombinePass