; LLVM IR from mkmarek/forex.analytics :: lib/ta-lib/src/ta_func (ta_WCLPRICE)

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @TA_S_WCLPRICE(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #2 {
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store i32 %0, ptr %10, align 4, !tbaa !5
  store i32 %1, ptr %11, align 4, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !9
  store ptr %3, ptr %13, align 8, !tbaa !9
  store ptr %4, ptr %14, align 8, !tbaa !9
  store ptr %5, ptr %15, align 8, !tbaa !9
  store ptr %6, ptr %16, align 8, !tbaa !9
  store ptr %7, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %21 = load i32, ptr %10, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %8
  store i32 12, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %86

24:                                               ; preds = %8
  %25 = load i32, ptr %11, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %31, label %27

27:                                               ; preds = %24
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = load i32, ptr %10, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %27, %24
  store i32 13, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %86

32:                                               ; preds = %27
  %33 = load ptr, ptr %12, align 8, !tbaa !9
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %41

35:                                               ; preds = %32
  %36 = load ptr, ptr %13, align 8, !tbaa !9
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = load ptr, ptr %14, align 8, !tbaa !9
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %38, %35, %32
  store i32 2, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %86

42:                                               ; preds = %38
  %43 = load ptr, ptr %17, align 8, !tbaa !9
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %42
  store i32 2, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %86

46:                                               ; preds = %42
  store i32 0, ptr %18, align 4, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %47, ptr %19, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %78, %46
  %49 = load i32, ptr %19, align 4, !tbaa !5
  %50 = load i32, ptr %11, align 4, !tbaa !5
  %51 = icmp sle i32 %49, %50
  br i1 %51, label %52, label %81

52:                                               ; preds = %48
  %53 = load ptr, ptr %12, align 8, !tbaa !9
  %54 = load i32, ptr %19, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds float, ptr %53, i64 %55
  %57 = load float, ptr %56, align 4, !tbaa !11
  %58 = load ptr, ptr %13, align 8, !tbaa !9
  %59 = load i32, ptr %19, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds float, ptr %58, i64 %60
  %62 = load float, ptr %61, align 4, !tbaa !11
  %63 = fadd float %57, %62
  %64 = fpext float %63 to double
  %65 = load ptr, ptr %14, align 8, !tbaa !9
  %66 = load i32, ptr %19, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !11
  %70 = fpext float %69 to double
  %71 = call double @llvm.fmuladd.f64(double %70, double 2.000000e+00, double %64)
  %72 = fdiv double %71, 4.000000e+00
  %73 = load ptr, ptr %17, align 8, !tbaa !9
  %74 = load i32, ptr %18, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %18, align 4, !tbaa !5
  %76 = sext i32 %74 to i64
  %77 = getelementptr inbounds double, ptr %73, i64 %76
  store double %72, ptr %77, align 8, !tbaa !13
  br label %78

78:                                               ; preds = %52
  %79 = load i32, ptr %19, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %19, align 4, !tbaa !5
  br label %48, !llvm.loop !15

81:                                               ; preds = %48
  %82 = load i32, ptr %18, align 4, !tbaa !5
  %83 = load ptr, ptr %16, align 8, !tbaa !9
  store i32 %82, ptr %83, align 4, !tbaa !5
  %84 = load i32, ptr %10, align 4, !tbaa !5
  %85 = load ptr, ptr %15, align 8, !tbaa !9
  store i32 %84, ptr %85, align 4, !tbaa !5
  store i32 0, ptr %9, align 4
  store i32 1, ptr %20, align 4
  br label %86

86:                                               ; preds = %81, %45, %41, %31, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %87 = load i32, ptr %9, align 4
  ret i32 %87
}

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 = !{!"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 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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: readwrite) uwtable
define dso_local range(i32 0, 14) i32 @TA_S_WCLPRICE(i32 noundef %0, i32 noundef %1, ptr noundef readonly %2, ptr noundef readonly %3, ptr noundef readonly %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef writeonly %6, ptr noundef writeonly %7) local_unnamed_addr #1 {
  %9 = icmp slt i32 %0, 0
  br i1 %9, label %53, label %10

10:                                               ; preds = %8
  %11 = icmp slt i32 %1, %0
  br i1 %11, label %53, label %12

12:                                               ; preds = %10
  %13 = insertelement <4 x ptr> poison, ptr %2, i64 0
  %14 = insertelement <4 x ptr> %13, ptr %3, i64 1
  %15 = insertelement <4 x ptr> %14, ptr %4, i64 2
  %16 = insertelement <4 x ptr> %15, ptr %7, i64 3
  %17 = icmp eq <4 x ptr> %16, zeroinitializer
  %18 = bitcast <4 x i1> %17 to i4
  %.not = icmp eq i4 %18, 0
  br i1 %.not, label %.lr.ph.preheader, label %53

.lr.ph.preheader:                                 ; preds = %12
  %19 = zext nneg i32 %0 to i64
  %20 = add nuw i32 %1, 1
  %21 = sub i32 %20, %0
  %wide.trip.count = zext i32 %21 to i64
  %min.iters.check = icmp ult i32 %21, 4
  br i1 %min.iters.check, label %.lr.ph.preheader57, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %wide.trip.count, 4294967292
  %ind.end = add nuw nsw i64 %n.vec, %19
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %index, %19
  %22 = getelementptr inbounds float, ptr %2, i64 %offset.idx
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %wide.load = load <2 x float>, ptr %22, align 4, !tbaa !5
  %wide.load52 = load <2 x float>, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds float, ptr %3, i64 %offset.idx
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  %wide.load53 = load <2 x float>, ptr %24, align 4, !tbaa !5
  %wide.load54 = load <2 x float>, ptr %25, align 4, !tbaa !5
  %26 = fadd <2 x float> %wide.load, %wide.load53
  %27 = fadd <2 x float> %wide.load52, %wide.load54
  %28 = fpext <2 x float> %26 to <2 x double>
  %29 = fpext <2 x float> %27 to <2 x double>
  %30 = getelementptr inbounds float, ptr %4, i64 %offset.idx
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  %wide.load55 = load <2 x float>, ptr %30, align 4, !tbaa !5
  %wide.load56 = load <2 x float>, ptr %31, align 4, !tbaa !5
  %32 = fpext <2 x float> %wide.load55 to <2 x double>
  %33 = fpext <2 x float> %wide.load56 to <2 x double>
  %34 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %28)
  %35 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %29)
  %36 = fmul <2 x double> %34, <double 2.500000e-01, double 2.500000e-01>
  %37 = fmul <2 x double> %35, <double 2.500000e-01, double 2.500000e-01>
  %38 = getelementptr inbounds double, ptr %7, i64 %index
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  store <2 x double> %36, ptr %38, align 8, !tbaa !9
  store <2 x double> %37, ptr %39, align 8, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %40 = icmp eq i64 %index.next, %n.vec
  br i1 %40, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader57

