; LLVM IR from jdeokkim/ferox :: src (geometry)

; 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.frVertices_ = type { [8 x %struct.frVector2_], i32 }
%struct.frVector2_ = type { 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @frSetPolygonVertices(ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @frSetRectangleDimensions(ptr noundef %0, float noundef %1, float noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca %struct.frVertices_, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %18, label %12

12:                                               ; preds = %3
  %13 = load float, ptr %5, align 4, !tbaa !9
  %14 = fcmp ole float %13, 0.000000e+00
  br i1 %14, label %18, label %15

15:                                               ; preds = %12
  %16 = load float, ptr %6, align 4, !tbaa !9
  %17 = fcmp ole float %16, 0.000000e+00
  br i1 %17, label %18, label %19

18:                                               ; preds = %15, %12, %3
  br label %57

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %20 = load float, ptr %5, align 4, !tbaa !9
  %21 = fmul float 5.000000e-01, %20
  store float %21, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %22 = load float, ptr %6, align 4, !tbaa !9
  %23 = fmul float 5.000000e-01, %22
  store float %23, ptr %8, align 4, !tbaa !9
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.frVertices_, ptr %9, i32 0, i32 0
  %26 = getelementptr inbounds %struct.frVector2_, ptr %25, i32 0, i32 0
  %27 = load float, ptr %7, align 4, !tbaa !9
  %28 = fneg float %27
  store float %28, ptr %26, align 4, !tbaa !11
  %29 = getelementptr inbounds %struct.frVector2_, ptr %25, i32 0, i32 1
  %30 = load float, ptr %8, align 4, !tbaa !9
  %31 = fneg float %30
  store float %31, ptr %29, align 4, !tbaa !13
  %32 = getelementptr inbounds %struct.frVector2_, ptr %25, i64 1
  %33 = getelementptr inbounds %struct.frVector2_, ptr %32, i32 0, i32 0
  %34 = load float, ptr %7, align 4, !tbaa !9
  %35 = fneg float %34
  store float %35, ptr %33, align 4, !tbaa !11
  %36 = getelementptr inbounds %struct.frVector2_, ptr %32, i32 0, i32 1
  %37 = load float, ptr %8, align 4, !tbaa !9
  store float %37, ptr %36, align 4, !tbaa !13
  %38 = getelementptr inbounds %struct.frVector2_, ptr %25, i64 2
  %39 = getelementptr inbounds %struct.frVector2_, ptr %38, i32 0, i32 0
  %40 = load float, ptr %7, align 4, !tbaa !9
  store float %40, ptr %39, align 4, !tbaa !11
  %41 = getelementptr inbounds %struct.frVector2_, ptr %38, i32 0, i32 1
  %42 = load float, ptr %8, align 4, !tbaa !9
  store float %42, ptr %41, align 4, !tbaa !13
  %43 = getelementptr inbounds %struct.frVector2_, ptr %25, i64 3
  %44 = getelementptr inbounds %struct.frVector2_, ptr %43, i32 0, i32 0
  %45 = load float, ptr %7, align 4, !tbaa !9
  store float %45, ptr %44, align 4, !tbaa !11
  %46 = getelementptr inbounds %struct.frVector2_, ptr %43, i32 0, i32 1
  %47 = load float, ptr %8, align 4, !tbaa !9
  %48 = fneg float %47
  store float %48, ptr %46, align 4, !tbaa !13
  %49 = getelementptr inbounds %struct.frVector2_, ptr %25, i64 4
  %50 = getelementptr inbounds %struct.frVector2_, ptr %25, i64 8
  br label %51

51:                                               ; preds = %51, %19
  %52 = phi ptr [ %49, %19 ], [ %53, %51 ]
  call void @llvm.memset.p0.i64(ptr align 4 %52, i8 0, i64 8, i1 false)
  %53 = getelementptr inbounds %struct.frVector2_, ptr %52, i64 1
  %54 = icmp eq ptr %53, %50
  br i1 %54, label %55, label %51

55:                                               ; preds = %51
  %56 = getelementptr inbounds %struct.frVertices_, ptr %9, i32 0, i32 1
  store i32 4, ptr %56, align 4, !tbaa !14
  call void @frSetPolygonVertices(ptr noundef %24, ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %57

57:                                               ; preds = %55, %18
  ret void
}

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

%struct.frVertices_ = type { [8 x %struct.frVector2_], i32 }
%struct.frVector2_ = type { float, float }

; Function Attrs: nounwind uwtable
declare dso_local void @frSetPolygonVertices(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @frSetRectangleDimensions(ptr noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.frVertices_, align 8
  %5 = icmp eq ptr %0, null
  %6 = fcmp ole float %1, 0.000000e+00
  %or.cond = or i1 %5, %6
  %7 = fcmp ole float %2, 0.000000e+00
  %or.cond3 = or i1 %or.cond, %7
  br i1 %or.cond3, label %20, label %8

8:                                                ; preds = %3
  %9 = insertelement <2 x float> poison, float %1, i64 0
  %10 = insertelement <2 x float> %9, float %2, i64 1
  %11 = fmul <2 x float> %10, <float 5.000000e-01, float 5.000000e-01>
  %12 = fneg <2 x float> %11
  store <2 x float> %12, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  %14 = extractelement <2 x float> %12, i64 0
  store float %14, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %4, i64 12
  %16 = shufflevector <2 x float> %11, <2 x float> poison, <4 x i32> <i32 1, i32 0, i32 1, i32 0>
  store <4 x float> %16, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %4, i64 28
  %18 = extractelement <2 x float> %12, i64 1
  store float %18, ptr %17, align 4, !tbaa !11
  %scevgep = getelementptr inbounds i8, ptr %4, i64 32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %scevgep, i8 0, i64 32, i1 false)
  %19 = getelementptr inbounds i8, ptr %4, i64 64
  store i32 4, ptr %19, align 8, !tbaa !12
  call void @frSetPolygonVertices(ptr noundef nonnull %0, ptr noundef nonnull %4)
  br label %20

20:                                               ; preds = %3, %8
  ret void
}

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

!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"}
!9 = !{!10, !6, i64 0}
!10 = !{!"frVector2_", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = !{!13, !14, i64 64}
!13 = !{!"frVertices_", !7, i64 0, !14, i64 64}
!14 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass