; LLVM IR from DreamingInfraviolet/EstimateImageMatting :: Primatte/matrixd.ll (ZN4math3tmp5_mat414initProjectionEfffff)

; 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.math::tmp::_mat4" = 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 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 @_ZN4math3tmp5_mat45resetEv(ptr noundef nonnull align 4 dereferenceable(64)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 4 dereferenceable(64) ptr @_ZN4math3tmp5_mat414initProjectionEfffff(ptr noundef nonnull align 4 dereferenceable(64) %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5) #1 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !9
  store float %2, ptr %9, align 4, !tbaa !9
  store float %3, ptr %10, align 4, !tbaa !9
  store float %4, ptr %11, align 4, !tbaa !9
  store float %5, ptr %12, align 4, !tbaa !9
  %14 = load ptr, ptr %7, align 8
  call void @_ZN4math3tmp5_mat45resetEv(ptr noundef nonnull align 4 dereferenceable(64) %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %15 = load float, ptr %8, align 4, !tbaa !9
  %16 = fdiv float %15, 2.000000e+00
  %17 = fpext float %16 to double
  %18 = call double @tan(double noundef %17) #3
  %19 = fptrunc double %18 to float
  store float %19, ptr %13, align 4, !tbaa !9
  %20 = load float, ptr %13, align 4, !tbaa !9
  %21 = fdiv float 1.000000e+00, %20
  %22 = getelementptr inbounds %"class.math::tmp::_mat4", ptr %14, i32 0, i32 0
  %23 = getelementptr inbounds [4 x [4 x float]], ptr %22, i64 0, i64 1
  %24 = getelementptr inbounds [4 x float], ptr %23, i64 0, i64 1
  store float %21, ptr %24, align 4, !tbaa !9
  %25 = getelementptr inbounds %"class.math::tmp::_mat4", ptr %14, i32 0, i32 0
  %26 = getelementptr inbounds [4 x [4 x float]], ptr %25, i64 0, i64 1
  %27 = getelementptr inbounds [4 x float], ptr %26, i64 0, i64 1
  %28 = load float, ptr %27, align 4, !tbaa !9
  %29 = fneg float %28
  %30 = load float, ptr %9, align 4, !tbaa !9
  %31 = load float, ptr %10, align 4, !tbaa !9
  %32 = fdiv float %30, %31
  %33 = fdiv float %29, %32
  %34 = getelementptr inbounds %"class.math::tmp::_mat4", ptr %14, i32 0, i32 0
  %35 = getelementptr inbounds [4 x [4 x float]], ptr %34, i64 0, i64 0
  %36 = getelementptr inbounds [4 x float], ptr %35, i64 0, i64 0
  store float %33, ptr %36, align 4, !tbaa !9
  %37 = load float, ptr %12, align 4, !tbaa !9
  %38 = load float, ptr %12, align 4, !tbaa !9
  %39 = load float, ptr %11, align 4, !tbaa !9
  %40 = fsub float %38, %39
  %41 = fdiv float 1.000000e+00, %40
  %42 = fmul float %37, %41
  %43 = getelementptr inbounds %"class.math::tmp::_mat4", ptr %14, i32 0, i32 0
  %44 = getelementptr inbounds [4 x [4 x float]], ptr %43, i64 0, i64 2
  %45 = getelementptr inbounds [4 x float], ptr %44, i64 0, i64 2
  store float %42, ptr %45, align 4, !tbaa !9
  %46 = load float, ptr %12, align 4, !tbaa !9
  %47 = fneg float %46
  %48 = load float, ptr %11, align 4, !tbaa !9
  %49 = fmul float %47, %48
  %50 = load float, ptr %12, align 4, !tbaa !9
  %51 = load float, ptr %11, align 4, !tbaa !9
  %52 = fsub float %50, %51
  %53 = fdiv float 1.000000e+00, %52
  %54 = fmul float %49, %53
  %55 = getelementptr inbounds %"class.math::tmp::_mat4", ptr %14, i32 0, i32 0
  %56 = getelementptr inbounds [4 x [4 x float]], ptr %55, i64 0, i64 3
  %57 = getelementptr inbounds [4 x float], ptr %56, i64 0, i64 2
  store float %54, ptr %57, align 4, !tbaa !9
  %58 = getelementptr inbounds %"class.math::tmp::_mat4", ptr %14, i32 0, i32 0
  %59 = getelementptr inbounds [4 x [4 x float]], ptr %58, i64 0, i64 2
  %60 = getelementptr inbounds [4 x float], ptr %59, i64 0, i64 3
  store float 1.000000e+00, ptr %60, align 4, !tbaa !9
  %61 = getelementptr inbounds %"class.math::tmp::_mat4", ptr %14, i32 0, i32 0
  %62 = getelementptr inbounds [4 x [4 x float]], ptr %61, i64 0, i64 3
  %63 = getelementptr inbounds [4 x float], ptr %62, i64 0, i64 3
  store float 0.000000e+00, ptr %63, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  ret ptr %14
}

; Function Attrs: nounwind
declare double @tan(double noundef) #2

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 "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 = { 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 = !{!"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 nounwind uwtable
declare dso_local void @_ZN4math3tmp5_mat45resetEv(ptr noundef nonnull align 4 dereferenceable(64)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 4 dereferenceable(64) ptr @_ZN4math3tmp5_mat414initProjectionEfffff(ptr noundef nonnull returned align 4 dereferenceable(64) %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5) local_unnamed_addr #0 align 2 {
  tail call void @_ZN4math3tmp5_mat45resetEv(ptr noundef nonnull align 4 dereferenceable(64) %0)
  %7 = fmul float %1, 5.000000e-01
  %8 = fpext float %7 to double
  %9 = tail call double @tan(double noundef %8) #2
  %10 = fptrunc double %9 to float
  %11 = fdiv float 1.000000e+00, %10
  %12 = getelementptr inbounds i8, ptr %0, i64 20
  store float %11, ptr %12, align 4, !tbaa !5
  %13 = fneg float %11
  %14 = fdiv float %2, %3
  %15 = fdiv float %13, %14
  store float %15, ptr %0, align 4, !tbaa !5
  %16 = fsub float %5, %4
  %17 = fdiv float 1.000000e+00, %16
  %18 = fmul float %17, %5
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  store float %18, ptr %19, align 4, !tbaa !5
  %20 = fneg float %5
  %21 = fmul float %20, %4
  %22 = fmul float %21, %17
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  store float %22, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 44
  store float 1.000000e+00, ptr %24, align 4, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %0, i64 60
  store float 0.000000e+00, ptr %25, align 4, !tbaa !5
  ret ptr %0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @tan(double noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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