.lr.ph.preheader57:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv46.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %indvars.iv.ph = phi i64 [ %19, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader57, %.lr.ph
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %.lr.ph ], [ %indvars.iv46.ph, %.lr.ph.preheader57 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader57 ]
  %41 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %42 = load float, ptr %41, align 4, !tbaa !5
  %43 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  %44 = load float, ptr %43, align 4, !tbaa !5
  %45 = fadd float %42, %44
  %46 = fpext float %45 to double
  %47 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  %48 = load float, ptr %47, align 4, !tbaa !5
  %49 = fpext float %48 to double
  %50 = tail call double @llvm.fmuladd.f64(double %49, double 2.000000e+00, double %46)
  %51 = fmul double %50, 2.500000e-01
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %52 = getelementptr inbounds double, ptr %7, i64 %indvars.iv46
  store double %51, ptr %52, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next47, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %middle.block
  store i32 %21, ptr %6, align 4, !tbaa !16
  store i32 %0, ptr %5, align 4, !tbaa !16
  br label %53

53:                                               ; preds = %12, %10, %8, %._crit_edge
  %.028 = phi i32 [ 0, %._crit_edge ], [ 12, %8 ], [ 13, %10 ], [ 2, %12 ]
  ret i32 %.028
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #2

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

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !14, !13}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass