; LLVM IR from erwincoumans/tiny-differentiable-simulator :: src/visualizer/opengl (tiny_gl_instancing_renderer)

; 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.TinyGLInstancingRenderer = type <{ ptr, %"class.std::vector", ptr, i8, i8, [2 x i8], i32, i32, i32, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<b3GraphicsInstance *, std::allocator<b3GraphicsInstance *>>::_Vector_impl" }
%"struct.std::_Vector_base<b3GraphicsInstance *, std::allocator<b3GraphicsInstance *>>::_Vector_impl" = type { %"struct.std::_Vector_base<b3GraphicsInstance *, std::allocator<b3GraphicsInstance *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<b3GraphicsInstance *, std::allocator<b3GraphicsInstance *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.InternalDataRenderer = type <{ %struct.GLInstanceRendererInternalData.base, [4 x i8], %struct.TinyCamera, ptr, [16 x float], [16 x float], [16 x float], [16 x float], [16 x float], i8, [3 x i8], %"struct.TINY::TinyVector3", %"struct.TINY::TinyVector3", i32, %"class.std::vector.5", ptr, i32, i32, %class.TinyResizablePool, i32, i32, float, i8, [3 x i8] }>
%struct.GLInstanceRendererInternalData.base = type <{ %"class.std::vector.0", %"class.std::vector.0", %"class.std::vector.0", %"class.std::vector.0", i32, i32, i32, i32, i32 }>
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, std::allocator<float>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.TinyCamera = type { ptr, ptr }
%"struct.TINY::TinyVector3" = type { float, float, float, i32 }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<InternalTextureHandle, std::allocator<InternalTextureHandle>>::_Vector_impl" }
%"struct.std::_Vector_base<InternalTextureHandle, std::allocator<InternalTextureHandle>>::_Vector_impl" = type { %"struct.std::_Vector_base<InternalTextureHandle, std::allocator<InternalTextureHandle>>::_Vector_impl_data" }
%"struct.std::_Vector_base<InternalTextureHandle, std::allocator<InternalTextureHandle>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.TinyResizablePool = type { ptr, %"class.std::vector.10", i32, i32 }
%"class.std::vector.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = type { %"struct.std::_Vector_base<TinyPoolBodyHandle<TinyPublicGraphicsInstanceData>, std::allocator<TinyPoolBodyHandle<TinyPublicGraphicsInstanceData>>>::_Vector_impl" }
%"struct.std::_Vector_base<TinyPoolBodyHandle<TinyPublicGraphicsInstanceData>, std::allocator<TinyPoolBodyHandle<TinyPublicGraphicsInstanceData>>>::_Vector_impl" = type { %"struct.std::_Vector_base<TinyPoolBodyHandle<TinyPublicGraphicsInstanceData>, std::allocator<TinyPoolBodyHandle<TinyPublicGraphicsInstanceData>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<TinyPoolBodyHandle<TinyPublicGraphicsInstanceData>, std::allocator<TinyPoolBodyHandle<TinyPublicGraphicsInstanceData>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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 nounwind uwtable
define dso_local void @_ZN24TinyGLInstancingRenderer31set_projective_texture_matricesEPKfS1_(ptr noundef nonnull align 8 dereferenceable(60) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %36, %3
  %10 = load i32, ptr %7, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 16
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %39

13:                                               ; preds = %9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds float, ptr %14, i64 %16
  %18 = load float, ptr %17, align 4, !tbaa !11
  %19 = getelementptr inbounds %class.TinyGLInstancingRenderer, ptr %8, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds %struct.InternalDataRenderer, ptr %20, i32 0, i32 7
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [16 x float], ptr %21, i64 0, i64 %23
  store float %18, ptr %24, align 4, !tbaa !11
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %25, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !11
  %30 = getelementptr inbounds %class.TinyGLInstancingRenderer, ptr %8, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds %struct.InternalDataRenderer, ptr %31, i32 0, i32 6
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [16 x float], ptr %32, i64 0, i64 %34
  store float %29, ptr %35, align 4, !tbaa !11
  br label %36

36:                                               ; preds = %13
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %7, align 4, !tbaa !9
  br label %9, !llvm.loop !20

39:                                               ; preds = %12
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 32}
!14 = !{!"_ZTS24TinyGLInstancingRenderer", !15, i64 8, !6, i64 32, !19, i64 40, !19, i64 41, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56}
!15 = !{!"_ZTSSt6vectorIP18b3GraphicsInstanceSaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIP18b3GraphicsInstanceSaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIP18b3GraphicsInstanceSaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIP18b3GraphicsInstanceSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"bool", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN24TinyGLInstancingRenderer31set_projective_texture_matricesEPKfS1_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(60) %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 336
  %7 = getelementptr inbounds i8, ptr %5, i64 272
  %8 = load float, ptr %1, align 4, !tbaa !16
  store float %8, ptr %6, align 4, !tbaa !16
  %9 = load float, ptr %2, align 4, !tbaa !16
  store float %9, ptr %7, align 4, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = load float, ptr %10, align 4, !tbaa !16
  %12 = getelementptr inbounds i8, ptr %5, i64 340
  store float %11, ptr %12, align 4, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %2, i64 4
  %14 = load float, ptr %13, align 4, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %5, i64 276
  store float %14, ptr %15, align 4, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load float, ptr %16, align 4, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %5, i64 344
  store float %17, ptr %18, align 4, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %2, i64 8
  %20 = load float, ptr %19, align 4, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %5, i64 280
  store float %20, ptr %21, align 4, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %1, i64 12
  %23 = load float, ptr %22, align 4, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %5, i64 348
  store float %23, ptr %24, align 4, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %2, i64 12
  %26 = load float, ptr %25, align 4, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %5, i64 284
  store float %26, ptr %27, align 4, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %1, i64 16
  %29 = load float, ptr %28, align 4, !tbaa !16
  %30 = getelementptr inbounds i8, ptr %5, i64 352
  store float %29, ptr %30, align 4, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %2, i64 16
  %32 = load float, ptr %31, align 4, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %5, i64 288
  store float %32, ptr %33, align 4, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %1, i64 20
  %35 = load float, ptr %34, align 4, !tbaa !16
  %36 = getelementptr inbounds i8, ptr %5, i64 356
  store float %35, ptr %36, align 4, !tbaa !16
  %37 = getelementptr inbounds i8, ptr %2, i64 20
  %38 = load float, ptr %37, align 4, !tbaa !16
  %39 = getelementptr inbounds i8, ptr %5, i64 292
  store float %38, ptr %39, align 4, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %1, i64 24
  %41 = load float, ptr %40, align 4, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %5, i64 360
  store float %41, ptr %42, align 4, !tbaa !16
  %43 = getelementptr inbounds i8, ptr %2, i64 24
  %44 = load float, ptr %43, align 4, !tbaa !16
  %45 = getelementptr inbounds i8, ptr %5, i64 296
  store float %44, ptr %45, align 4, !tbaa !16
  %46 = getelementptr inbounds i8, ptr %1, i64 28
  %47 = load float, ptr %46, align 4, !tbaa !16
  %48 = getelementptr inbounds i8, ptr %5, i64 364
  store float %47, ptr %48, align 4, !tbaa !16
  %49 = getelementptr inbounds i8, ptr %2, i64 28
  %50 = load float, ptr %49, align 4, !tbaa !16
  %51 = getelementptr inbounds i8, ptr %5, i64 300
  store float %50, ptr %51, align 4, !tbaa !16
  %52 = getelementptr inbounds i8, ptr %1, i64 32
  %53 = load float, ptr %52, align 4, !tbaa !16
  %54 = getelementptr inbounds i8, ptr %5, i64 368
  store float %53, ptr %54, align 4, !tbaa !16
  %55 = getelementptr inbounds i8, ptr %2, i64 32
  %56 = load float, ptr %55, align 4, !tbaa !16
  %57 = getelementptr inbounds i8, ptr %5, i64 304
  store float %56, ptr %57, align 4, !tbaa !16
  %58 = getelementptr inbounds i8, ptr %1, i64 36
  %59 = load float, ptr %58, align 4, !tbaa !16
  %60 = getelementptr inbounds i8, ptr %5, i64 372
  store float %59, ptr %60, align 4, !tbaa !16
  %61 = getelementptr inbounds i8, ptr %2, i64 36
  %62 = load float, ptr %61, align 4, !tbaa !16
  %63 = getelementptr inbounds i8, ptr %5, i64 308
  store float %62, ptr %63, align 4, !tbaa !16
  %64 = getelementptr inbounds i8, ptr %1, i64 40
  %65 = load float, ptr %64, align 4, !tbaa !16
  %66 = getelementptr inbounds i8, ptr %5, i64 376
  store float %65, ptr %66, align 4, !tbaa !16
  %67 = getelementptr inbounds i8, ptr %2, i64 40
  %68 = load float, ptr %67, align 4, !tbaa !16
  %69 = getelementptr inbounds i8, ptr %5, i64 312
  store float %68, ptr %69, align 4, !tbaa !16
  %70 = getelementptr inbounds i8, ptr %1, i64 44
  %71 = load float, ptr %70, align 4, !tbaa !16
  %72 = getelementptr inbounds i8, ptr %5, i64 380
  store float %71, ptr %72, align 4, !tbaa !16
  %73 = getelementptr inbounds i8, ptr %2, i64 44
  %74 = load float, ptr %73, align 4, !tbaa !16
  %75 = getelementptr inbounds i8, ptr %5, i64 316
  store float %74, ptr %75, align 4, !tbaa !16
  %76 = getelementptr inbounds i8, ptr %1, i64 48
  %77 = load float, ptr %76, align 4, !tbaa !16
  %78 = getelementptr inbounds i8, ptr %5, i64 384
  store float %77, ptr %78, align 4, !tbaa !16
  %79 = getelementptr inbounds i8, ptr %2, i64 48
  %80 = load float, ptr %79, align 4, !tbaa !16
  %81 = getelementptr inbounds i8, ptr %5, i64 320
  store float %80, ptr %81, align 4, !tbaa !16
  %82 = getelementptr inbounds i8, ptr %1, i64 52
  %83 = load float, ptr %82, align 4, !tbaa !16
  %84 = getelementptr inbounds i8, ptr %5, i64 388
  store float %83, ptr %84, align 4, !tbaa !16
  %85 = getelementptr inbounds i8, ptr %2, i64 52
  %86 = load float, ptr %85, align 4, !tbaa !16
  %87 = getelementptr inbounds i8, ptr %5, i64 324
  store float %86, ptr %87, align 4, !tbaa !16
  %88 = getelementptr inbounds i8, ptr %1, i64 56
  %89 = load float, ptr %88, align 4, !tbaa !16
  %90 = getelementptr inbounds i8, ptr %5, i64 392
  store float %89, ptr %90, align 4, !tbaa !16
  %91 = getelementptr inbounds i8, ptr %2, i64 56
  %92 = load float, ptr %91, align 4, !tbaa !16
  %93 = getelementptr inbounds i8, ptr %5, i64 328
  store float %92, ptr %93, align 4, !tbaa !16
  %94 = getelementptr inbounds i8, ptr %1, i64 60
  %95 = load float, ptr %94, align 4, !tbaa !16
  %96 = getelementptr inbounds i8, ptr %5, i64 396
  store float %95, ptr %96, align 4, !tbaa !16
  %97 = getelementptr inbounds i8, ptr %2, i64 60
  %98 = load float, ptr %97, align 4, !tbaa !16
  %99 = getelementptr inbounds i8, ptr %5, i64 332
  store float %98, ptr %99, align 4, !tbaa !16
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: none) 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" }

!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, !11, i64 32}
!6 = !{!"_ZTS24TinyGLInstancingRenderer", !7, i64 8, !11, i64 32, !14, i64 40, !14, i64 41, !15, i64 44, !15, i64 48, !15, i64 52, !15, i64 56}
!7 = !{!"_ZTSSt6vectorIP18b3GraphicsInstanceSaIS1_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseIP18b3GraphicsInstanceSaIS1_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseIP18b3GraphicsInstanceSaIS1_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseIP18b3GraphicsInstanceSaIS1_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"bool", !12, i64 0}
!15 = !{!"int", !12, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !12, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass