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

; 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::internal::Shader" = type <{ ptr, i32, [4 x i8] }>
%"class.rmg::internal::Text2DShader" = type { %"class.rmg::internal::Shader.base", i32, i32, i32, i32, i32, i32, i32 }
%"class.rmg::internal::Shader.base" = type <{ ptr, i32 }>

@_ZN3rmg8internal20glGetUniformLocationE = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@_ZN3rmg8internal17glGenVertexArraysE = external global ptr, align 8
@_ZN3rmg8internal17glBindVertexArrayE = external global ptr, align 8
@_ZN3rmg8internal12glGenBuffersE = external global ptr, align 8
@_ZN3rmg8internal12glBindBufferE = external global ptr, align 8
@_ZN3rmg8internal12glBufferDataE = external global ptr, align 8
@_ZN3rmg8internal21glVertexAttribPointerE = external global ptr, align 8
@_ZN3rmg8internal25glEnableVertexAttribArrayE = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1

declare noundef i32 @_ZN3rmg8internal6Shader20compileShaderProgramEPKcS3_(ptr noundef, ptr noundef) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg8internal12Text2DShader4loadEv(ptr noundef nonnull align 8 dereferenceable(40) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca [12 x float], align 16
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = call noundef i32 @_ZN3rmg8internal6Shader20compileShaderProgramEPKcS3_(ptr noundef @.str.5, ptr noundef @.str.6)
  %6 = getelementptr inbounds %"class.rmg::internal::Shader", ptr %4, i32 0, i32 1
  store i32 %5, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !5
  %8 = getelementptr inbounds %"class.rmg::internal::Shader", ptr %4, i32 0, i32 1
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = call noundef i32 %7(i32 noundef %9, ptr noundef @.str.2)
  %11 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 1
  store i32 %10, ptr %11, align 4, !tbaa !12
  %12 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.rmg::internal::Shader", ptr %4, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = call noundef i32 %12(i32 noundef %14, ptr noundef @.str.3)
  %16 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 2
  store i32 %15, ptr %16, align 8, !tbaa !14
  %17 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.rmg::internal::Shader", ptr %4, i32 0, i32 1
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = call noundef i32 %17(i32 noundef %19, ptr noundef @.str.7)
  %21 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 3
  store i32 %20, ptr %21, align 4, !tbaa !15
  %22 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.rmg::internal::Shader", ptr %4, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = call noundef i32 %22(i32 noundef %24, ptr noundef @.str.8)
  %26 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 4
  store i32 %25, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.rmg::internal::Shader", ptr %4, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !9
  %30 = call noundef i32 %27(i32 noundef %29, ptr noundef @.str.9)
  %31 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 5
  store i32 %30, ptr %31, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #4
  call void @llvm.memset.p0.i64(ptr align 16 %3, i8 0, i64 48, i1 false)
  %32 = getelementptr inbounds [12 x float], ptr %3, i32 0, i32 0
  store float 1.000000e+00, ptr %32, align 16
  %33 = getelementptr inbounds [12 x float], ptr %3, i32 0, i32 1
  store float 1.000000e+00, ptr %33, align 4
  %34 = getelementptr inbounds [12 x float], ptr %3, i32 0, i32 3
  store float 1.000000e+00, ptr %34, align 4
  %35 = getelementptr inbounds [12 x float], ptr %3, i32 0, i32 8
  store float 1.000000e+00, ptr %35, align 16
  %36 = getelementptr inbounds [12 x float], ptr %3, i32 0, i32 10
  store float 1.000000e+00, ptr %36, align 8
  %37 = getelementptr inbounds [12 x float], ptr %3, i32 0, i32 11
  store float 1.000000e+00, ptr %37, align 4
  %38 = load ptr, ptr @_ZN3rmg8internal17glGenVertexArraysE, align 8, !tbaa !5
  %39 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 6
  call void %38(i32 noundef 1, ptr noundef %39)
  %40 = load ptr, ptr @_ZN3rmg8internal17glBindVertexArrayE, align 8, !tbaa !5
  %41 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 6
  %42 = load i32, ptr %41, align 8, !tbaa !18
  call void %40(i32 noundef %42)
  %43 = load ptr, ptr @_ZN3rmg8internal12glGenBuffersE, align 8, !tbaa !5
  %44 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 7
  call void %43(i32 noundef 1, ptr noundef %44)
  %45 = load ptr, ptr @_ZN3rmg8internal12glBindBufferE, align 8, !tbaa !5
  %46 = getelementptr inbounds %"class.rmg::internal::Text2DShader", ptr %4, i32 0, i32 7
  %47 = load i32, ptr %46, align 4, !tbaa !19
  call void %45(i32 noundef 34962, i32 noundef %47)
  %48 = load ptr, ptr @_ZN3rmg8internal12glBufferDataE, align 8, !tbaa !5
  %49 = getelementptr inbounds [12 x float], ptr %3, i64 0, i64 0
  call void %48(i32 noundef 34962, i64 noundef 48, ptr noundef %49, i32 noundef 35044)
  %50 = load ptr, ptr @_ZN3rmg8internal21glVertexAttribPointerE, align 8, !tbaa !5
  call void %50(i32 noundef 0, i32 noundef 2, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 8, ptr noundef null)
  %51 = load ptr, ptr @_ZN3rmg8internal25glEnableVertexAttribArrayE, align 8, !tbaa !5
  call void %51(i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #4
  ret void
}

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !11, i64 8}
!10 = !{!"_ZTSN3rmg8internal6ShaderE", !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 12}
!13 = !{!"_ZTSN3rmg8internal12Text2DShaderE", !10, i64 0, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36}
!14 = !{!13, !11, i64 16}
!15 = !{!13, !11, i64 20}
!16 = !{!13, !11, i64 24}
!17 = !{!13, !11, i64 28}
!18 = !{!13, !11, i64 32}
!19 = !{!13, !11, i64 36}


