; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z13mat4_ortho_glffffff)

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

%union.Mat4 = type { [4 x %union.Vec4] }
%union.Vec4 = type { %struct.anon.3 }
%struct.anon.3 = 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: inlinehint mustprogress nounwind uwtable
declare dso_local { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef, float noundef, float noundef, float noundef) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13mat4_ortho_glffffff(ptr dead_on_unwind noalias writable sret(%union.Mat4) align 4 %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6) #3 {
  %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
  %14 = alloca %union.Vec4, align 4
  %15 = alloca %union.Vec4, align 4
  %16 = alloca %union.Vec4, align 4
  %17 = alloca %union.Vec4, align 4
  store float %1, ptr %8, align 4, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !5
  store float %3, ptr %10, align 4, !tbaa !5
  store float %4, ptr %11, align 4, !tbaa !5
  store float %5, ptr %12, align 4, !tbaa !5
  store float %6, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  %18 = load float, ptr %9, align 4, !tbaa !5
  %19 = load float, ptr %8, align 4, !tbaa !5
  %20 = fsub float %18, %19
  %21 = fdiv float 2.000000e+00, %20
  %22 = load float, ptr %8, align 4, !tbaa !5
  %23 = load float, ptr %9, align 4, !tbaa !5
  %24 = fadd float %22, %23
  %25 = fneg float %24
  %26 = load float, ptr %9, align 4, !tbaa !5
  %27 = load float, ptr %8, align 4, !tbaa !5
  %28 = fsub float %26, %27
  %29 = fdiv float %25, %28
  %30 = call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef %21, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef %29)
  %31 = getelementptr inbounds %union.Vec4, ptr %14, i32 0, i32 0
  %32 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %31, i32 0, i32 0
  %33 = extractvalue { <2 x float>, <2 x float> } %30, 0
  store <2 x float> %33, ptr %32, align 4
  %34 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %31, i32 0, i32 1
  %35 = extractvalue { <2 x float>, <2 x float> } %30, 1
  store <2 x float> %35, ptr %34, align 4
  %36 = getelementptr inbounds [4 x %union.Vec4], ptr %0, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %36, ptr align 4 %14, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #4
  %37 = load float, ptr %10, align 4, !tbaa !5
  %38 = load float, ptr %11, align 4, !tbaa !5
  %39 = fsub float %37, %38
  %40 = fdiv float 2.000000e+00, %39
  %41 = load float, ptr %10, align 4, !tbaa !5
  %42 = load float, ptr %11, align 4, !tbaa !5
  %43 = fadd float %41, %42
  %44 = fneg float %43
  %45 = load float, ptr %10, align 4, !tbaa !5
  %46 = load float, ptr %11, align 4, !tbaa !5
  %47 = fsub float %45, %46
  %48 = fdiv float %44, %47
  %49 = call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef 0.000000e+00, float noundef %40, float noundef 0.000000e+00, float noundef %48)
  %50 = getelementptr inbounds %union.Vec4, ptr %15, i32 0, i32 0
  %51 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %50, i32 0, i32 0
  %52 = extractvalue { <2 x float>, <2 x float> } %49, 0
  store <2 x float> %52, ptr %51, align 4
  %53 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %50, i32 0, i32 1
  %54 = extractvalue { <2 x float>, <2 x float> } %49, 1
  store <2 x float> %54, ptr %53, align 4
  %55 = getelementptr inbounds [4 x %union.Vec4], ptr %0, i64 0, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %55, ptr align 4 %15, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  %56 = load float, ptr %13, align 4, !tbaa !5
  %57 = load float, ptr %12, align 4, !tbaa !5
  %58 = fsub float %56, %57
  %59 = fdiv float -2.000000e+00, %58
  %60 = load float, ptr %13, align 4, !tbaa !5
  %61 = load float, ptr %12, align 4, !tbaa !5
  %62 = fadd float %60, %61
  %63 = fneg float %62
  %64 = load float, ptr %13, align 4, !tbaa !5
  %65 = load float, ptr %12, align 4, !tbaa !5
  %66 = fsub float %64, %65
  %67 = fdiv float %63, %66
  %68 = call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef %59, float noundef %67)
  %69 = getelementptr inbounds %union.Vec4, ptr %16, i32 0, i32 0
  %70 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %69, i32 0, i32 0
  %71 = extractvalue { <2 x float>, <2 x float> } %68, 0
  store <2 x float> %71, ptr %70, align 4
  %72 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %69, i32 0, i32 1
  %73 = extractvalue { <2 x float>, <2 x float> } %68, 1
  store <2 x float> %73, ptr %72, align 4
  %74 = getelementptr inbounds [4 x %union.Vec4], ptr %0, i64 0, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %74, ptr align 4 %16, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #4
  %75 = call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %76 = getelementptr inbounds %union.Vec4, ptr %17, i32 0, i32 0
  %77 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %76, i32 0, i32 0
  %78 = extractvalue { <2 x float>, <2 x float> } %75, 0
  store <2 x float> %78, ptr %77, align 4
  %79 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %76, i32 0, i32 1
  %80 = extractvalue { <2 x float>, <2 x float> } %75, 1
  store <2 x float> %80, ptr %79, align 4
  %81 = getelementptr inbounds [4 x %union.Vec4], ptr %0, i64 0, i64 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %81, ptr align 4 %17, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 16, !10}
