; LLVM IR from sharkbench/sharkbench :: benchmark/computation/c/gcc-6 (main)

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

14:                                               ; preds = %53, %4
  %15 = load i32, ptr %13, align 4, !tbaa !5
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  br label %56

19:                                               ; preds = %14
  %20 = load i32, ptr %13, align 4, !tbaa !5
  %21 = srem i32 %20, 2
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = load double, ptr %10, align 8, !tbaa !11
  %25 = fdiv double 1.000000e+00, %24
  %26 = load double, ptr %9, align 8, !tbaa !11
  %27 = fadd double %26, %25
  store double %27, ptr %9, align 8, !tbaa !11
  br label %33

28:                                               ; preds = %19
  %29 = load double, ptr %10, align 8, !tbaa !11
  %30 = fdiv double 1.000000e+00, %29
  %31 = load double, ptr %9, align 8, !tbaa !11
  %32 = fsub double %31, %30
  store double %32, ptr %9, align 8, !tbaa !11
  br label %33

33:                                               ; preds = %28, %23
  %34 = load double, ptr %10, align 8, !tbaa !11
  %35 = fadd double %34, 2.000000e+00
  store double %35, ptr %10, align 8, !tbaa !11
  %36 = load double, ptr %9, align 8, !tbaa !11
  %37 = load double, ptr %11, align 8, !tbaa !11
  %38 = fadd double %37, %36
  store double %38, ptr %11, align 8, !tbaa !11
  %39 = load i32, ptr %13, align 4, !tbaa !5
  %40 = srem i32 %39, 3
  switch i32 %40, label %52 [
    i32 0, label %41
    i32 1, label %45
    i32 2, label %49
  ]

41:                                               ; preds = %33
  %42 = load double, ptr %9, align 8, !tbaa !11
  %43 = load double, ptr %12, align 8, !tbaa !11
  %44 = fadd double %43, %42
  store double %44, ptr %12, align 8, !tbaa !11
  br label %52

45:                                               ; preds = %33
  %46 = load double, ptr %9, align 8, !tbaa !11
  %47 = load double, ptr %12, align 8, !tbaa !11
  %48 = fsub double %47, %46
  store double %48, ptr %12, align 8, !tbaa !11
  br label %52

49:                                               ; preds = %33
  %50 = load double, ptr %12, align 8, !tbaa !11
  %51 = fdiv double %50, 2.000000e+00
  store double %51, ptr %12, align 8, !tbaa !11
  br label %52

52:                                               ; preds = %49, %45, %41, %33
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %13, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %13, align 4, !tbaa !5
  br label %14, !llvm.loop !13

56:                                               ; preds = %18
  %57 = load double, ptr %9, align 8, !tbaa !11
  %58 = fmul double %57, 4.000000e+00
  store double %58, ptr %9, align 8, !tbaa !11
  %59 = load double, ptr %9, align 8, !tbaa !11
  %60 = load ptr, ptr %6, align 8, !tbaa !9
  store double %59, ptr %60, align 8, !tbaa !11
  %61 = load double, ptr %11, align 8, !tbaa !11
  %62 = load ptr, ptr %7, align 8, !tbaa !9
  store double %61, ptr %62, align 8, !tbaa !11
  %63 = load double, ptr %12, align 8, !tbaa !11
  %64 = load ptr, ptr %8, align 8, !tbaa !9
  store double %63, ptr %64, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret void
}

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

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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: nofree norecurse nosync nounwind memory(argmem: write) uwtable
define dso_local void @calc_pi(i32 noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = icmp sgt i32 %0, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %20
  %6 = fmul double %.127, 4.000000e+00
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %4
  %.026.lcssa = phi double [ 0.000000e+00, %4 ], [ %6, %._crit_edge.loopexit ]
  %.024.lcssa = phi double [ 0.000000e+00, %4 ], [ %12, %._crit_edge.loopexit ]
  %.023.lcssa = phi double [ 0.000000e+00, %4 ], [ %.1, %._crit_edge.loopexit ]
  store double %.026.lcssa, ptr %1, align 8, !tbaa !5
  store double %.024.lcssa, ptr %2, align 8, !tbaa !5
  store double %.023.lcssa, ptr %3, align 8, !tbaa !5
  ret void

.lr.ph:                                           ; preds = %4, %20
  %.035 = phi i32 [ %21, %20 ], [ 0, %4 ]
  %.02334 = phi double [ %.1, %20 ], [ 0.000000e+00, %4 ]
  %.02433 = phi double [ %12, %20 ], [ 0.000000e+00, %4 ]
  %.02532 = phi double [ %11, %20 ], [ 1.000000e+00, %4 ]
  %.02631 = phi double [ %.127, %20 ], [ 0.000000e+00, %4 ]
  %7 = and i32 %.035, 1
  %8 = icmp eq i32 %7, 0
  %9 = fdiv double 1.000000e+00, %.02532
  %10 = fneg double %9
  %.127.p = select i1 %8, double %9, double %10
  %.127 = fadd double %.02631, %.127.p
  %11 = fadd double %.02532, 2.000000e+00
  %12 = fadd double %.02433, %.127
  %13 = urem i32 %.035, 3
  switch i32 %13, label %default.unreachable [
    i32 0, label %14
    i32 1, label %16
    i32 2, label %18
  ]

14:                                               ; preds = %.lr.ph
  %15 = fadd double %.02334, %.127
  br label %20

16:                                               ; preds = %.lr.ph
  %17 = fsub double %.02334, %.127
  br label %20

18:                                               ; preds = %.lr.ph
  %19 = fmul double %.02334, 5.000000e-01
  br label %20

default.unreachable:                              ; preds = %.lr.ph
  unreachable

20:                                               ; preds = %14, %16, %18
  %.1 = phi double [ %19, %18 ], [ %17, %16 ], [ %15, %14 ]
  %21 = add nuw nsw i32 %.035, 1
  %exitcond.not = icmp eq i32 %21, %0
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !9
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: write) 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,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass