; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_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"

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

; Function Attrs: nounwind uwtable
define dso_local double @Math_signedAreaPolygon2D(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store double 0.000000e+00, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %47, %2
  %9 = load i32, ptr %6, align 4, !tbaa !9
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = icmp ult i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %50

13:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = add i32 %14, 1
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = urem i32 %15, %16
  store i32 %17, ptr %7, align 4, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds [2 x double], ptr %18, i64 %20
  %22 = getelementptr inbounds [2 x double], ptr %21, i64 0, i64 0
  %23 = load double, ptr %22, align 8, !tbaa !11
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds [2 x double], ptr %24, i64 %26
  %28 = getelementptr inbounds [2 x double], ptr %27, i64 0, i64 1
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = load double, ptr %5, align 8, !tbaa !11
  %31 = call double @llvm.fmuladd.f64(double %23, double %29, double %30)
  store double %31, ptr %5, align 8, !tbaa !11
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds [2 x double], ptr %32, i64 %34
  %36 = getelementptr inbounds [2 x double], ptr %35, i64 0, i64 0
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds [2 x double], ptr %38, i64 %40
  %42 = getelementptr inbounds [2 x double], ptr %41, i64 0, i64 1
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = load double, ptr %5, align 8, !tbaa !11
  %45 = fneg double %37
  %46 = call double @llvm.fmuladd.f64(double %45, double %43, double %44)
  store double %46, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %47

47:                                               ; preds = %13
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = add i32 %48, 1
  store i32 %49, ptr %6, align 4, !tbaa !9
  br label %8, !llvm.loop !13

50:                                               ; preds = %12
  %51 = load double, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %51
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
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, !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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local double @Math_signedAreaPolygon2D(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %3 = zext i32 %1 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.0.lcssa = phi double [ 0.000000e+00, %2 ], [ %17, %.lr.ph ]
  ret double %.0.lcssa

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.018 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %17, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %4 = icmp eq i64 %indvars.iv.next, %3
  %5 = and i64 %indvars.iv.next, 4294967295
  %6 = getelementptr inbounds [2 x double], ptr %0, i64 %indvars.iv
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = select i1 %4, i64 0, i64 %5
  %9 = getelementptr inbounds [2 x double], ptr %0, i64 %8
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = tail call double @llvm.fmuladd.f64(double %7, double %11, double %.018)
  %13 = load double, ptr %9, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %6, i64 8
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fneg double %13
  %17 = tail call double @llvm.fmuladd.f64(double %16, double %15, double %12)
  %exitcond.not = icmp eq i64 %indvars.iv.next, %3
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree norecurse nosync nounwind 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" }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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