; LLVM IR from mvr/jiggle :: src (Area)

; 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.jgVector2 = type { float, float }
%struct.jgArea = type { ptr, %struct.jgAABB, %struct.jgVector2, ptr, i8, %struct.jgVector2, %struct.jgVector2, float, i8, float, float, i8 }
%struct.jgAABB = type { %struct.jgVector2, %struct.jgVector2, i8 }
%struct.jgList = type { ptr, i32, i32 }
%struct.jgParticle = type { float, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, %struct.jgVector2, float, float, i8, i8, ptr }

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @jgListGet(ptr noundef, i32 noundef) #1

; 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) #2

; 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 zeroext i1 @jgAreaContains(ptr noundef %0, <2 x float> %1) #3 {
  %3 = alloca i1, align 1
  %4 = alloca %struct.jgVector2, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca %struct.jgVector2, align 4
  %9 = alloca %struct.jgVector2, align 4
  %10 = alloca %struct.jgVector2, align 4
  %11 = alloca %struct.jgVector2, align 4
  %12 = alloca i32, align 4
  store <2 x float> %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.jgArea, ptr %13, i32 0, i32 1
  %15 = load <2 x float>, ptr %4, align 4
  %16 = call zeroext i1 @jgAABBContains(ptr noundef byval(%struct.jgAABB) align 8 %14, <2 x float> %15)
  br i1 %16, label %18, label %17

17:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %112

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.jgArea, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct.jgList, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.jgArea, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct.jgList, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 8, !tbaa !19
  %29 = sub nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds ptr, ptr %23, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.jgParticle, ptr %32, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %33, i64 8, i1 false), !tbaa.struct !20
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.jgArea, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = call ptr @jgListGet(ptr noundef %36, i32 noundef 0)
  store ptr %37, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %101, %18
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.jgArea, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = getelementptr inbounds %struct.jgList, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !19
  %45 = icmp slt i32 %39, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %109

47:                                               ; preds = %38
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.jgParticle, ptr %48, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %49, i64 8, i1 false), !tbaa.struct !20
  %50 = getelementptr inbounds %struct.jgVector2, ptr %8, i32 0, i32 0
  %51 = load float, ptr %50, align 4, !tbaa !22
  %52 = getelementptr inbounds %struct.jgVector2, ptr %9, i32 0, i32 0
  %53 = load float, ptr %52, align 4, !tbaa !22
  %54 = fcmp ogt float %51, %53
  br i1 %54, label %55, label %56

55:                                               ; preds = %47
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !20
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !20
  br label %57

56:                                               ; preds = %47
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !20
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !20
  br label %57

57:                                               ; preds = %56, %55
  %58 = getelementptr inbounds %struct.jgVector2, ptr %8, i32 0, i32 0
  %59 = load float, ptr %58, align 4, !tbaa !22
  %60 = getelementptr inbounds %struct.jgVector2, ptr %4, i32 0, i32 0
  %61 = load float, ptr %60, align 4, !tbaa !22
  %62 = fcmp olt float %59, %61
  %63 = zext i1 %62 to i32
  %64 = getelementptr inbounds %struct.jgVector2, ptr %4, i32 0, i32 0
  %65 = load float, ptr %64, align 4, !tbaa !22
  %66 = getelementptr inbounds %struct.jgVector2, ptr %9, i32 0, i32 0
  %67 = load float, ptr %66, align 4, !tbaa !22
  %68 = fcmp ole float %65, %67
  %69 = zext i1 %68 to i32
  %70 = icmp eq i32 %63, %69
  br i1 %70, label %71, label %100

