; 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: nounwind uwtable
define dso_local i32 @TA_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) #0 {
  %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 %84

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 %84

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 %84

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 %84

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 = %76, %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 %79

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 double, ptr %53, i64 %55
  %57 = load double, ptr %56, align 8, !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 double, ptr %58, i64 %60
  %62 = load double, ptr %61, align 8, !tbaa !11
  %63 = fadd double %57, %62
  %64 = load ptr, ptr %14, align 8, !tbaa !9
  %65 = load i32, ptr %19, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds double, ptr %64, i64 %66
  %68 = load double, ptr %67, align 8, !tbaa !11
  %69 = call double @llvm.fmuladd.f64(double %68, double 2.000000e+00, double %63)
  %70 = fdiv double %69, 4.000000e+00
  %71 = load ptr, ptr %17, align 8, !tbaa !9
  %72 = load i32, ptr %18, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %18, align 4, !tbaa !5
  %74 = sext i32 %72 to i64
  %75 = getelementptr inbounds double, ptr %71, i64 %74
  store double %70, ptr %75, align 8, !tbaa !11
  br label %76

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

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

84:                                               ; preds = %79, %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
  %85 = load i32, ptr %9, align 4
  ret i32 %85
}

; 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.fmuladd.f64(double, double, double) #2

; 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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: readwrite) uwtable
define dso_local range(i32 0, 14) i32 @TA_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 #0 {
  %9 = ptrtoint ptr %4 to i64
  %10 = ptrtoint ptr %3 to i64
  %11 = ptrtoint ptr %2 to i64
  %12 = ptrtoint ptr %7 to i64
  %13 = icmp slt i32 %0, 0
  br i1 %13, label %79, label %14

14:                                               ; preds = %8
  %15 = icmp slt i32 %1, %0
  br i1 %15, label %79, label %16

16:                                               ; preds = %14
  %17 = insertelement <4 x ptr> poison, ptr %2, i64 0
  %18 = insertelement <4 x ptr> %17, ptr %3, i64 1
  %19 = insertelement <4 x ptr> %18, ptr %4, i64 2
  %20 = insertelement <4 x ptr> %19, ptr %7, i64 3
  %21 = icmp eq <4 x ptr> %20, zeroinitializer
  %22 = bitcast <4 x i1> %21 to i4
  %.not = icmp eq i4 %22, 0
  br i1 %.not, label %.lr.ph.preheader, label %79

.lr.ph.preheader:                                 ; preds = %16
  %23 = zext nneg i32 %0 to i64
  %24 = add nuw i32 %1, 1
  %25 = sub i32 %24, %0
  %wide.trip.count = zext i32 %25 to i64
  %min.iters.check = icmp ult i32 %25, 8
  br i1 %min.iters.check, label %.lr.ph.preheader60, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %26 = shl nuw nsw i64 %23, 3
  %27 = add i64 %26, %11
  %28 = sub i64 %12, %27
  %diff.check = icmp ult i64 %28, 32
  %29 = add i64 %26, %10
  %30 = sub i64 %12, %29
  %diff.check51 = icmp ult i64 %30, 32
  %conflict.rdx = or i1 %diff.check, %diff.check51
  %31 = add i64 %26, %9
  %32 = sub i64 %12, %31
  %diff.check52 = icmp ult i64 %32, 32
  %conflict.rdx53 = or i1 %conflict.rdx, %diff.check52
  br i1 %conflict.rdx53, label %.lr.ph.preheader60, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 4294967292
  %ind.end = add nuw nsw i64 %n.vec, %23
  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, %23
  %33 = getelementptr inbounds double, ptr %2, i64 %offset.idx
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %wide.load = load <2 x double>, ptr %33, align 8, !tbaa !5
  %wide.load55 = load <2 x double>, ptr %34, align 8, !tbaa !5
  %35 = getelementptr inbounds double, ptr %3, i64 %offset.idx
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  %wide.load56 = load <2 x double>, ptr %35, align 8, !tbaa !5
  %wide.load57 = load <2 x double>, ptr %36, align 8, !tbaa !5
  %37 = fadd <2 x double> %wide.load, %wide.load56
  %38 = fadd <2 x double> %wide.load55, %wide.load57
  %39 = getelementptr inbounds double, ptr %4, i64 %offset.idx
  %40 = getelementptr inbounds i8, ptr %39, i64 16
  %wide.load58 = load <2 x double>, ptr %39, align 8, !tbaa !5
  %wide.load59 = load <2 x double>, ptr %40, align 8, !tbaa !5
  %41 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %wide.load58, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %37)
  %42 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %wide.load59, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> %38)
  %43 = fmul <2 x double> %41, <double 2.500000e-01, double 2.500000e-01>
  %44 = fmul <2 x double> %42, <double 2.500000e-01, double 2.500000e-01>
  %45 = getelementptr inbounds double, ptr %7, i64 %index
  %46 = getelementptr inbounds i8, ptr %45, i64 16
  store <2 x double> %43, ptr %45, align 8, !tbaa !5
  store <2 x double> %44, ptr %46, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %47 = icmp eq i64 %index.next, %n.vec
  br i1 %47, label %middle.block, label %vector.body, !llvm.loop !9

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.preheader60

