; LLVM IR from achilles288/robot-monitor-graphics :: src/base/internal/texture_load.ll (ZN3rmg8internal7TextureC2Ev)

; 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::ColorRGBA" = type { float, float, float, float }
%"class.rmg::internal::Texture" = type { ptr, i32, i32, i32, i32, i32, i32, %"struct.rmg::Vec2", %"struct.rmg::ColorRGBA", float, float, float, float }
%"struct.rmg::Vec2" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { float, float }

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

; 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: mustprogress uwtable
define dso_local void @_ZN3rmg8internal7TextureC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.rmg::ColorRGBA", align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN3rmg8internal7TextureE, i32 0, i32 0, i32 2), ptr %4, align 8, !tbaa !9
  %5 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 7
  call void @_ZN3rmg4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %6 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 8
  call void @_ZN3rmg9ColorRGBAC2Ev(ptr noundef nonnull align 4 dereferenceable(16) %6) #6
  %7 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 1
  store i32 0, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 2
  store i32 0, ptr %8, align 4, !tbaa !17
  %9 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 3
  store i32 0, ptr %9, align 8, !tbaa !18
  %10 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 4
  store i32 0, ptr %10, align 4, !tbaa !19
  %11 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 5
  store i32 0, ptr %11, align 8, !tbaa !20
  %12 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 6
  store i32 0, ptr %12, align 4, !tbaa !21
  %13 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 7
  %14 = getelementptr inbounds %"struct.rmg::Vec2", ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.anon, ptr %14, i32 0, i32 0
  store float 1.000000e+00, ptr %15, align 8, !tbaa !22
  %16 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 7
  %17 = getelementptr inbounds %"struct.rmg::Vec2", ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.anon, ptr %17, i32 0, i32 1
  store float 1.000000e+00, ptr %18, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #6
  call void @_ZN3rmg9ColorRGBAC1Efff(ptr noundef nonnull align 4 dereferenceable(16) %3, float noundef 1.000000e+00, float noundef 1.000000e+00, float noundef 1.000000e+00)
  %19 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 4 %3, i64 16, i1 false), !tbaa.struct !23
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #6
  %20 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 9
  store float 0.000000e+00, ptr %20, align 8, !tbaa !25
  %21 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 10
  store float 0x3FE3333340000000, ptr %21, align 4, !tbaa !26
  %22 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 11
  store float 0x3FE3333340000000, ptr %22, align 8, !tbaa !27
  %23 = getelementptr inbounds %"class.rmg::internal::Texture", ptr %4, i32 0, i32 12
  store float 0.000000e+00, ptr %23, align 4, !tbaa !28
  ret void
}

; 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 nounwind uwtable
declare dso_local void @_ZN3rmg9ColorRGBAC2Ev(ptr noundef nonnull align 4 dereferenceable(16)) unnamed_addr #3 align 2

declare void @_ZN3rmg9ColorRGBAC1Efff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef) unnamed_addr #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #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: readwrite) }
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, !13, i64 8}
!12 = !{!"_ZTSN3rmg8internal7TextureE", !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !14, i64 32, !15, i64 40, !16, i64 56, !16, i64 60, !16, i64 64, !16, i64 68}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN3rmg4Vec2E", !7, i64 0}
!15 = !{!"_ZTSN3rmg9ColorRGBAE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12}
!16 = !{!"float", !7, i64 0}
!17 = !{!12, !13, i64 12}
!18 = !{!12, !13, i64 16}
!19 = !{!12, !13, i64 20}
!20 = !{!12, !13, i64 24}
!21 = !{!12, !13, i64 28}
!22 = !{!7, !7, i64 0}
!23 = !{i64 0, i64 4, !24, i64 4, i64 4, !24, i64 8, i64 4, !24, i64 12, i64 4, !24}
!24 = !{!16, !16, i64 0}
!25 = !{!12, !16, i64 56}
!26 = !{!12, !16, i64 60}
!27 = !{!12, !16, i64 64}
!28 = !{!12, !16, i64 68}


; 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::ColorRGBA" = type { float, float, float, float }

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

; 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: mustprogress uwtable
define dso_local void @_ZN3rmg8internal7TextureC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %0) unnamed_addr #1 align 2 {
  %2 = alloca %"struct.rmg::ColorRGBA", align 4
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN3rmg8internal7TextureE, i64 16), ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZN3rmg4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZN3rmg9ColorRGBAC2Ev(ptr noundef nonnull align 4 dereferenceable(16) %4) #7
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %5, i8 0, i64 24, i1 false)
  store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr %3, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #7
  call void @_ZN3rmg9ColorRGBAC1Efff(ptr noundef nonnull align 4 dereferenceable(16) %2, float noundef 1.000000e+00, float noundef 1.000000e+00, float noundef 1.000000e+00)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(16) %2, i64 16, i1 false), !tbaa.struct !10
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #7
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  store <4 x float> <float 0.000000e+00, float 0x3FE3333340000000, float 0x3FE3333340000000, float 0.000000e+00>, ptr %6, align 8, !tbaa !11
  ret void
}

; 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 nounwind uwtable
declare dso_local void @_ZN3rmg9ColorRGBAC2Ev(ptr noundef nonnull align 4 dereferenceable(16)) unnamed_addr #3 align 2

declare void @_ZN3rmg9ColorRGBAC1Efff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef) unnamed_addr #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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, !9, i64 0}
!9 = !{!"omnipotent char", !7, i64 0}
!10 = !{i64 0, i64 4, !11, i64 4, i64 4, !11, i64 8, i64 4, !11, i64 12, i64 4, !11}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SLPVectorizerPass,SROAPass,TailCallElimPass