; LLVM IR from Mithreindeir/VelocityRaptor :: VelocityRaptor/src (vrTriangulation)

; 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.vrTriangle = type { %struct.vrVec2, %struct.vrVec2, %struct.vrVec2 }
%struct.vrVec2 = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local i32 @vrTriangleCCW(ptr noundef byval(%struct.vrTriangle) align 8 %0) #0 {
  %2 = getelementptr inbounds %struct.vrTriangle, ptr %0, i32 0, i32 1
  %3 = getelementptr inbounds %struct.vrVec2, ptr %2, i32 0, i32 0
  %4 = load float, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.vrTriangle, ptr %0, i32 0, i32 0
  %6 = getelementptr inbounds %struct.vrVec2, ptr %5, i32 0, i32 0
  %7 = load float, ptr %6, align 8, !tbaa !11
  %8 = fsub float %4, %7
  %9 = getelementptr inbounds %struct.vrTriangle, ptr %0, i32 0, i32 2
  %10 = getelementptr inbounds %struct.vrVec2, ptr %9, i32 0, i32 1
  %11 = load float, ptr %10, align 4, !tbaa !12
  %12 = getelementptr inbounds %struct.vrTriangle, ptr %0, i32 0, i32 0
  %13 = getelementptr inbounds %struct.vrVec2, ptr %12, i32 0, i32 1
  %14 = load float, ptr %13, align 4, !tbaa !13
  %15 = fsub float %11, %14
  %16 = getelementptr inbounds %struct.vrTriangle, ptr %0, i32 0, i32 2
  %17 = getelementptr inbounds %struct.vrVec2, ptr %16, i32 0, i32 0
  %18 = load float, ptr %17, align 8, !tbaa !14
  %19 = getelementptr inbounds %struct.vrTriangle, ptr %0, i32 0, i32 0
  %20 = getelementptr inbounds %struct.vrVec2, ptr %19, i32 0, i32 0
  %21 = load float, ptr %20, align 8, !tbaa !11
  %22 = fsub float %18, %21
  %23 = getelementptr inbounds %struct.vrTriangle, ptr %0, i32 0, i32 1
  %24 = getelementptr inbounds %struct.vrVec2, ptr %23, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !15
  %26 = getelementptr inbounds %struct.vrTriangle, ptr %0, i32 0, i32 0
  %27 = getelementptr inbounds %struct.vrVec2, ptr %26, i32 0, i32 1
  %28 = load float, ptr %27, align 4, !tbaa !13
  %29 = fsub float %25, %28
  %30 = fmul float %22, %29
  %31 = fneg float %30
  %32 = call float @llvm.fmuladd.f32(float %8, float %15, float %31)
  %33 = fcmp ogt float %32, 0.000000e+00
  %34 = zext i1 %33 to i32
  ret i32 %34
}

; 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, !8, i64 8}
!6 = !{!"vrTriangle", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"vrVec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!6, !8, i64 0}
!12 = !{!6, !8, i64 20}
!13 = !{!6, !8, i64 4}
!14 = !{!6, !8, i64 16}
!15 = !{!6, !8, i64 12}


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

%struct.vrTriangle = type { %struct.vrVec2, %struct.vrVec2, %struct.vrVec2 }
%struct.vrVec2 = type { float, float }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local range(i32 0, 2) i32 @vrTriangleCCW(ptr nocapture noundef readonly byval(%struct.vrTriangle) align 8 %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load float, ptr %2, align 8, !tbaa !5
  %4 = load float, ptr %0, align 8, !tbaa !11
  %5 = fsub float %3, %4
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = getelementptr inbounds i8, ptr %0, i64 20
  %8 = load float, ptr %7, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load float, ptr %9, align 4, !tbaa !13
  %11 = fsub float %8, %10
  %12 = load float, ptr %6, align 8, !tbaa !14
  %13 = fsub float %12, %4
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  %15 = load float, ptr %14, align 4, !tbaa !15
  %16 = fsub float %15, %10
  %17 = fneg float %13
  %18 = fmul float %16, %17
  %19 = tail call float @llvm.fmuladd.f32(float %5, float %11, float %18)
  %20 = fcmp ogt float %19, 0.000000e+00
  %21 = zext i1 %20 to i32
  ret i32 %21
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 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, !8, i64 8}
!6 = !{!"vrTriangle", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"vrVec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!6, !8, i64 0}
!12 = !{!6, !8, i64 20}
!13 = !{!6, !8, i64 4}
!14 = !{!6, !8, i64 16}
!15 = !{!6, !8, i64 12}


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