; LLVM IR from drohmer/cgp :: library/cgp/06_mat/mat4/mat4.ll (ZNK3cgp12matrix_stackIfLi4ELi4EE16get_block_linearEv)

; 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.cgp::matrix_stack.2" = type { %"struct.cgp::numarray_stack.3" }
%"struct.cgp::numarray_stack.3" = type { %"struct.cgp::numarray_stack.4", %"struct.cgp::numarray_stack.4", %"struct.cgp::numarray_stack.4" }
%"struct.cgp::numarray_stack.4" = type { float, float, float }
%"class.std::initializer_list.7" = type { ptr, i64 }
%"struct.cgp::matrix_stack" = type { %"struct.cgp::numarray_stack" }
%"struct.cgp::numarray_stack" = type { %"struct.cgp::numarray_stack.0", %"struct.cgp::numarray_stack.0", %"struct.cgp::numarray_stack.0", %"struct.cgp::numarray_stack.0" }
%"struct.cgp::numarray_stack.0" = type { float, float, float, float }

; 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) #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 @_ZNK3cgp12matrix_stackIfLi4ELi4EE16get_block_linearEv(ptr dead_on_unwind noalias writable sret(%"struct.cgp::matrix_stack.2") align 4 %0, ptr noundef nonnull align 4 dereferenceable(64) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca %"class.std::initializer_list.7", align 8
  %5 = alloca [3 x %"struct.cgp::numarray_stack.4"], align 4
  %6 = alloca { <2 x float>, float }, align 8
  %7 = alloca { <2 x float>, float }, align 8
  %8 = alloca { <2 x float>, float }, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 36, ptr %5) #5
  %10 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %10, i32 0, i32 0
  %12 = call { <2 x float>, float } @_ZNK3cgp14numarray_stackIfLi4EE3xyzEv(ptr noundef nonnull align 4 dereferenceable(16) %11)
  store { <2 x float>, float } %12, ptr %6, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 8 %6, i64 12, i1 false)
  %13 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %5, i64 1
  %14 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %9, i32 0, i32 0
  %15 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %14, i32 0, i32 1
  %16 = call { <2 x float>, float } @_ZNK3cgp14numarray_stackIfLi4EE3xyzEv(ptr noundef nonnull align 4 dereferenceable(16) %15)
  store { <2 x float>, float } %16, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 8 %7, i64 12, i1 false)
  %17 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %5, i64 2
  %18 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %9, i32 0, i32 0
  %19 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %18, i32 0, i32 2
  %20 = call { <2 x float>, float } @_ZNK3cgp14numarray_stackIfLi4EE3xyzEv(ptr noundef nonnull align 4 dereferenceable(16) %19)
  store { <2 x float>, float } %20, ptr %8, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 8 %8, i64 12, i1 false)
  %21 = getelementptr inbounds %"class.std::initializer_list.7", ptr %4, i32 0, i32 0
  store ptr %5, ptr %21, align 8, !tbaa !9
  %22 = getelementptr inbounds %"class.std::initializer_list.7", ptr %4, i32 0, i32 1
  store i64 3, ptr %22, align 8, !tbaa !12
  call void @_ZN3cgp12matrix_stackIfLi3ELi3EEC1ERKSt16initializer_listINS_14numarray_stackIfLi3EEEE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 36, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #5
  ret void
}

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

declare void @_ZN3cgp12matrix_stackIfLi3ELi3EEC1ERKSt16initializer_listINS_14numarray_stackIfLi3EEEE(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync 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 = { 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, !6, i64 0}
!10 = !{!"_ZTSSt16initializer_listIN3cgp14numarray_stackIfLi3EEEE", !6, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}


; 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.cgp::matrix_stack.2" = type { %"struct.cgp::numarray_stack.3" }
%"struct.cgp::numarray_stack.3" = type { %"struct.cgp::numarray_stack.4", %"struct.cgp::numarray_stack.4", %"struct.cgp::numarray_stack.4" }
%"struct.cgp::numarray_stack.4" = type { float, float, float }
%"class.std::initializer_list.7" = type { ptr, i64 }

; 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 @_ZNK3cgp12matrix_stackIfLi4ELi4EE16get_block_linearEv(ptr dead_on_unwind noalias writable sret(%"struct.cgp::matrix_stack.2") align 4 %0, ptr noundef nonnull align 4 dereferenceable(64) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.std::initializer_list.7", align 8
  %4 = alloca [3 x %"struct.cgp::numarray_stack.4"], align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %4) #4
  %5 = tail call { <2 x float>, float } @_ZNK3cgp14numarray_stackIfLi4EE3xyzEv(ptr noundef nonnull align 4 dereferenceable(16) %1)
  %.fca.0.extract5 = extractvalue { <2 x float>, float } %5, 0
  %.fca.1.extract6 = extractvalue { <2 x float>, float } %5, 1
  store <2 x float> %.fca.0.extract5, ptr %4, align 8
  %.sroa.28.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store float %.fca.1.extract6, ptr %.sroa.28.0..sroa_idx, align 8
  %6 = getelementptr inbounds i8, ptr %4, i64 12
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = tail call { <2 x float>, float } @_ZNK3cgp14numarray_stackIfLi4EE3xyzEv(ptr noundef nonnull align 4 dereferenceable(16) %7)
  %.fca.0.extract1 = extractvalue { <2 x float>, float } %8, 0
  %.fca.1.extract2 = extractvalue { <2 x float>, float } %8, 1
  store <2 x float> %.fca.0.extract1, ptr %6, align 4
  %.sroa.24.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 20
  store float %.fca.1.extract2, ptr %.sroa.24.0..sroa_idx, align 4
  %9 = getelementptr inbounds i8, ptr %4, i64 24
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  %11 = tail call { <2 x float>, float } @_ZNK3cgp14numarray_stackIfLi4EE3xyzEv(ptr noundef nonnull align 4 dereferenceable(16) %10)
  %.fca.0.extract = extractvalue { <2 x float>, float } %11, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %11, 1
  store <2 x float> %.fca.0.extract, ptr %9, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 32
  store float %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  store ptr %4, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %3, i64 8
  store i64 3, ptr %12, align 8, !tbaa !11
  call void @_ZN3cgp12matrix_stackIfLi3ELi3EEC1ERKSt16initializer_listINS_14numarray_stackIfLi3EEEE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(16) %3)
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  ret void
}

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

declare void @_ZN3cgp12matrix_stackIfLi3ELi3EEC1ERKSt16initializer_listINS_14numarray_stackIfLi3EEEE(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(16)) 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSSt16initializer_listIN3cgp14numarray_stackIfLi3EEEE", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}


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