; LLVM IR from heroseh/cgm :: cgm (CgmMat4x4_ortho)

; 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.CgmVec4 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float, float, 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = !{i64 0, i64 16, !17}
!17 = !{!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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @CgmMat4x4_ortho(ptr nocapture noundef writeonly %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6) local_unnamed_addr #0 {
  %8 = insertelement <2 x float> poison, float %2, i64 0
  %9 = insertelement <2 x float> %8, float %4, i64 1
  %10 = insertelement <2 x float> poison, float %1, i64 0
  %11 = insertelement <2 x float> %10, float %3, i64 1
  %12 = fsub <2 x float> %9, %11
  %13 = fsub float %6, %5
  %14 = fadd <2 x float> %11, %9
  %15 = fadd float %5, %6
  %16 = fneg float %15
  %17 = fdiv float %16, %13
  %18 = extractelement <2 x float> %12, i64 0
  %19 = fdiv float 2.000000e+00, %18
  store float %19, ptr %0, align 4
  %.sroa.210.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 4
  %20 = extractelement <2 x float> %12, i64 1
  %21 = fdiv float 2.000000e+00, %20
  %.sroa.26.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 20
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %.sroa.210.0..sroa_idx, i8 0, i64 16, i1 false)
  store float %21, ptr %.sroa.26.0..sroa_idx, align 4
  %.sroa.37.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 24
  %22 = fdiv float -2.000000e+00, %13
  %.sroa.33.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %.sroa.37.0..sroa_idx, i8 0, i64 16, i1 false)
  store float %22, ptr %.sroa.33.0..sroa_idx, align 4
  %.sroa.44.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 44
  store float 0.000000e+00, ptr %.sroa.44.0..sroa_idx, align 4, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %0, i64 48
  %24 = fneg <2 x float> %14
  %25 = fdiv <2 x float> %24, %12
  store <2 x float> %25, ptr %23, align 4
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 56
  store float %17, ptr %.sroa.3.0..sroa_idx, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 60
  store float 1.000000e+00, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

!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/C++ TBAA"}


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