.lr.ph.preheader60:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv46.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %indvars.iv.ph = phi i64 [ %23, %vector.memcheck ], [ %23, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader60
  %48 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.ph
  %49 = load double, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.ph
  %51 = load double, ptr %50, align 8, !tbaa !5
  %52 = fadd double %49, %51
  %53 = getelementptr inbounds double, ptr %4, i64 %indvars.iv.ph
  %54 = load double, ptr %53, align 8, !tbaa !5
  %55 = tail call double @llvm.fmuladd.f64(double %54, double 2.000000e+00, double %52)
  %56 = fmul double %55, 2.500000e-01
  %indvars.iv.next47.prol = or disjoint i64 %indvars.iv46.ph, 1
  %57 = getelementptr inbounds double, ptr %7, i64 %indvars.iv46.ph
  store double %56, ptr %57, align 8, !tbaa !5
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.ph, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader60
  %indvars.iv46.unr = phi i64 [ %indvars.iv46.ph, %.lr.ph.preheader60 ], [ %indvars.iv.next47.prol, %.lr.ph.prol ]
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.preheader60 ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %58 = add nsw i64 %wide.trip.count, -1
  %59 = icmp eq i64 %indvars.iv46.ph, %58
  br i1 %59, label %._crit_edge, label %.lr.ph.preheader60.new

.lr.ph.preheader60.new:                           ; preds = %.lr.ph.prol.loopexit
  %invariant.gep = getelementptr i8, ptr %7, i64 8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader60.new
  %indvars.iv46 = phi i64 [ %indvars.iv46.unr, %.lr.ph.preheader60.new ], [ %indvars.iv.next47.1, %.lr.ph ]
  %indvars.iv = phi i64 [ %indvars.iv.unr, %.lr.ph.preheader60.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %60 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  %61 = load double, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %63 = load double, ptr %62, align 8, !tbaa !5
  %64 = fadd double %61, %63
  %65 = getelementptr inbounds double, ptr %4, i64 %indvars.iv
  %66 = load double, ptr %65, align 8, !tbaa !5
  %67 = tail call double @llvm.fmuladd.f64(double %66, double 2.000000e+00, double %64)
  %68 = fmul double %67, 2.500000e-01
  %69 = getelementptr inbounds double, ptr %7, i64 %indvars.iv46
  store double %68, ptr %69, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %70 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next
  %71 = load double, ptr %70, align 8, !tbaa !5
  %72 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next
  %73 = load double, ptr %72, align 8, !tbaa !5
  %74 = fadd double %71, %73
  %75 = getelementptr inbounds double, ptr %4, i64 %indvars.iv.next
  %76 = load double, ptr %75, align 8, !tbaa !5
  %77 = tail call double @llvm.fmuladd.f64(double %76, double 2.000000e+00, double %74)
  %78 = fmul double %77, 2.500000e-01
  %indvars.iv.next47.1 = add nuw nsw i64 %indvars.iv46, 2
  %gep = getelementptr double, ptr %invariant.gep, i64 %indvars.iv46
  store double %78, ptr %gep, align 8, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next47.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block
  store i32 %25, ptr %6, align 4, !tbaa !14
  store i32 %0, ptr %5, align 4, !tbaa !14
  br label %79

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

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

; 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 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}


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