; 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: nounwind uwtable
define dso_local i32 @TA_INT_VAR(i32 noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %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 %128

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

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

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 double, ptr %53, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !11
  store double %58, ptr %16, align 8, !tbaa !11
  %59 = load double, ptr %16, align 8, !tbaa !11
  %60 = load double, ptr %17, align 8, !tbaa !11
  %61 = fadd double %60, %59
  store double %61, ptr %17, align 8, !tbaa !11
  %62 = load double, ptr %16, align 8, !tbaa !11
  %63 = load double, ptr %16, align 8, !tbaa !11
  %64 = fmul double %63, %62
  store double %64, ptr %16, align 8, !tbaa !11
  %65 = load double, ptr %16, align 8, !tbaa !11
  %66 = load double, ptr %18, align 8, !tbaa !11
  %67 = fadd double %66, %65
  store double %67, ptr %18, align 8, !tbaa !11
  br label %48, !llvm.loop !13

68:                                               ; preds = %48
  br label %69

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

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

119:                                              ; preds = %70
  %120 = load i32, ptr %21, align 4, !tbaa !5
  %121 = load i32, ptr %10, align 4, !tbaa !5
  %122 = icmp sle i32 %120, %121
  br i1 %122, label %70, label %123, !llvm.loop !15

123:                                              ; preds = %119
  %124 = load i32, ptr %22, align 4, !tbaa !5
  %125 = load ptr, ptr %14, align 8, !tbaa !9
  store i32 %124, ptr %125, align 4, !tbaa !5
  %126 = load i32, ptr %9, align 4, !tbaa !5
  %127 = load ptr, ptr %13, align 8, !tbaa !9
  store i32 %126, ptr %127, align 4, !tbaa !5
  store i32 0, ptr %8, align 4
  store i32 1, ptr %25, align 4
  br label %128

128:                                              ; preds = %123, %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
  %129 = load i32, ptr %8, align 4
  ret i32 %129
}

; 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"}
!15 = distinct !{!15, !14}


; 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 noundef i32 @TA_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 #0 {
  %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 %51

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 ], [ %22, %.lr.ph ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %17 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = fmul double %18, %18
  %20 = insertelement <2 x double> poison, double %18, i64 0
  %21 = insertelement <2 x double> %20, double %19, i64 1
  %22 = fadd <2 x double> %16, %21
  %23 = icmp slt i64 %indvars.iv.next, %15
  br i1 %23, label %.lr.ph, label %.loopexit.loopexit, !llvm.loop !11

.loopexit.loopexit:                               ; preds = %.lr.ph
  %24 = 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 [ %24, %.loopexit.loopexit ], [ %12, %11 ]
  %25 = phi <2 x double> [ %22, %.loopexit.loopexit ], [ zeroinitializer, %11 ]
  %26 = sitofp i32 %3 to double
  %smax = tail call i32 @llvm.smax.i32(i32 %.1, i32 %1)
  %27 = add i32 %smax, 1
  %28 = sub i32 %27, %.1
  %wide.trip.count = zext i32 %28 to i64
  br label %29

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

50:                                               ; preds = %29
  store i32 %28, ptr %5, align 4, !tbaa !5
  store i32 %spec.select, ptr %4, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %50, %10
  ret i32 0
}

; 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 i32 @llvm.smax.i32(i32, i32) #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 = !{!"int", !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}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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