71:                                               ; preds = %57
  %72 = getelementptr inbounds %struct.jgVector2, ptr %4, i32 0, i32 1
  %73 = load float, ptr %72, align 4, !tbaa !23
  %74 = getelementptr inbounds %struct.jgVector2, ptr %10, i32 0, i32 1
  %75 = load float, ptr %74, align 4, !tbaa !23
  %76 = fsub float %73, %75
  %77 = getelementptr inbounds %struct.jgVector2, ptr %11, i32 0, i32 0
  %78 = load float, ptr %77, align 4, !tbaa !22
  %79 = getelementptr inbounds %struct.jgVector2, ptr %10, i32 0, i32 0
  %80 = load float, ptr %79, align 4, !tbaa !22
  %81 = fsub float %78, %80
  %82 = fmul float %76, %81
  %83 = getelementptr inbounds %struct.jgVector2, ptr %11, i32 0, i32 1
  %84 = load float, ptr %83, align 4, !tbaa !23
  %85 = getelementptr inbounds %struct.jgVector2, ptr %10, i32 0, i32 1
  %86 = load float, ptr %85, align 4, !tbaa !23
  %87 = fsub float %84, %86
  %88 = getelementptr inbounds %struct.jgVector2, ptr %4, i32 0, i32 0
  %89 = load float, ptr %88, align 4, !tbaa !22
  %90 = getelementptr inbounds %struct.jgVector2, ptr %10, i32 0, i32 0
  %91 = load float, ptr %90, align 4, !tbaa !22
  %92 = fsub float %89, %91
  %93 = fmul float %87, %92
  %94 = fcmp olt float %82, %93
  br i1 %94, label %95, label %100

95:                                               ; preds = %71
  %96 = load i32, ptr %6, align 4, !tbaa !9
  %97 = icmp ne i32 %96, 0
  %98 = xor i1 %97, true
  %99 = zext i1 %98 to i32
  store i32 %99, ptr %6, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %95, %71, %57
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !20
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %12, align 4, !tbaa !9
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %12, align 4, !tbaa !9
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.jgArea, ptr %104, i32 0, i32 0
  %106 = load ptr, ptr %105, align 8, !tbaa !11
  %107 = load i32, ptr %12, align 4, !tbaa !9
  %108 = call ptr @jgListGet(ptr noundef %106, i32 noundef %107)
  store ptr %108, ptr %7, align 8, !tbaa !5
  br label %38, !llvm.loop !24

109:                                              ; preds = %46
  %110 = load i32, ptr %6, align 4, !tbaa !9
  %111 = icmp ne i32 %110, 0
  store i1 %111, ptr %3, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %112

112:                                              ; preds = %109, %17
  %113 = load i1, ptr %3, align 1
  ret i1 %113
}

