; LLVM IR from bbenligiray/stag :: src/Ellipse.ll (ZN13customEllipse12GetPerimeterEv)

; 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"

%class.customEllipse = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, i32, ptr, ptr, ptr, ptr, ptr, ptr }

; 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
declare double @sqrt(double noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN13customEllipse12GetPerimeterEv(ptr noundef nonnull align 8 dereferenceable(272) %0) #3 align 2 {
  %2 = alloca double, align 8
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 22
  %7 = load double, ptr %6, align 8, !tbaa !9
  %8 = fcmp une double %7, 0.000000e+00
  br i1 %8, label %9, label %12

9:                                                ; preds = %1
  %10 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 22
  %11 = load double, ptr %10, align 8, !tbaa !9
  store double %11, ptr %2, align 8
  br label %44

12:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %13 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 20
  %14 = load double, ptr %13, align 8, !tbaa !13
  %15 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 21
  %16 = load double, ptr %15, align 8, !tbaa !14
  %17 = fsub double %14, %16
  %18 = call double @pow(double noundef %17, double noundef 2.000000e+00) #4
  %19 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 20
  %20 = load double, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 21
  %22 = load double, ptr %21, align 8, !tbaa !14
  %23 = fadd double %20, %22
  %24 = call double @pow(double noundef %23, double noundef 2.000000e+00) #4
  %25 = fdiv double %18, %24
  store double %25, ptr %4, align 8, !tbaa !15
  %26 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 20
  %27 = load double, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 21
  %29 = load double, ptr %28, align 8, !tbaa !14
  %30 = fadd double %27, %29
  %31 = fmul double 0x400921FB53C8D4F1, %30
  %32 = load double, ptr %4, align 8, !tbaa !15
  %33 = fmul double 3.000000e+00, %32
  %34 = load double, ptr %4, align 8, !tbaa !15
  %35 = call double @llvm.fmuladd.f64(double -3.000000e+00, double %34, double 4.000000e+00)
  %36 = call double @sqrt(double noundef %35) #4
  %37 = fadd double 1.000000e+01, %36
  %38 = fdiv double %33, %37
  %39 = fadd double 1.000000e+00, %38
  %40 = fmul double %31, %39
  %41 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 22
  store double %40, ptr %41, align 8, !tbaa !9
  %42 = getelementptr inbounds %class.customEllipse, ptr %5, i32 0, i32 22
  %43 = load double, ptr %42, align 8, !tbaa !9
  store double %43, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %44

44:                                               ; preds = %12, %9
  %45 = load double, ptr %2, align 8
  ret double %45
}

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nounwind "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 = { 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 #4 = { 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, !11, i64 176}
!10 = !{!"_ZTS13customEllipse", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !11, i64 184, !11, i64 192, !11, i64 200, !11, i64 208, !12, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 160}
!14 = !{!10, !11, i64 168}
!15 = !{!11, !11, i64 0}


; 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 nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local noundef double @_ZN13customEllipse12GetPerimeterEv(ptr nocapture noundef nonnull align 8 dereferenceable(272) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 176
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = fcmp une double %3, 0.000000e+00
  br i1 %4, label %21, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 160
  %7 = load double, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 168
  %9 = load double, ptr %8, align 8, !tbaa !13
  %10 = fsub double %7, %9
  %square = fmul double %10, %10
  %11 = fadd double %7, %9
  %square5 = fmul double %11, %11
  %12 = fdiv double %square, %square5
  %13 = fmul double %11, 0x400921FB53C8D4F1
  %14 = fmul double %12, 3.000000e+00
  %15 = tail call double @llvm.fmuladd.f64(double %12, double -3.000000e+00, double 4.000000e+00)
  %16 = tail call double @sqrt(double noundef %15) #3
  %17 = fadd double %16, 1.000000e+01
  %18 = fdiv double %14, %17
  %19 = fadd double %18, 1.000000e+00
  %20 = fmul double %13, %19
  store double %20, ptr %2, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %1, %5
  %.0 = phi double [ %20, %5 ], [ %3, %1 ]
  ret double %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 nofree nounwind willreturn memory(write, 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" }
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 176}
!6 = !{!"_ZTS13customEllipse", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208, !10, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !11, i64 248, !11, i64 256, !11, i64 264}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 160}
!13 = !{!6, !7, i64 168}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass