; LLVM IR from achilles288/robot-monitor-graphics :: src/base/internal (shadow_map_shader)

; 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::Vec3" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { float, float, float }
%"class.rmg::internal::ShadowMapShader" = type { %"class.rmg::internal::Shader.base", %"class.rmg::Camera", %"struct.rmg::Vec3", %"struct.rmg::Vec3", %"struct.rmg::Vec3", float, float, float, i32, i32, i32 }
%"class.rmg::internal::Shader.base" = type <{ ptr, i32 }>
%"class.rmg::Camera" = type { %"struct.rmg::Vec3", %"struct.rmg::Mat3", %"struct.rmg::Mat4", %"struct.rmg::Mat4", %"struct.rmg::Mat4", float, float, float, float, float, i32 }
%"struct.rmg::Mat3" = type { %union.anon.0 }
%union.anon.0 = type { [3 x [3 x float]] }
%"struct.rmg::Mat4" = type { %union.anon.1 }
%union.anon.1 = type { [4 x [4 x float]] }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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 @_ZN3rmg8internal15ShadowMapShader32calculateShadowMapperTranslationEv(ptr noundef nonnull align 8 dereferenceable(336) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.rmg::Vec3", align 4
  %4 = alloca %"struct.rmg::Vec3", align 4
  %5 = alloca %"struct.rmg::Vec3", align 4
  %6 = alloca { <2 x float>, float }, align 8
  %7 = alloca { <2 x float>, float }, align 8
  %8 = alloca %"struct.rmg::Vec3", align 4
  %9 = alloca { <2 x float>, float }, align 8
  %10 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %11 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #5
  %12 = getelementptr inbounds %"class.rmg::internal::ShadowMapShader", ptr %11, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #5
  %13 = getelementptr inbounds %"class.rmg::internal::ShadowMapShader", ptr %11, i32 0, i32 7
  %14 = load float, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.rmg::internal::ShadowMapShader", ptr %11, i32 0, i32 3
  %16 = call { <2 x float>, float } @_ZN3rmgmlEfRKNS_4Vec3E(float noundef %14, ptr noundef nonnull align 4 dereferenceable(12) %15)
  %17 = getelementptr inbounds %"struct.rmg::Vec3", ptr %5, i32 0, i32 0
  %18 = getelementptr inbounds %union.anon, ptr %17, i32 0, i32 0
  store { <2 x float>, float } %16, ptr %6, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 8 %6, i64 12, i1 false)
  %19 = call { <2 x float>, float } @_ZNK3rmg4Vec3plERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %12, ptr noundef nonnull align 4 dereferenceable(12) %5)
  %20 = getelementptr inbounds %"struct.rmg::Vec3", ptr %4, i32 0, i32 0
  %21 = getelementptr inbounds %union.anon, ptr %20, i32 0, i32 0
  store { <2 x float>, float } %19, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 8 %7, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #5
  %22 = getelementptr inbounds %"class.rmg::internal::ShadowMapShader", ptr %11, i32 0, i32 6
  %23 = load float, ptr %22, align 4, !tbaa !19
  %24 = getelementptr inbounds %"class.rmg::internal::ShadowMapShader", ptr %11, i32 0, i32 5
  %25 = load float, ptr %24, align 8, !tbaa !20
  %26 = fsub float %23, %25
  %27 = fmul float 0x3FE99999A0000000, %26
  %28 = getelementptr inbounds %"class.rmg::internal::ShadowMapShader", ptr %11, i32 0, i32 4
  %29 = call { <2 x float>, float } @_ZN3rmgmlEfRKNS_4Vec3E(float noundef %27, ptr noundef nonnull align 4 dereferenceable(12) %28)
  %30 = getelementptr inbounds %"struct.rmg::Vec3", ptr %8, i32 0, i32 0
  %31 = getelementptr inbounds %union.anon, ptr %30, i32 0, i32 0
  store { <2 x float>, float } %29, ptr %9, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %31, ptr align 8 %9, i64 12, i1 false)
  %32 = call { <2 x float>, float } @_ZNK3rmg4Vec3miERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %4, ptr noundef nonnull align 4 dereferenceable(12) %8)
  %33 = getelementptr inbounds %"struct.rmg::Vec3", ptr %3, i32 0, i32 0
  %34 = getelementptr inbounds %union.anon, ptr %33, i32 0, i32 0
  store { <2 x float>, float } %32, ptr %10, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 8 %10, i64 12, i1 false)
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %4) #5
  %35 = getelementptr inbounds %"class.rmg::internal::ShadowMapShader", ptr %11, i32 0, i32 1
  call void @_ZN3rmg6Camera14setTranslationERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(264) %35, ptr noundef nonnull align 4 dereferenceable(12) %3)
  call void @llvm.lifetime.end.p0(i64 12, ptr %3) #5
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZNK3rmg4Vec3plERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN3rmgmlEfRKNS_4Vec3E(float noundef, ptr noundef nonnull align 4 dereferenceable(12)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZNK3rmg4Vec3miERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

declare void @_ZN3rmg6Camera14setTranslationERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(264), ptr noundef nonnull align 4 dereferenceable(12)) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !17, i64 320}
!10 = !{!"_ZTSN3rmg8internal15ShadowMapShaderE", !11, i64 0, !13, i64 12, !14, i64 276, !14, i64 288, !14, i64 300, !17, i64 312, !17, i64 316, !17, i64 320, !12, i64 324, !12, i64 328, !12, i64 332}
!11 = !{!"_ZTSN3rmg8internal6ShaderE", !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN3rmg6CameraE", !14, i64 0, !15, i64 12, !16, i64 48, !16, i64 112, !16, i64 176, !17, i64 240, !17, i64 244, !17, i64 248, !17, i64 252, !17, i64 256, !18, i64 260}
!14 = !{!"_ZTSN3rmg4Vec3E", !7, i64 0}
!15 = !{!"_ZTSN3rmg4Mat3E", !7, i64 0}
!16 = !{!"_ZTSN3rmg4Mat4E", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!"_ZTSN3rmg14ProjectionModeE", !7, i64 0}
!19 = !{!10, !17, i64 316}
!20 = !{!10, !17, i64 312}


; 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::Vec3" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { float, float, float }

; 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 @_ZN3rmg8internal15ShadowMapShader32calculateShadowMapperTranslationEv(ptr noundef nonnull align 8 dereferenceable(336) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"struct.rmg::Vec3", align 8
  %3 = alloca %"struct.rmg::Vec3", align 8
  %4 = alloca %"struct.rmg::Vec3", align 8
  %5 = alloca %"struct.rmg::Vec3", align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #4
  %6 = getelementptr inbounds i8, ptr %0, i64 276
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  %7 = getelementptr inbounds i8, ptr %0, i64 320
  %8 = load float, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 288
  %10 = tail call { <2 x float>, float } @_ZN3rmgmlEfRKNS_4Vec3E(float noundef %8, ptr noundef nonnull align 4 dereferenceable(12) %9)
  %.fca.0.extract9 = extractvalue { <2 x float>, float } %10, 0
  %.fca.1.extract10 = extractvalue { <2 x float>, float } %10, 1
  store <2 x float> %.fca.0.extract9, ptr %4, align 8
  %.sroa.212.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store float %.fca.1.extract10, ptr %.sroa.212.0..sroa_idx, align 8
  %11 = call { <2 x float>, float } @_ZNK3rmg4Vec3plERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %4)
  %.fca.0.extract5 = extractvalue { <2 x float>, float } %11, 0
  %.fca.1.extract6 = extractvalue { <2 x float>, float } %11, 1
  store <2 x float> %.fca.0.extract5, ptr %3, align 8
  %.sroa.28.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  store float %.fca.1.extract6, ptr %.sroa.28.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  %12 = getelementptr inbounds i8, ptr %0, i64 316
  %13 = load float, ptr %12, align 4, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %0, i64 312
  %15 = load float, ptr %14, align 8, !tbaa !18
  %16 = fsub float %13, %15
  %17 = fmul float %16, 0x3FE99999A0000000
  %18 = getelementptr inbounds i8, ptr %0, i64 300
  %19 = call { <2 x float>, float } @_ZN3rmgmlEfRKNS_4Vec3E(float noundef %17, ptr noundef nonnull align 4 dereferenceable(12) %18)
  %.fca.0.extract1 = extractvalue { <2 x float>, float } %19, 0
  %.fca.1.extract2 = extractvalue { <2 x float>, float } %19, 1
  store <2 x float> %.fca.0.extract1, ptr %5, align 8
  %.sroa.24.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store float %.fca.1.extract2, ptr %.sroa.24.0..sroa_idx, align 8
  %20 = call { <2 x float>, float } @_ZNK3rmg4Vec3miERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %5)
  %.fca.0.extract = extractvalue { <2 x float>, float } %20, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %20, 1
  store <2 x float> %.fca.0.extract, ptr %2, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  store float %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  %21 = getelementptr inbounds i8, ptr %0, i64 12
  call void @_ZN3rmg6Camera14setTranslationERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(264) %21, ptr noundef nonnull align 4 dereferenceable(12) %2)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #4
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZNK3rmg4Vec3plERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN3rmgmlEfRKNS_4Vec3E(float noundef, ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZNK3rmg4Vec3miERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

declare void @_ZN3rmg6Camera14setTranslationERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(264), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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 = { 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, !15, i64 320}
!6 = !{!"_ZTSN3rmg8internal15ShadowMapShaderE", !7, i64 0, !11, i64 12, !12, i64 276, !12, i64 288, !12, i64 300, !15, i64 312, !15, i64 316, !15, i64 320, !8, i64 324, !8, i64 328, !8, i64 332}
!7 = !{!"_ZTSN3rmg8internal6ShaderE", !8, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN3rmg6CameraE", !12, i64 0, !13, i64 12, !14, i64 48, !14, i64 112, !14, i64 176, !15, i64 240, !15, i64 244, !15, i64 248, !15, i64 252, !15, i64 256, !16, i64 260}
!12 = !{!"_ZTSN3rmg4Vec3E", !9, i64 0}
!13 = !{!"_ZTSN3rmg4Mat3E", !9, i64 0}
!14 = !{!"_ZTSN3rmg4Mat4E", !9, i64 0}
!15 = !{!"float", !9, i64 0}
!16 = !{!"_ZTSN3rmg14ProjectionModeE", !9, i64 0}
!17 = !{!6, !15, i64 316}
!18 = !{!6, !15, i64 312}


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