; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: nounwind uwtable
define dso_local float @jgAreaArea(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.jgVector2, align 4
  %8 = alloca %struct.jgVector2, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 0.000000e+00, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.jgArea, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = call ptr @jgListGet(ptr noundef %11, i32 noundef 0)
  store ptr %12, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.jgArea, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = call ptr @jgListGet(ptr noundef %15, i32 noundef 1)
  store ptr %16, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !16
  br label %17

17:                                               ; preds = %72, %1
  %18 = load i32, ptr %6, align 4, !tbaa !16
  %19 = load ptr, ptr %2, 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 1
  %23 = load i32, ptr %22, align 8, !tbaa !18
  %24 = icmp slt i32 %18, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %74

26:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.jgParticle, ptr %27, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 %28, i64 8, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.jgParticle, ptr %29, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %30, i64 8, i1 false), !tbaa.struct !20
  %31 = getelementptr inbounds %struct.jgVector2, ptr %7, i32 0, i32 0
  %32 = load float, ptr %31, align 4, !tbaa !21
  %33 = getelementptr inbounds %struct.jgVector2, ptr %8, i32 0, i32 1
  %34 = load float, ptr %33, align 4, !tbaa !22
  %35 = getelementptr inbounds %struct.jgVector2, ptr %8, i32 0, i32 0
  %36 = load float, ptr %35, align 4, !tbaa !21
  %37 = getelementptr inbounds %struct.jgVector2, ptr %7, i32 0, i32 1
  %38 = load float, ptr %37, align 4, !tbaa !22
  %39 = fmul float %36, %38
  %40 = fneg float %39
  %41 = call float @llvm.fmuladd.f32(float %32, float %34, float %40)
  %42 = load float, ptr %3, align 4, !tbaa !9
  %43 = fadd float %42, %41
  store float %43, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %44

44:                                               ; preds = %26
  %45 = load i32, ptr %6, align 4, !tbaa !16
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %6, align 4, !tbaa !16
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.jgArea, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = load i32, ptr %6, align 4, !tbaa !16
  %51 = call ptr @jgListGet(ptr noundef %49, i32 noundef %50)
  store ptr %51, ptr %4, align 8, !tbaa !5
  %52 = load i32, ptr %6, align 4, !tbaa !16
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.jgArea, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = getelementptr inbounds %struct.jgList, ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 8, !tbaa !18
  %58 = sub nsw i32 %57, 1
  %59 = icmp eq i32 %52, %58
  br i1 %59, label %60, label %65

60:                                               ; preds = %44
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.jgArea, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !11
  %64 = call ptr @jgListGet(ptr noundef %63, i32 noundef 0)
  br label %72

65:                                               ; preds = %44
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.jgArea, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !11
  %69 = load i32, ptr %6, align 4, !tbaa !16
  %70 = add nsw i32 %69, 1
  %71 = call ptr @jgListGet(ptr noundef %68, i32 noundef %70)
  br label %72

72:                                               ; preds = %65, %60
  %73 = phi ptr [ %64, %60 ], [ %71, %65 ]
  store ptr %73, ptr %5, align 8, !tbaa !5
  br label %17, !llvm.loop !23

74:                                               ; preds = %25
  %75 = load float, ptr %3, align 4, !tbaa !9
  %76 = fneg float %75
  %77 = fdiv float %76, 2.000000e+00
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret float %77
}

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

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

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

; Function Attrs: nounwind uwtable
define dso_local float @jgAreaArea(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = tail call ptr @jgListGet(ptr noundef %2, i32 noundef 0)
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = tail call ptr @jgListGet(ptr noundef %4, i32 noundef 1)
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !14
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %10 = fmul float %17, -5.000000e-01
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %.0.lcssa = phi float [ -0.000000e+00, %1 ], [ %10, %._crit_edge.loopexit ]
  ret float %.0.lcssa

.lr.ph:                                           ; preds = %1, %.lr.ph
  %11 = phi ptr [ %27, %.lr.ph ], [ %6, %1 ]
  %.024 = phi float [ %17, %.lr.ph ], [ 0.000000e+00, %1 ]
  %.01723 = phi ptr [ %19, %.lr.ph ], [ %3, %1 ]
  %.01822 = phi ptr [ %26, %.lr.ph ], [ %5, %1 ]
  %.01921 = phi i32 [ %18, %.lr.ph ], [ 0, %1 ]
  %12 = getelementptr inbounds i8, ptr %.01723, i64 4
  %.sroa.01.0.copyload = load float, ptr %12, align 4, !tbaa !17
  %.sroa.42.0..sroa_idx = getelementptr inbounds i8, ptr %.01723, i64 8
  %.sroa.42.0.copyload = load float, ptr %.sroa.42.0..sroa_idx, align 4, !tbaa !17
  %13 = getelementptr inbounds i8, ptr %.01822, i64 4
  %.sroa.0.0.copyload = load float, ptr %13, align 4, !tbaa !17
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %.01822, i64 8
  %.sroa.4.0.copyload = load float, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !17
  %14 = fneg float %.sroa.0.0.copyload
  %15 = fmul float %.sroa.42.0.copyload, %14
  %16 = tail call float @llvm.fmuladd.f32(float %.sroa.01.0.copyload, float %.sroa.4.0.copyload, float %15)
  %17 = fadd float %.024, %16
  %18 = add nuw nsw i32 %.01921, 1
  %19 = tail call ptr @jgListGet(ptr noundef nonnull %11, i32 noundef %18)
  %20 = load ptr, ptr %0, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = add i32 %22, -2
  %24 = icmp eq i32 %.01921, %23
  %25 = add nuw nsw i32 %.01921, 2
  %.sink = select i1 %24, i32 0, i32 %25
  %26 = tail call ptr @jgListGet(ptr noundef nonnull %20, i32 noundef %.sink)
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !14
  %30 = icmp slt i32 %18, %29
  br i1 %30, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18
}

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !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, !16, i64 8}
!15 = !{!"jgList", !7, i64 0, !16, i64 8, !16, i64 12}
!16 = !{!"int", !8, i64 0}
!17 = !{!12, !12, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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