declare zeroext i1 @jgAABBContains(ptr noundef byval(%struct.jgAABB) align 8, <2 x float>) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 nounwind willreturn memory(argmem: readwrite) }
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 = { "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 #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"jgArea", !6, i64 0, !13, i64 8, !14, i64 28, !6, i64 40, !16, i64 48, !14, i64 52, !14, i64 60, !15, i64 68, !16, i64 72, !15, i64 76, !15, i64 80, !16, i64 84}
!13 = !{!"jgAABB", !14, i64 0, !14, i64 8, !16, i64 16}
!14 = !{!"jgVector2", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"jgList", !6, i64 0, !10, i64 8, !10, i64 12}
!19 = !{!18, !10, i64 8}
!20 = !{i64 0, i64 4, !21, i64 4, i64 4, !21}
!21 = !{!15, !15, i64 0}
!22 = !{!14, !15, i64 0}
!23 = !{!14, !15, i64 4}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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.jgAABB = type { %struct.jgVector2, %struct.jgVector2, i8 }
%struct.jgVector2 = type { float, float }

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @jgListGet(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @jgAreaContains(ptr noundef %0, <2 x float> %1) local_unnamed_addr #1 {
  %3 = extractelement <2 x float> %1, i64 0
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = tail call zeroext i1 @jgAABBContains(ptr noundef nonnull byval(%struct.jgAABB) align 8 %4, <2 x float> %1) #3
  br i1 %5, label %6, label %._crit_edge

6:                                                ; preds = %2
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !17
  %11 = sext i32 %10 to i64
  %12 = getelementptr ptr, ptr %8, i64 %11
  %13 = getelementptr i8, ptr %12, i64 -8
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  %15 = getelementptr inbounds i8, ptr %14, i64 4
  %16 = load <2 x float>, ptr %15, align 4, !tbaa !19
  %17 = tail call ptr @jgListGet(ptr noundef nonnull %7, i32 noundef 0)
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load i32, ptr %19, align 8, !tbaa !17
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6
  %22 = shufflevector <2 x float> %16, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  br label %24

._crit_edge.loopexit:                             ; preds = %50
  %23 = icmp ne i32 %.1, 0
  br label %._crit_edge

24:                                               ; preds = %.lr.ph, %50
  %25 = phi ptr [ %18, %.lr.ph ], [ %53, %50 ]
  %.042 = phi i32 [ 0, %.lr.ph ], [ %51, %50 ]
  %.03639 = phi i32 [ 0, %.lr.ph ], [ %.1, %50 ]
  %.03738 = phi ptr [ %17, %.lr.ph ], [ %52, %50 ]
  %26 = phi <2 x float> [ %22, %.lr.ph ], [ %29, %50 ]
  %27 = getelementptr inbounds i8, ptr %.03738, i64 4
  %28 = load <2 x float>, ptr %27, align 4, !tbaa !19
  %29 = shufflevector <2 x float> %28, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %30 = extractelement <2 x float> %28, i64 0
  %31 = fcmp olt float %30, %3
  %32 = extractelement <2 x float> %26, i64 1
  %33 = fcmp ugt float %3, %32
  %34 = xor i1 %33, %31
  br i1 %34, label %35, label %50

35:                                               ; preds = %24
  %36 = fcmp ogt float %30, %32
  %37 = insertelement <2 x i1> poison, i1 %36, i64 0
  %38 = shufflevector <2 x i1> %37, <2 x i1> poison, <2 x i32> zeroinitializer
  %39 = select <2 x i1> %38, <2 x float> %29, <2 x float> %26
  %40 = select <2 x i1> %38, <2 x float> %26, <2 x float> %29
  %41 = fsub <2 x float> %39, %40
  %42 = shufflevector <2 x float> %40, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %43 = fsub <2 x float> %1, %42
  %44 = fmul <2 x float> %41, %43
  %45 = extractelement <2 x float> %44, i64 0
  %46 = extractelement <2 x float> %44, i64 1
  %47 = fcmp olt float %46, %45
  br i1 %47, label %48, label %50

48:                                               ; preds = %35
  %.not = icmp eq i32 %.03639, 0
  %49 = zext i1 %.not to i32
  br label %50

50:                                               ; preds = %48, %35, %24
  %.1 = phi i32 [ %49, %48 ], [ %.03639, %35 ], [ %.03639, %24 ]
  %51 = add nuw nsw i32 %.042, 1
  %52 = tail call ptr @jgListGet(ptr noundef nonnull %25, i32 noundef %51)
  %53 = load ptr, ptr %0, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i64 8
  %55 = load i32, ptr %54, align 8, !tbaa !17
  %56 = icmp slt i32 %51, %55
  br i1 %56, label %24, label %._crit_edge.loopexit, !llvm.loop !20

._crit_edge:                                      ; preds = %6, %._crit_edge.loopexit, %2
  %.035 = phi i1 [ false, %2 ], [ false, %6 ], [ %23, %._crit_edge.loopexit ]
  ret i1 %.035
}

declare zeroext i1 @jgAABBContains(ptr noundef byval(%struct.jgAABB) align 8, <2 x float>) local_unnamed_addr #2

attributes #0 = { inlinehint 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 = { 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 = { "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, !7, i64 0}
!6 = !{!"jgArea", !7, i64 0, !10, i64 8, !11, i64 28, !7, i64 40, !13, i64 48, !11, i64 52, !11, i64 60, !12, i64 68, !13, i64 72, !12, i64 76, !12, i64 80, !13, i64 84}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"jgAABB", !11, i64 0, !11, i64 8, !13, i64 16}
!11 = !{!"jgVector2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"jgList", !7, i64 0, !16, i64 8, !16, i64 12}
!16 = !{!"int", !8, i64 0}
!17 = !{!15, !16, i64 8}
!18 = !{!7, !7, i64 0}
!19 = !{!12, !12, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass