; LLVM IR from liminchen/OptCuts :: ext/libigl/external/cgal/src/CGAL_Project/examples/Mesh_3/implicit_functions._ff9c1567 (i)

; 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: mustprogress nounwind uwtable
define dso_local void @_Z5puissRdS_i(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 1.000000e+00, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store double 0.000000e+00, ptr %8, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %40, %3
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %16, label %60

16:                                               ; preds = %13
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = and i32 %17, 1
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %40

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %21 = load double, ptr %7, align 8, !tbaa !11
  store double %21, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %22 = load double, ptr %8, align 8, !tbaa !11
  store double %22, ptr %10, align 8, !tbaa !11
  %23 = load double, ptr %9, align 8, !tbaa !11
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load double, ptr %24, align 8, !tbaa !11
  %26 = load double, ptr %10, align 8, !tbaa !11
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = fmul double %26, %28
  %30 = fneg double %29
  %31 = call double @llvm.fmuladd.f64(double %23, double %25, double %30)
  store double %31, ptr %7, align 8, !tbaa !11
  %32 = load double, ptr %9, align 8, !tbaa !11
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = load double, ptr %10, align 8, !tbaa !11
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = fmul double %35, %37
  %39 = call double @llvm.fmuladd.f64(double %32, double %34, double %38)
  store double %39, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %40

40:                                               ; preds = %20, %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load double, ptr %41, align 8, !tbaa !11
  store double %42, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load double, ptr %43, align 8, !tbaa !11
  store double %44, ptr %12, align 8, !tbaa !11
  %45 = load double, ptr %11, align 8, !tbaa !11
  %46 = load double, ptr %11, align 8, !tbaa !11
  %47 = load double, ptr %12, align 8, !tbaa !11
  %48 = load double, ptr %12, align 8, !tbaa !11
  %49 = fmul double %47, %48
  %50 = fneg double %49
  %51 = call double @llvm.fmuladd.f64(double %45, double %46, double %50)
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  store double %51, ptr %52, align 8, !tbaa !11
  %53 = load double, ptr %11, align 8, !tbaa !11
  %54 = fmul double 2.000000e+00, %53
  %55 = load double, ptr %12, align 8, !tbaa !11
  %56 = fmul double %54, %55
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  store double %56, ptr %57, align 8, !tbaa !11
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = sdiv i32 %58, 2
  store i32 %59, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %13, !llvm.loop !13

60:                                               ; preds = %13
  %61 = load double, ptr %7, align 8, !tbaa !11
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  store double %61, ptr %62, align 8, !tbaa !11
  %63 = load double, ptr %8, align 8, !tbaa !11
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  store double %63, ptr %64, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress 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++ 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: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_Z5puissRdS_i(ptr nocapture noundef nonnull align 8 dereferenceable(8) %0, ptr nocapture noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = icmp sgt i32 %2, 0
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %.pre34.pre = load double, ptr %1, align 8, !tbaa !5
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %12
  %.pre34 = phi double [ %17, %12 ], [ %.pre34.pre, %.lr.ph.preheader ]
  %.031 = phi i32 [ %18, %12 ], [ %2, %.lr.ph.preheader ]
  %.02630 = phi double [ %.1, %12 ], [ 1.000000e+00, %.lr.ph.preheader ]
  %.02729 = phi double [ %.128, %12 ], [ 0.000000e+00, %.lr.ph.preheader ]
  %5 = and i32 %.031, 1
  %.not = icmp eq i32 %5, 0
  %.pre = load double, ptr %0, align 8, !tbaa !5
  br i1 %.not, label %12, label %6

6:                                                ; preds = %.lr.ph
  %7 = fneg double %.02729
  %8 = fmul double %.pre34, %7
  %9 = tail call double @llvm.fmuladd.f64(double %.02630, double %.pre, double %8)
  %10 = fmul double %.02729, %.pre
  %11 = tail call double @llvm.fmuladd.f64(double %.02630, double %.pre34, double %10)
  br label %12

12:                                               ; preds = %6, %.lr.ph
  %.128 = phi double [ %11, %6 ], [ %.02729, %.lr.ph ]
  %.1 = phi double [ %9, %6 ], [ %.02630, %.lr.ph ]
  %13 = fneg double %.pre34
  %14 = fmul double %.pre34, %13
  %15 = tail call double @llvm.fmuladd.f64(double %.pre, double %.pre, double %14)
  store double %15, ptr %0, align 8, !tbaa !5
  %16 = fmul double %.pre, 2.000000e+00
  %17 = fmul double %16, %.pre34
  store double %17, ptr %1, align 8, !tbaa !5
  %18 = lshr i32 %.031, 1
  %.not33 = icmp ult i32 %.031, 2
  br i1 %.not33, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %12, %3
  %.027.lcssa = phi double [ 0.000000e+00, %3 ], [ %.128, %12 ]
  %.026.lcssa = phi double [ 1.000000e+00, %3 ], [ %.1, %12 ]
  store double %.026.lcssa, ptr %0, align 8, !tbaa !5
  store double %.027.lcssa, ptr %1, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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