; 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"

@_ZN3rmg8internal20glGetUniformLocationE = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@_ZN3rmg8internal17glGenVertexArraysE = external local_unnamed_addr global ptr, align 8
@_ZN3rmg8internal17glBindVertexArrayE = external local_unnamed_addr global ptr, align 8
@_ZN3rmg8internal12glGenBuffersE = external local_unnamed_addr global ptr, align 8
@_ZN3rmg8internal12glBindBufferE = external local_unnamed_addr global ptr, align 8
@_ZN3rmg8internal12glBufferDataE = external local_unnamed_addr global ptr, align 8
@_ZN3rmg8internal21glVertexAttribPointerE = external local_unnamed_addr global ptr, align 8
@_ZN3rmg8internal25glEnableVertexAttribArrayE = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1

declare noundef i32 @_ZN3rmg8internal6Shader20compileShaderProgramEPKcS3_(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg8internal12Text2DShader4loadEv(ptr noundef nonnull align 8 dereferenceable(40) %0) unnamed_addr #2 align 2 {
  %2 = alloca [12 x float], align 16
  %3 = tail call noundef i32 @_ZN3rmg8internal6Shader20compileShaderProgramEPKcS3_(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6)
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %3, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !10
  %6 = tail call noundef i32 %5(i32 noundef %3, ptr noundef nonnull @.str.2)
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %6, ptr %7, align 4, !tbaa !12
  %8 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !10
  %9 = load i32, ptr %4, align 8, !tbaa !5
  %10 = tail call noundef i32 %8(i32 noundef %9, ptr noundef nonnull @.str.3)
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %10, ptr %11, align 8, !tbaa !14
  %12 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !10
  %13 = load i32, ptr %4, align 8, !tbaa !5
  %14 = tail call noundef i32 %12(i32 noundef %13, ptr noundef nonnull @.str.7)
  %15 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %14, ptr %15, align 4, !tbaa !15
  %16 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !10
  %17 = load i32, ptr %4, align 8, !tbaa !5
  %18 = tail call noundef i32 %16(i32 noundef %17, ptr noundef nonnull @.str.8)
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %18, ptr %19, align 8, !tbaa !16
  %20 = load ptr, ptr @_ZN3rmg8internal20glGetUniformLocationE, align 8, !tbaa !10
  %21 = load i32, ptr %4, align 8, !tbaa !5
  %22 = tail call noundef i32 %20(i32 noundef %21, ptr noundef nonnull @.str.9)
  %23 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %22, ptr %23, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(48) %2, i8 0, i64 48, i1 false)
  store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr %2, align 16
  %24 = getelementptr inbounds i8, ptr %2, i64 12
  store float 1.000000e+00, ptr %24, align 4
  %25 = getelementptr inbounds i8, ptr %2, i64 32
  store float 1.000000e+00, ptr %25, align 16
  %26 = getelementptr inbounds i8, ptr %2, i64 40
  store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr %26, align 8
  %27 = load ptr, ptr @_ZN3rmg8internal17glGenVertexArraysE, align 8, !tbaa !10
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void %27(i32 noundef 1, ptr noundef nonnull %28)
  %29 = load ptr, ptr @_ZN3rmg8internal17glBindVertexArrayE, align 8, !tbaa !10
  %30 = load i32, ptr %28, align 8, !tbaa !18
  tail call void %29(i32 noundef %30)
  %31 = load ptr, ptr @_ZN3rmg8internal12glGenBuffersE, align 8, !tbaa !10
  %32 = getelementptr inbounds i8, ptr %0, i64 36
  tail call void %31(i32 noundef 1, ptr noundef nonnull %32)
  %33 = load ptr, ptr @_ZN3rmg8internal12glBindBufferE, align 8, !tbaa !10
  %34 = load i32, ptr %32, align 4, !tbaa !19
  tail call void %33(i32 noundef 34962, i32 noundef %34)
  %35 = load ptr, ptr @_ZN3rmg8internal12glBufferDataE, align 8, !tbaa !10
  call void %35(i32 noundef 34962, i64 noundef 48, ptr noundef nonnull %2, i32 noundef 35044)
  %36 = load ptr, ptr @_ZN3rmg8internal21glVertexAttribPointerE, align 8, !tbaa !10
  call void %36(i32 noundef 0, i32 noundef 2, i32 noundef 5126, i8 noundef zeroext 0, i32 noundef 8, ptr noundef null)
  %37 = load ptr, ptr @_ZN3rmg8internal25glEnableVertexAttribArrayE, align 8, !tbaa !10
  call void %37(i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #4
  ret void
}

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !7, i64 8}
!6 = !{!"_ZTSN3rmg8internal6ShaderE", !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !7, i64 12}
!13 = !{!"_ZTSN3rmg8internal12Text2DShaderE", !6, i64 0, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36}
!14 = !{!13, !7, i64 16}
!15 = !{!13, !7, i64 20}
!16 = !{!13, !7, i64 24}
!17 = !{!13, !7, i64 28}
!18 = !{!13, !7, i64 32}
!19 = !{!13, !7, i64 36}


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