!10 = !{!7, !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"

%union.Mat4 = type { [4 x %union.Vec4] }
%union.Vec4 = type { %struct.anon.3 }
%struct.anon.3 = type { float, float, float, float }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z13mat4_ortho_glffffff(ptr dead_on_unwind noalias nocapture writable writeonly sret(%union.Mat4) align 4 %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6) local_unnamed_addr #1 {
  %8 = fsub float %2, %1
  %9 = fdiv float 2.000000e+00, %8
  %10 = fadd float %1, %2
  %11 = fneg float %10
  %12 = fdiv float %11, %8
  %13 = tail call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef %9, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef %12)
  %14 = extractvalue { <2 x float>, <2 x float> } %13, 0
  %15 = extractvalue { <2 x float>, <2 x float> } %13, 1
  store <2 x float> %14, ptr %0, align 4
  %.sroa.46.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  store <2 x float> %15, ptr %.sroa.46.0..sroa_idx, align 4, !tbaa !5
  %16 = fsub float %3, %4
  %17 = fdiv float 2.000000e+00, %16
  %18 = fadd float %3, %4
  %19 = fneg float %18
  %20 = fdiv float %19, %16
  %21 = tail call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef 0.000000e+00, float noundef %17, float noundef 0.000000e+00, float noundef %20)
  %22 = extractvalue { <2 x float>, <2 x float> } %21, 0
  %23 = extractvalue { <2 x float>, <2 x float> } %21, 1
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  store <2 x float> %22, ptr %24, align 4
  %.sroa.44.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 24
  store <2 x float> %23, ptr %.sroa.44.0..sroa_idx, align 4, !tbaa !5
  %25 = fsub float %6, %5
  %26 = fdiv float -2.000000e+00, %25
  %27 = fadd float %5, %6
  %28 = fneg float %27
  %29 = fdiv float %28, %25
  %30 = tail call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef %26, float noundef %29)
  %31 = extractvalue { <2 x float>, <2 x float> } %30, 0
  %32 = extractvalue { <2 x float>, <2 x float> } %30, 1
  %33 = getelementptr inbounds i8, ptr %0, i64 32
  store <2 x float> %31, ptr %33, align 4
  %.sroa.42.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 40
  store <2 x float> %32, ptr %.sroa.42.0..sroa_idx, align 4, !tbaa !5
  %34 = tail call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %35 = extractvalue { <2 x float>, <2 x float> } %34, 0
  %36 = extractvalue { <2 x float>, <2 x float> } %34, 1
  %37 = getelementptr inbounds i8, ptr %0, i64 48
  store <2 x float> %35, ptr %37, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 56
  store <2 x float> %36, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  ret void
}

attributes #0 = { inlinehint 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 nounwind 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" }

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


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