; LLVM IR from danginsburg/opengles3-book :: Common/Source (esTransform)

; 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.ESMatrix = type { [4 x [4 x float]] }

; Function Attrs: nounwind uwtable
define dso_local void @esTranslate(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.ESMatrix, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds [4 x [4 x float]], ptr %10, i64 0, i64 0
  %12 = getelementptr inbounds [4 x float], ptr %11, i64 0, i64 0
  %13 = load float, ptr %12, align 4, !tbaa !9
  %14 = load float, ptr %6, align 4, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ESMatrix, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds [4 x [4 x float]], ptr %16, i64 0, i64 1
  %18 = getelementptr inbounds [4 x float], ptr %17, i64 0, i64 0
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = load float, ptr %7, align 4, !tbaa !9
  %21 = fmul float %19, %20
  %22 = call float @llvm.fmuladd.f32(float %13, float %14, float %21)
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ESMatrix, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds [4 x [4 x float]], ptr %24, i64 0, i64 2
  %26 = getelementptr inbounds [4 x float], ptr %25, i64 0, i64 0
  %27 = load float, ptr %26, align 4, !tbaa !9
  %28 = load float, ptr %8, align 4, !tbaa !9
  %29 = call float @llvm.fmuladd.f32(float %27, float %28, float %22)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ESMatrix, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds [4 x [4 x float]], ptr %31, i64 0, i64 3
  %33 = getelementptr inbounds [4 x float], ptr %32, i64 0, i64 0
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = fadd float %34, %29
  store float %35, ptr %33, align 4, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ESMatrix, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds [4 x [4 x float]], ptr %37, i64 0, i64 0
  %39 = getelementptr inbounds [4 x float], ptr %38, i64 0, i64 1
  %40 = load float, ptr %39, align 4, !tbaa !9
  %41 = load float, ptr %6, align 4, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ESMatrix, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds [4 x [4 x float]], ptr %43, i64 0, i64 1
  %45 = getelementptr inbounds [4 x float], ptr %44, i64 0, i64 1
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = load float, ptr %7, align 4, !tbaa !9
  %48 = fmul float %46, %47
  %49 = call float @llvm.fmuladd.f32(float %40, float %41, float %48)
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ESMatrix, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds [4 x [4 x float]], ptr %51, i64 0, i64 2
  %53 = getelementptr inbounds [4 x float], ptr %52, i64 0, i64 1
  %54 = load float, ptr %53, align 4, !tbaa !9
  %55 = load float, ptr %8, align 4, !tbaa !9
  %56 = call float @llvm.fmuladd.f32(float %54, float %55, float %49)
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ESMatrix, ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds [4 x [4 x float]], ptr %58, i64 0, i64 3
  %60 = getelementptr inbounds [4 x float], ptr %59, i64 0, i64 1
  %61 = load float, ptr %60, align 4, !tbaa !9
  %62 = fadd float %61, %56
  store float %62, ptr %60, align 4, !tbaa !9
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ESMatrix, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds [4 x [4 x float]], ptr %64, i64 0, i64 0
  %66 = getelementptr inbounds [4 x float], ptr %65, i64 0, i64 2
  %67 = load float, ptr %66, align 4, !tbaa !9
  %68 = load float, ptr %6, align 4, !tbaa !9
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ESMatrix, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds [4 x [4 x float]], ptr %70, i64 0, i64 1
  %72 = getelementptr inbounds [4 x float], ptr %71, i64 0, i64 2
  %73 = load float, ptr %72, align 4, !tbaa !9
  %74 = load float, ptr %7, align 4, !tbaa !9
  %75 = fmul float %73, %74
  %76 = call float @llvm.fmuladd.f32(float %67, float %68, float %75)
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ESMatrix, ptr %77, i32 0, i32 0
  %79 = getelementptr inbounds [4 x [4 x float]], ptr %78, i64 0, i64 2
  %80 = getelementptr inbounds [4 x float], ptr %79, i64 0, i64 2
  %81 = load float, ptr %80, align 4, !tbaa !9
  %82 = load float, ptr %8, align 4, !tbaa !9
  %83 = call float @llvm.fmuladd.f32(float %81, float %82, float %76)
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.ESMatrix, ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds [4 x [4 x float]], ptr %85, i64 0, i64 3
  %87 = getelementptr inbounds [4 x float], ptr %86, i64 0, i64 2
  %88 = load float, ptr %87, align 4, !tbaa !9
  %89 = fadd float %88, %83
  store float %89, ptr %87, align 4, !tbaa !9
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.ESMatrix, ptr %90, i32 0, i32 0
  %92 = getelementptr inbounds [4 x [4 x float]], ptr %91, i64 0, i64 0
  %93 = getelementptr inbounds [4 x float], ptr %92, i64 0, i64 3
  %94 = load float, ptr %93, align 4, !tbaa !9
  %95 = load float, ptr %6, align 4, !tbaa !9
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ESMatrix, ptr %96, i32 0, i32 0
  %98 = getelementptr inbounds [4 x [4 x float]], ptr %97, i64 0, i64 1
  %99 = getelementptr inbounds [4 x float], ptr %98, i64 0, i64 3
  %100 = load float, ptr %99, align 4, !tbaa !9
  %101 = load float, ptr %7, align 4, !tbaa !9
  %102 = fmul float %100, %101
  %103 = call float @llvm.fmuladd.f32(float %94, float %95, float %102)
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.ESMatrix, ptr %104, i32 0, i32 0
  %106 = getelementptr inbounds [4 x [4 x float]], ptr %105, i64 0, i64 2
  %107 = getelementptr inbounds [4 x float], ptr %106, i64 0, i64 3
  %108 = load float, ptr %107, align 4, !tbaa !9
  %109 = load float, ptr %8, align 4, !tbaa !9
  %110 = call float @llvm.fmuladd.f32(float %108, float %109, float %103)
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.ESMatrix, ptr %111, i32 0, i32 0
  %113 = getelementptr inbounds [4 x [4 x float]], ptr %112, i64 0, i64 3
  %114 = getelementptr inbounds [4 x float], ptr %113, i64 0, i64 3
  %115 = load float, ptr %114, align 4, !tbaa !9
  %116 = fadd float %115, %110
  store float %116, ptr %114, align 4, !tbaa !9
  ret void
}

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}


; 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(argmem: readwrite) uwtable
define dso_local void @esTranslate(ptr nocapture noundef %0, float noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load <4 x float>, ptr %0, align 4, !tbaa !5
  %9 = load <4 x float>, ptr %5, align 4, !tbaa !5
  %10 = insertelement <4 x float> poison, float %2, i64 0
  %11 = shufflevector <4 x float> %10, <4 x float> poison, <4 x i32> zeroinitializer
  %12 = fmul <4 x float> %9, %11
  %13 = insertelement <4 x float> poison, float %1, i64 0
  %14 = shufflevector <4 x float> %13, <4 x float> poison, <4 x i32> zeroinitializer
  %15 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %8, <4 x float> %14, <4 x float> %12)
  %16 = load <4 x float>, ptr %6, align 4, !tbaa !5
  %17 = insertelement <4 x float> poison, float %3, i64 0
  %18 = shufflevector <4 x float> %17, <4 x float> poison, <4 x i32> zeroinitializer
  %19 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %16, <4 x float> %18, <4 x float> %15)
  %20 = load <4 x float>, ptr %7, align 4, !tbaa !5
  %21 = fadd <4 x float> %20, %19
  store <4 x float> %21, ptr %7, align 4, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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