; 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.frMaterial_ = type { float, float, float }
%struct.frVertices_ = type { [8 x %struct.frVector2_], i32 }
%struct.frVector2_ = type { float, float }
%struct.frShape_ = type { i32, %union.frShapeData_, %struct.frMaterial_, float }
%union.frShapeData_ = type { %struct.anon.0 }
%struct.anon.0 = type { %struct.frVertices_, %struct.frVertices_ }

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @frCreateRectangle(<2 x float> %0, float %1, float noundef %2, float noundef %3) #3 {
  %5 = alloca ptr, align 8
  %6 = alloca %struct.frMaterial_, align 4
  %7 = alloca { <2 x float>, float }, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca %struct.frVertices_, align 4
  %14 = getelementptr inbounds { <2 x float>, float }, ptr %7, i32 0, i32 0
  store <2 x float> %0, ptr %14, align 4
  %15 = getelementptr inbounds { <2 x float>, float }, ptr %7, i32 0, i32 1
  store float %1, ptr %15, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %7, i64 12, i1 false)
  store float %2, ptr %8, align 4, !tbaa !5
  store float %3, ptr %9, align 4, !tbaa !5
  %16 = load float, ptr %8, align 4, !tbaa !5
  %17 = fcmp ole float %16, 0.000000e+00
  br i1 %17, label %21, label %18

18:                                               ; preds = %4
  %19 = load float, ptr %9, align 4, !tbaa !5
  %20 = fcmp ole float %19, 0.000000e+00
  br i1 %20, label %21, label %22

21:                                               ; preds = %18, %4
  store ptr null, ptr %5, align 8
  br label %66

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %23 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 156) #6
  store ptr %23, ptr %10, align 8, !tbaa !9
  %24 = load ptr, ptr %10, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.frShape_, ptr %24, i32 0, i32 0
  store i32 2, ptr %25, align 4, !tbaa !11
  %26 = load ptr, ptr %10, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.frShape_, ptr %26, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %6, i64 12, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %28 = load float, ptr %8, align 4, !tbaa !5
  %29 = fmul float 5.000000e-01, %28
  store float %29, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %30 = load float, ptr %9, align 4, !tbaa !5
  %31 = fmul float 5.000000e-01, %30
  store float %31, ptr %12, align 4, !tbaa !5
  %32 = load ptr, ptr %10, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.frVertices_, ptr %13, i32 0, i32 0
  %34 = getelementptr inbounds %struct.frVector2_, ptr %33, i32 0, i32 0
  %35 = load float, ptr %11, align 4, !tbaa !5
  %36 = fneg float %35
  store float %36, ptr %34, align 4, !tbaa !16
  %37 = getelementptr inbounds %struct.frVector2_, ptr %33, i32 0, i32 1
  %38 = load float, ptr %12, align 4, !tbaa !5
  %39 = fneg float %38
  store float %39, ptr %37, align 4, !tbaa !18
  %40 = getelementptr inbounds %struct.frVector2_, ptr %33, i64 1
  %41 = getelementptr inbounds %struct.frVector2_, ptr %40, i32 0, i32 0
  %42 = load float, ptr %11, align 4, !tbaa !5
  %43 = fneg float %42
  store float %43, ptr %41, align 4, !tbaa !16
  %44 = getelementptr inbounds %struct.frVector2_, ptr %40, i32 0, i32 1
  %45 = load float, ptr %12, align 4, !tbaa !5
  store float %45, ptr %44, align 4, !tbaa !18
  %46 = getelementptr inbounds %struct.frVector2_, ptr %33, i64 2
  %47 = getelementptr inbounds %struct.frVector2_, ptr %46, i32 0, i32 0
  %48 = load float, ptr %11, align 4, !tbaa !5
  store float %48, ptr %47, align 4, !tbaa !16
  %49 = getelementptr inbounds %struct.frVector2_, ptr %46, i32 0, i32 1
  %50 = load float, ptr %12, align 4, !tbaa !5
  store float %50, ptr %49, align 4, !tbaa !18
  %51 = getelementptr inbounds %struct.frVector2_, ptr %33, i64 3
  %52 = getelementptr inbounds %struct.frVector2_, ptr %51, i32 0, i32 0
  %53 = load float, ptr %11, align 4, !tbaa !5
  store float %53, ptr %52, align 4, !tbaa !16
  %54 = getelementptr inbounds %struct.frVector2_, ptr %51, i32 0, i32 1
  %55 = load float, ptr %12, align 4, !tbaa !5
  %56 = fneg float %55
  store float %56, ptr %54, align 4, !tbaa !18
  %57 = getelementptr inbounds %struct.frVector2_, ptr %33, i64 4
  %58 = getelementptr inbounds %struct.frVector2_, ptr %33, i64 8
  br label %59

59:                                               ; preds = %59, %22
  %60 = phi ptr [ %57, %22 ], [ %61, %59 ]
  call void @llvm.memset.p0.i64(ptr align 4 %60, i8 0, i64 8, i1 false)
  %61 = getelementptr inbounds %struct.frVector2_, ptr %60, i64 1
  %62 = icmp eq ptr %61, %58
  br i1 %62, label %63, label %59

63:                                               ; preds = %59
  %64 = getelementptr inbounds %struct.frVertices_, ptr %13, i32 0, i32 1
  store i32 4, ptr %64, align 4, !tbaa !19
  call void @frSetPolygonVertices(ptr noundef %32, ptr noundef %13)
  %65 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %65, ptr %5, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %66

66:                                               ; preds = %63, %21
  %67 = load ptr, ptr %5, align 8
  ret ptr %67
}

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

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(0,1) "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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"frShape_", !13, i64 0, !7, i64 4, !14, i64 140, !6, i64 152}
!13 = !{!"int", !7, i64 0}
!14 = !{!"frMaterial_", !6, i64 0, !6, i64 4, !6, i64 8}
!15 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!16 = !{!17, !6, i64 0}
!17 = !{!"frVector2_", !6, i64 0, !6, i64 4}
!18 = !{!17, !6, i64 4}
!19 = !{!20, !13, i64 64}
!20 = !{!"frVertices_", !7, i64 0, !13, i64 64}


; 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: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @frCreateRectangle(<2 x float> %0, float %1, float noundef %2, float noundef %3) local_unnamed_addr #1 {
  %5 = alloca %struct.frVertices_, align 8
  %6 = fcmp ole float %2, 0.000000e+00
  %7 = fcmp ole float %3, 0.000000e+00
  %or.cond = or i1 %6, %7
  br i1 %or.cond, label %22, label %8

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

22:                                               ; preds = %4, %8
  %.0 = phi ptr [ %9, %8 ], [ null, %4 ]
  ret ptr %.0
}

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

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind allocsize(0,1) }

!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, !7, i64 0}
!6 = !{!"frShape_", !7, i64 0, !8, i64 4, !10, i64 140, !11, i64 152}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"frMaterial_", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"float", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"frVector2_", !11, i64 0, !11, i64 4}
!15 = !{!14, !11, i64 4}
!16 = !{!17, !7, i64 64}
!17 = !{!"frVertices_", !8, i64 0, !7, i64 64}


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