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

; 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_INT_VAR(i32 noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  store i32 %0, ptr %9, align 4, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  %26 = load i32, ptr %12, align 4, !tbaa !5
  %27 = sub nsw i32 %26, 1
  store i32 %27, ptr %24, align 4, !tbaa !5
  %28 = load i32, ptr %9, align 4, !tbaa !5
  %29 = load i32, ptr %24, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %7
  %32 = load i32, ptr %24, align 4, !tbaa !5
  store i32 %32, ptr %9, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %31, %7
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = icmp sgt i32 %34, %35
  br i1 %36, label %37, label %40

37:                                               ; preds = %33
  %38 = load ptr, ptr %13, align 8, !tbaa !9
  store i32 0, ptr %38, align 4, !tbaa !5
  %39 = load ptr, ptr %14, align 8, !tbaa !9
  store i32 0, ptr %39, align 4, !tbaa !5
  store i32 0, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %131

40:                                               ; preds = %33
  store double 0.000000e+00, ptr %17, align 8, !tbaa !11
  store double 0.000000e+00, ptr %18, align 8, !tbaa !11
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = load i32, ptr %24, align 4, !tbaa !5
  %43 = sub nsw i32 %41, %42
  store i32 %43, ptr %23, align 4, !tbaa !5
  %44 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %44, ptr %21, align 4, !tbaa !5
  %45 = load i32, ptr %12, align 4, !tbaa !5
  %46 = icmp sgt i32 %45, 1
  br i1 %46, label %47, label %70

47:                                               ; preds = %40
  br label %48

48:                                               ; preds = %52, %47
  %49 = load i32, ptr %21, align 4, !tbaa !5
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %52, label %69

52:                                               ; preds = %48
  %53 = load ptr, ptr %11, align 8, !tbaa !9
  %54 = load i32, ptr %21, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %21, align 4, !tbaa !5
  %56 = sext i32 %54 to i64
  %57 = getelementptr inbounds float, ptr %53, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !13
  %59 = fpext float %58 to double
  store double %59, ptr %16, align 8, !tbaa !11
  %60 = load double, ptr %16, align 8, !tbaa !11
  %61 = load double, ptr %17, align 8, !tbaa !11
  %62 = fadd double %61, %60
  store double %62, ptr %17, align 8, !tbaa !11
  %63 = load double, ptr %16, align 8, !tbaa !11
  %64 = load double, ptr %16, align 8, !tbaa !11
  %65 = fmul double %64, %63
  store double %65, ptr %16, align 8, !tbaa !11
  %66 = load double, ptr %16, align 8, !tbaa !11
  %67 = load double, ptr %18, align 8, !tbaa !11
  %68 = fadd double %67, %66
  store double %68, ptr %18, align 8, !tbaa !11
  br label %48, !llvm.loop !15

69:                                               ; preds = %48
  br label %70

70:                                               ; preds = %69, %40
  store i32 0, ptr %22, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %122, %70
  %72 = load ptr, ptr %11, align 8, !tbaa !9
  %73 = load i32, ptr %21, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %21, align 4, !tbaa !5
  %75 = sext i32 %73 to i64
  %76 = getelementptr inbounds float, ptr %72, i64 %75
  %77 = load float, ptr %76, align 4, !tbaa !13
  %78 = fpext float %77 to double
  store double %78, ptr %16, align 8, !tbaa !11
  %79 = load double, ptr %16, align 8, !tbaa !11
  %80 = load double, ptr %17, align 8, !tbaa !11
  %81 = fadd double %80, %79
  store double %81, ptr %17, align 8, !tbaa !11
  %82 = load double, ptr %16, align 8, !tbaa !11
  %83 = load double, ptr %16, align 8, !tbaa !11
  %84 = fmul double %83, %82
  store double %84, ptr %16, align 8, !tbaa !11
  %85 = load double, ptr %16, align 8, !tbaa !11
  %86 = load double, ptr %18, align 8, !tbaa !11
  %87 = fadd double %86, %85
  store double %87, ptr %18, align 8, !tbaa !11
  %88 = load double, ptr %17, align 8, !tbaa !11
  %89 = load i32, ptr %12, align 4, !tbaa !5
  %90 = sitofp i32 %89 to double
  %91 = fdiv double %88, %90
  store double %91, ptr %19, align 8, !tbaa !11
  %92 = load double, ptr %18, align 8, !tbaa !11
  %93 = load i32, ptr %12, align 4, !tbaa !5
  %94 = sitofp i32 %93 to double
  %95 = fdiv double %92, %94
  store double %95, ptr %20, align 8, !tbaa !11
  %96 = load ptr, ptr %11, align 8, !tbaa !9
  %97 = load i32, ptr %23, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %23, align 4, !tbaa !5
  %99 = sext i32 %97 to i64
  %100 = getelementptr inbounds float, ptr %96, i64 %99
  %101 = load float, ptr %100, align 4, !tbaa !13
  %102 = fpext float %101 to double
  store double %102, ptr %16, align 8, !tbaa !11
  %103 = load double, ptr %16, align 8, !tbaa !11
  %104 = load double, ptr %17, align 8, !tbaa !11
  %105 = fsub double %104, %103
  store double %105, ptr %17, align 8, !tbaa !11
  %106 = load double, ptr %16, align 8, !tbaa !11
  %107 = load double, ptr %16, align 8, !tbaa !11
  %108 = fmul double %107, %106
  store double %108, ptr %16, align 8, !tbaa !11
  %109 = load double, ptr %16, align 8, !tbaa !11
  %110 = load double, ptr %18, align 8, !tbaa !11
  %111 = fsub double %110, %109
  store double %111, ptr %18, align 8, !tbaa !11
  %112 = load double, ptr %20, align 8, !tbaa !11
  %113 = load double, ptr %19, align 8, !tbaa !11
  %114 = load double, ptr %19, align 8, !tbaa !11
  %115 = fneg double %113
  %116 = call double @llvm.fmuladd.f64(double %115, double %114, double %112)
  %117 = load ptr, ptr %15, align 8, !tbaa !9
  %118 = load i32, ptr %22, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %22, align 4, !tbaa !5
  %120 = sext i32 %118 to i64
  %121 = getelementptr inbounds double, ptr %117, i64 %120
  store double %116, ptr %121, align 8, !tbaa !11
  br label %122

122:                                              ; preds = %71
  %123 = load i32, ptr %21, align 4, !tbaa !5
  %124 = load i32, ptr %10, align 4, !tbaa !5
  %125 = icmp sle i32 %123, %124
  br i1 %125, label %71, label %126, !llvm.loop !17

126:                                              ; preds = %122
  %127 = load i32, ptr %22, align 4, !tbaa !5
  %128 = load ptr, ptr %14, align 8, !tbaa !9
  store i32 %127, ptr %128, align 4, !tbaa !5
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = load ptr, ptr %13, align 8, !tbaa !9
  store i32 %129, ptr %130, align 4, !tbaa !5
  store i32 0, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %131

131:                                              ; preds = %126, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %132 = load i32, ptr %8, align 4
  ret i32 %132
}

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 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 noundef i32 @TA_S_INT_VAR(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #1 {
  %8 = add nsw i32 %3, -1
  %spec.select = tail call i32 @llvm.smax.i32(i32 %8, i32 %0)
  %9 = icmp sgt i32 %spec.select, %1
  br i1 %9, label %10, label %11

10:                                               ; preds = %7
  store i32 0, ptr %4, align 4, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %54

11:                                               ; preds = %7
  %12 = sub i32 %spec.select, %8
  %13 = icmp sgt i32 %3, 1
  %14 = sext i32 %12 to i64
  br i1 %13, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %11
  %15 = sext i32 %spec.select to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %14, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %16 = phi <2 x double> [ zeroinitializer, %.lr.ph.preheader ], [ %23, %.lr.ph ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %17 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %18 = load float, ptr %17, align 4, !tbaa !9
  %19 = fpext float %18 to double
  %20 = fmul double %19, %19
  %21 = insertelement <2 x double> poison, double %19, i64 0
  %22 = insertelement <2 x double> %21, double %20, i64 1
  %23 = fadd <2 x double> %16, %22
  %24 = icmp slt i64 %indvars.iv.next, %15
  br i1 %24, label %.lr.ph, label %.loopexit.loopexit, !llvm.loop !11

.loopexit.loopexit:                               ; preds = %.lr.ph
  %25 = trunc nsw i64 %indvars.iv.next to i32
  %sext = shl i64 %indvars.iv.next, 32
  %.pre85 = ashr exact i64 %sext, 32
  br label %.loopexit

.loopexit:                                        ; preds = %11, %.loopexit.loopexit
  %.pre-phi86 = phi i64 [ %.pre85, %.loopexit.loopexit ], [ %14, %11 ]
  %.1 = phi i32 [ %25, %.loopexit.loopexit ], [ %12, %11 ]
  %26 = phi <2 x double> [ %23, %.loopexit.loopexit ], [ zeroinitializer, %11 ]
  %27 = sitofp i32 %3 to double
  %smax = tail call i32 @llvm.smax.i32(i32 %.1, i32 %1)
  %28 = add i32 %smax, 1
  %29 = sub i32 %28, %.1
  %wide.trip.count = zext i32 %29 to i64
  br label %30

30:                                               ; preds = %30, %.loopexit
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %30 ], [ %14, %.loopexit ]
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %30 ], [ 0, %.loopexit ]
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %30 ], [ %.pre-phi86, %.loopexit ]
  %31 = phi <2 x double> [ %49, %30 ], [ %26, %.loopexit ]
  %indvars.iv.next75 = add nsw i64 %indvars.iv74, 1
  %32 = getelementptr inbounds float, ptr %2, i64 %indvars.iv74
  %33 = load float, ptr %32, align 4, !tbaa !9
  %34 = fpext float %33 to double
  %35 = fmul double %34, %34
  %36 = insertelement <2 x double> poison, double %34, i64 0
  %37 = insertelement <2 x double> %36, double %35, i64 1
  %38 = fadd <2 x double> %31, %37
  %39 = extractelement <2 x double> %38, i64 0
  %40 = fdiv double %39, %27
  %41 = extractelement <2 x double> %38, i64 1
  %42 = fdiv double %41, %27
  %indvars.iv.next79 = add nsw i64 %indvars.iv78, 1
  %43 = getelementptr inbounds float, ptr %2, i64 %indvars.iv78
  %44 = load float, ptr %43, align 4, !tbaa !9
  %45 = fpext float %44 to double
  %46 = fmul double %45, %45
  %47 = insertelement <2 x double> poison, double %45, i64 0
  %48 = insertelement <2 x double> %47, double %46, i64 1
  %49 = fsub <2 x double> %38, %48
  %50 = fneg double %40
  %51 = tail call double @llvm.fmuladd.f64(double %50, double %40, double %42)
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %52 = getelementptr inbounds double, ptr %6, i64 %indvars.iv76
  store double %51, ptr %52, align 8, !tbaa !13
  %exitcond.not = icmp eq i64 %indvars.iv.next77, %wide.trip.count
  br i1 %exitcond.not, label %53, label %30, !llvm.loop !15

53:                                               ; preds = %30
  store i32 %29, ptr %5, align 4, !tbaa !5
  store i32 %spec.select, ptr %4, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %53, %10
  ret i32 0
}

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


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