; LLVM IR from codee-com/open-catalog :: Checks/PWR031/benchmark (example)

; 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 willreturn memory(none) uwtable
define dso_local double @midpoint_rule_x_pow_1_5_sin_x(double noundef %0, double noundef %1, i32 noundef %2) #0 {
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  store double %0, ptr %4, align 8, !tbaa !5
  store double %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) #4
  store double 0.000000e+00, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %11 = load double, ptr %5, align 8, !tbaa !5
  %12 = load double, ptr %4, align 8, !tbaa !5
  %13 = fsub double %11, %12
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = sitofp i32 %14 to double
  %16 = fdiv double %13, %15
  store double %16, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %37, %3
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %40

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = sitofp i32 %23 to double
  %25 = fadd double %24, 5.000000e-01
  %26 = load double, ptr %8, align 8, !tbaa !5
  %27 = load double, ptr %4, align 8, !tbaa !5
  %28 = call double @llvm.fma.f64(double %25, double %26, double %27)
  store double %28, ptr %10, align 8, !tbaa !5
  %29 = load double, ptr %10, align 8, !tbaa !5
  %30 = call double @pow(double noundef %29, double noundef 1.500000e+00) #4
  %31 = load double, ptr %10, align 8, !tbaa !5
  %32 = call double @sin(double noundef %31) #4
  %33 = fmul double %30, %32
  %34 = load double, ptr %8, align 8, !tbaa !5
  %35 = load double, ptr %7, align 8, !tbaa !5
  %36 = call double @llvm.fma.f64(double %33, double %34, double %35)
  store double %36, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %37

37:                                               ; preds = %22
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %9, align 4, !tbaa !9
  br label %17, !llvm.loop !11

40:                                               ; preds = %21
  %41 = load double, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret double %41
}

; 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 speculatable willreturn memory(none)
declare double @llvm.fma.f64(double, double, double) #2

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

; Function Attrs: nounwind
declare double @sin(double noundef) #3

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

attributes #0 = { nounwind willreturn memory(none) 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"double", !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 = distinct !{!11, !12}
!12 = !{!"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 nofree nosync nounwind willreturn memory(none) uwtable
define dso_local double @midpoint_rule_x_pow_1_5_sin_x(double noundef %0, double noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = fsub double %1, %0
  %5 = sitofp i32 %2 to double
  %6 = fdiv double %4, %5
  %7 = icmp sgt i32 %2, 0
  br i1 %7, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %xtraiter = and i32 %2, 1
  %8 = icmp eq i32 %2, 1
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %2, 2147483646
  br label %.lr.ph

._crit_edge.loopexit.unr-lcssa.loopexit:          ; preds = %.lr.ph
  %9 = uitofp nneg i32 %31 to double
  %10 = fadd double %9, 5.000000e-01
  br label %._crit_edge.loopexit.unr-lcssa

._crit_edge.loopexit.unr-lcssa:                   ; preds = %._crit_edge.loopexit.unr-lcssa.loopexit, %.lr.ph.preheader
  %.lcssa.ph = phi double [ poison, %.lr.ph.preheader ], [ %30, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.015.unr = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %30, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.01314.unr = phi double [ 5.000000e-01, %.lr.ph.preheader ], [ %10, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %11 = tail call double @llvm.fma.f64(double %.01314.unr, double %6, double %0)
  %12 = tail call double @pow(double noundef %11, double noundef 1.500000e+00) #3
  %13 = tail call double @sin(double noundef %11) #3
  %14 = fmul double %12, %13
  %15 = tail call double @llvm.fma.f64(double %14, double %6, double %.015.unr)
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %3
  %.0.lcssa = phi double [ 0.000000e+00, %3 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %15, %.lr.ph.epil ]
  ret double %.0.lcssa

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.015 = phi double [ 0.000000e+00, %.lr.ph.preheader.new ], [ %30, %.lr.ph ]
  %.01314 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %31, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %16 = uitofp nneg i32 %.01314 to double
  %17 = fadd double %16, 5.000000e-01
  %18 = tail call double @llvm.fma.f64(double %17, double %6, double %0)
  %19 = tail call double @pow(double noundef %18, double noundef 1.500000e+00) #3
  %20 = tail call double @sin(double noundef %18) #3
  %21 = fmul double %19, %20
  %22 = tail call double @llvm.fma.f64(double %21, double %6, double %.015)
  %23 = or disjoint i32 %.01314, 1
  %24 = uitofp nneg i32 %23 to double
  %25 = fadd double %24, 5.000000e-01
  %26 = tail call double @llvm.fma.f64(double %25, double %6, double %0)
  %27 = tail call double @pow(double noundef %26, double noundef 1.500000e+00) #3
  %28 = tail call double @sin(double noundef %26) #3
  %29 = fmul double %27, %28
  %30 = tail call double @llvm.fma.f64(double %29, double %6, double %22)
  %31 = add nuw nsw i32 %.01314, 2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa.loopexit, label %.lr.ph, !llvm.loop !5
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fma.f64(double, double, double) #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) 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 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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