; LLVM IR from sh1l0h/ZINC :: src (camera)

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

; Function Attrs: nounwind uwtable
define dso_local void @zinc_perspective_projection(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  store float %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %12 = load float, ptr %9, align 4, !tbaa !9
  %13 = fdiv float %12, 2.000000e+00
  %14 = call float @tanf(float noundef %13) #4
  store float %14, ptr %11, align 4, !tbaa !9
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void @zinc_mat4_zero(ptr noundef %15)
  %16 = load float, ptr %10, align 4, !tbaa !9
  %17 = load float, ptr %11, align 4, !tbaa !9
  %18 = fmul float %16, %17
  %19 = fdiv float 1.000000e+00, %18
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds [4 x float], ptr %20, i64 0
  %22 = getelementptr inbounds [4 x float], ptr %21, i64 0, i64 0
  store float %19, ptr %22, align 4, !tbaa !9
  %23 = load float, ptr %11, align 4, !tbaa !9
  %24 = fdiv float 1.000000e+00, %23
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds [4 x float], ptr %25, i64 1
  %27 = getelementptr inbounds [4 x float], ptr %26, i64 0, i64 1
  store float %24, ptr %27, align 4, !tbaa !9
  %28 = load float, ptr %7, align 4, !tbaa !9
  %29 = load float, ptr %8, align 4, !tbaa !9
  %30 = fadd float %28, %29
  %31 = load float, ptr %7, align 4, !tbaa !9
  %32 = load float, ptr %8, align 4, !tbaa !9
  %33 = fsub float %31, %32
  %34 = fdiv float %30, %33
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds [4 x float], ptr %35, i64 2
  %37 = getelementptr inbounds [4 x float], ptr %36, i64 0, i64 2
  store float %34, ptr %37, align 4, !tbaa !9
  %38 = load float, ptr %7, align 4, !tbaa !9
  %39 = fmul float -2.000000e+00, %38
  %40 = load float, ptr %8, align 4, !tbaa !9
  %41 = fmul float %39, %40
  %42 = load float, ptr %7, align 4, !tbaa !9
  %43 = load float, ptr %8, align 4, !tbaa !9
  %44 = fsub float %42, %43
  %45 = fdiv float %41, %44
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds [4 x float], ptr %46, i64 2
  %48 = getelementptr inbounds [4 x float], ptr %47, i64 0, i64 3
  store float %45, ptr %48, align 4, !tbaa !9
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds [4 x float], ptr %49, i64 3
  %51 = getelementptr inbounds [4 x float], ptr %50, i64 0, i64 2
  store float 1.000000e+00, ptr %51, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare float @tanf(float noundef) #2

declare void @zinc_mat4_zero(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
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 = { "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, !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: nounwind uwtable
define dso_local void @zinc_perspective_projection(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #0 {
  %6 = fmul float %3, 5.000000e-01
  %7 = tail call float @tanf(float noundef %6) #3
  tail call void @zinc_mat4_zero(ptr noundef %0) #3
  %8 = fmul float %7, %4
  %9 = fdiv float 1.000000e+00, %8
  store float %9, ptr %0, align 4, !tbaa !5
  %10 = fdiv float 1.000000e+00, %7
  %11 = getelementptr inbounds i8, ptr %0, i64 20
  store float %10, ptr %11, align 4, !tbaa !5
  %12 = fadd float %1, %2
  %13 = fsub float %1, %2
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = fmul float %1, -2.000000e+00
  %16 = fmul float %15, %2
  %17 = insertelement <2 x float> poison, float %12, i64 0
  %18 = insertelement <2 x float> %17, float %16, i64 1
  %19 = insertelement <2 x float> poison, float %13, i64 0
  %20 = shufflevector <2 x float> %19, <2 x float> poison, <2 x i32> zeroinitializer
  %21 = fdiv <2 x float> %18, %20
  store <2 x float> %21, ptr %14, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 56
  store float 1.000000e+00, ptr %22, align 4, !tbaa !5
  ret void
}

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

declare void @zinc_mat4_zero(ptr noundef) local_unnamed_addr #2

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


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