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

; 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::numarray_stack.4" = type { float, float, float }
%"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 nounwind uwtable
declare dso_local void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_ZNK3cgp12matrix_stackIfLi4ELi4EE16transform_vectorERKNS_14numarray_stackIfLi3EEE(ptr noundef nonnull align 4 dereferenceable(64) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) #4 align 2 {
  %3 = alloca %"struct.cgp::numarray_stack.4", align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %11 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %12, i32 0, i32 0
  %14 = load float, ptr %13, align 4, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %15, i32 0, i32 0
  %17 = load float, ptr %16, align 4, !tbaa !14
  %18 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %19 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %19, i32 0, i32 1
  %21 = load float, ptr %20, align 4, !tbaa !16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !17
  %25 = fmul float %21, %24
  %26 = call float @llvm.fmuladd.f32(float %14, float %17, float %25)
  %27 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %28 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %28, i32 0, i32 2
  %30 = load float, ptr %29, align 4, !tbaa !18
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %31, i32 0, i32 2
  %33 = load float, ptr %32, align 4, !tbaa !19
  %34 = call float @llvm.fmuladd.f32(float %30, float %33, float %26)
  store float %34, ptr %6, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %35 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %36 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %35, i32 0, i32 1
  %37 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %36, i32 0, i32 0
  %38 = load float, ptr %37, align 4, !tbaa !21
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %39, i32 0, i32 0
  %41 = load float, ptr %40, align 4, !tbaa !14
  %42 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %43 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %43, i32 0, i32 1
  %45 = load float, ptr %44, align 4, !tbaa !22
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %46, i32 0, i32 1
  %48 = load float, ptr %47, align 4, !tbaa !17
  %49 = fmul float %45, %48
  %50 = call float @llvm.fmuladd.f32(float %38, float %41, float %49)
  %51 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %52 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %52, i32 0, i32 2
  %54 = load float, ptr %53, align 4, !tbaa !23
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %55, i32 0, i32 2
  %57 = load float, ptr %56, align 4, !tbaa !19
  %58 = call float @llvm.fmuladd.f32(float %54, float %57, float %50)
  store float %58, ptr %7, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %59 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %60 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %59, i32 0, i32 2
  %61 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %60, i32 0, i32 0
  %62 = load float, ptr %61, align 4, !tbaa !24
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %63, i32 0, i32 0
  %65 = load float, ptr %64, align 4, !tbaa !14
  %66 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %67 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %66, i32 0, i32 2
  %68 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %67, i32 0, i32 1
  %69 = load float, ptr %68, align 4, !tbaa !25
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %70, i32 0, i32 1
  %72 = load float, ptr %71, align 4, !tbaa !17
  %73 = fmul float %69, %72
  %74 = call float @llvm.fmuladd.f32(float %62, float %65, float %73)
  %75 = getelementptr inbounds %"struct.cgp::matrix_stack", ptr %10, i32 0, i32 0
  %76 = getelementptr inbounds %"struct.cgp::numarray_stack", ptr %75, i32 0, i32 2
  %77 = getelementptr inbounds %"struct.cgp::numarray_stack.0", ptr %76, i32 0, i32 2
  %78 = load float, ptr %77, align 4, !tbaa !26
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %"struct.cgp::numarray_stack.4", ptr %79, i32 0, i32 2
  %81 = load float, ptr %80, align 4, !tbaa !19
  %82 = call float @llvm.fmuladd.f32(float %78, float %81, float %74)
  store float %82, ptr %8, align 4, !tbaa !20
  call void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 4 %3, i64 12, i1 false)
  %83 = load { <2 x float>, float }, ptr %9, align 8
  ret { <2 x float>, float } %83
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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, !13, i64 0}
!10 = !{!"_ZTSN3cgp12matrix_stackIfLi4ELi4EEE", !11, i64 0}
!11 = !{!"_ZTSN3cgp14numarray_stackINS0_IfLi4EEELi4EEE", !12, i64 0, !12, i64 16, !12, i64 32, !12, i64 48}
!12 = !{!"_ZTSN3cgp14numarray_stackIfLi4EEE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"_ZTSN3cgp14numarray_stackIfLi3EEE", !13, i64 0, !13, i64 4, !13, i64 8}
!16 = !{!10, !13, i64 4}
!17 = !{!15, !13, i64 4}
!18 = !{!10, !13, i64 8}
!19 = !{!15, !13, i64 8}
!20 = !{!13, !13, i64 0}
!21 = !{!10, !13, i64 16}
!22 = !{!10, !13, i64 20}
!23 = !{!10, !13, i64 24}
!24 = !{!10, !13, i64 32}
!25 = !{!10, !13, i64 36}
!26 = !{!10, !13, i64 40}


; 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::numarray_stack.4" = 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 nounwind uwtable
declare dso_local void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, float } @_ZNK3cgp12matrix_stackIfLi4ELi4EE16transform_vectorERKNS_14numarray_stackIfLi3EEE(ptr nocapture noundef nonnull readonly align 4 dereferenceable(64) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"struct.cgp::numarray_stack.4", align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %7 = load float, ptr %0, align 4, !tbaa !5
  %8 = load float, ptr %1, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load float, ptr %9, align 4, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %1, i64 4
  %12 = load float, ptr %11, align 4, !tbaa !15
  %13 = fmul float %10, %12
  %14 = tail call float @llvm.fmuladd.f32(float %7, float %8, float %13)
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load float, ptr %15, align 4, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  %18 = load float, ptr %17, align 4, !tbaa !17
  %19 = tail call float @llvm.fmuladd.f32(float %16, float %18, float %14)
  store float %19, ptr %4, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load float, ptr %20, align 4, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %0, i64 20
  %23 = load float, ptr %22, align 4, !tbaa !20
  %24 = fmul float %12, %23
  %25 = tail call float @llvm.fmuladd.f32(float %21, float %8, float %24)
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  %27 = load float, ptr %26, align 4, !tbaa !21
  %28 = tail call float @llvm.fmuladd.f32(float %27, float %18, float %25)
  store float %28, ptr %5, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %29 = getelementptr inbounds i8, ptr %0, i64 32
  %30 = load float, ptr %29, align 4, !tbaa !22
  %31 = getelementptr inbounds i8, ptr %0, i64 36
  %32 = load float, ptr %31, align 4, !tbaa !23
  %33 = fmul float %12, %32
  %34 = tail call float @llvm.fmuladd.f32(float %30, float %8, float %33)
  %35 = getelementptr inbounds i8, ptr %0, i64 40
  %36 = load float, ptr %35, align 4, !tbaa !24
  %37 = tail call float @llvm.fmuladd.f32(float %36, float %18, float %34)
  store float %37, ptr %6, align 4, !tbaa !18
  call void @_ZN3cgp14numarray_stackIfLi3EEC2ERKfS3_S3_(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  %.sroa.0.0.copyload = load <2 x float>, ptr %3, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  %.sroa.2.0.copyload = load float, ptr %.sroa.2.0..sroa_idx, align 8
  %.fca.0.insert = insertvalue { <2 x float>, float } poison, <2 x float> %.sroa.0.0.copyload, 0
  %.fca.1.insert = insertvalue { <2 x float>, float } %.fca.0.insert, float %.sroa.2.0.copyload, 1
  ret { <2 x float>, float } %.fca.1.insert
}

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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, !9, i64 0}
!6 = !{!"_ZTSN3cgp12matrix_stackIfLi4ELi4EEE", !7, i64 0}
!7 = !{!"_ZTSN3cgp14numarray_stackINS0_IfLi4EEELi4EEE", !8, i64 0, !8, i64 16, !8, i64 32, !8, i64 48}
!8 = !{!"_ZTSN3cgp14numarray_stackIfLi4EEE", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12}
!9 = !{!"float", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!13, !9, i64 0}
!13 = !{!"_ZTSN3cgp14numarray_stackIfLi3EEE", !9, i64 0, !9, i64 4, !9, i64 8}
!14 = !{!6, !9, i64 4}
!15 = !{!13, !9, i64 4}
!16 = !{!6, !9, i64 8}
!17 = !{!13, !9, i64 8}
!18 = !{!9, !9, i64 0}
!19 = !{!6, !9, i64 16}
!20 = !{!6, !9, i64 20}
!21 = !{!6, !9, i64 24}
!22 = !{!6, !9, i64 32}
!23 = !{!6, !9, i64 36}
!24 = !{!6, !9, i64 40}


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