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

; 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.fabs.f64(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_TRANGE(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 double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  %23 = alloca double, align 8
  %24 = alloca double, align 8
  %25 = alloca double, align 8
  %26 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #3
  %27 = load i32, ptr %10, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %8
  store i32 12, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %125

30:                                               ; preds = %8
  %31 = load i32, ptr %11, align 4, !tbaa !5
  %32 = icmp slt i32 %31, 0
  br i1 %32, label %37, label %33

33:                                               ; preds = %30
  %34 = load i32, ptr %11, align 4, !tbaa !5
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %33, %30
  store i32 13, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %125

38:                                               ; preds = %33
  %39 = load ptr, ptr %12, align 8, !tbaa !9
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %47

41:                                               ; preds = %38
  %42 = load ptr, ptr %13, align 8, !tbaa !9
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %47

44:                                               ; preds = %41
  %45 = load ptr, ptr %14, align 8, !tbaa !9
  %46 = icmp ne ptr %45, null
  br i1 %46, label %48, label %47

47:                                               ; preds = %44, %41, %38
  store i32 2, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %125

48:                                               ; preds = %44
  %49 = load ptr, ptr %17, align 8, !tbaa !9
  %50 = icmp ne ptr %49, null
  br i1 %50, label %52, label %51

51:                                               ; preds = %48
  store i32 2, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %125

52:                                               ; preds = %48
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = icmp slt i32 %53, 1
  br i1 %54, label %55, label %56

55:                                               ; preds = %52
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %55, %52
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = load i32, ptr %11, align 4, !tbaa !5
  %59 = icmp sgt i32 %57, %58
  br i1 %59, label %60, label %63

60:                                               ; preds = %56
  %61 = load ptr, ptr %15, align 8, !tbaa !9
  store i32 0, ptr %61, align 4, !tbaa !5
  %62 = load ptr, ptr %16, align 8, !tbaa !9
  store i32 0, ptr %62, align 4, !tbaa !5
  store i32 0, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %125

63:                                               ; preds = %56
  store i32 0, ptr %19, align 4, !tbaa !5
  %64 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %64, ptr %18, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %111, %63
  %66 = load i32, ptr %18, align 4, !tbaa !5
  %67 = load i32, ptr %11, align 4, !tbaa !5
  %68 = icmp sle i32 %66, %67
  br i1 %68, label %69, label %120

69:                                               ; preds = %65
  %70 = load ptr, ptr %13, align 8, !tbaa !9
  %71 = load i32, ptr %18, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds float, ptr %70, i64 %72
  %74 = load float, ptr %73, align 4, !tbaa !11
  %75 = fpext float %74 to double
  store double %75, ptr %24, align 8, !tbaa !13
  %76 = load ptr, ptr %12, align 8, !tbaa !9
  %77 = load i32, ptr %18, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %76, i64 %78
  %80 = load float, ptr %79, align 4, !tbaa !11
  %81 = fpext float %80 to double
  store double %81, ptr %25, align 8, !tbaa !13
  %82 = load ptr, ptr %14, align 8, !tbaa !9
  %83 = load i32, ptr %18, align 4, !tbaa !5
  %84 = sub nsw i32 %83, 1
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds float, ptr %82, i64 %85
  %87 = load float, ptr %86, align 4, !tbaa !11
  %88 = fpext float %87 to double
  store double %88, ptr %23, align 8, !tbaa !13
  %89 = load double, ptr %25, align 8, !tbaa !13
  %90 = load double, ptr %24, align 8, !tbaa !13
  %91 = fsub double %89, %90
  store double %91, ptr %22, align 8, !tbaa !13
  %92 = load double, ptr %23, align 8, !tbaa !13
  %93 = load double, ptr %25, align 8, !tbaa !13
  %94 = fsub double %92, %93
  %95 = call double @llvm.fabs.f64(double %94)
  store double %95, ptr %20, align 8, !tbaa !13
  %96 = load double, ptr %20, align 8, !tbaa !13
  %97 = load double, ptr %22, align 8, !tbaa !13
  %98 = fcmp ogt double %96, %97
  br i1 %98, label %99, label %101

99:                                               ; preds = %69
  %100 = load double, ptr %20, align 8, !tbaa !13
  store double %100, ptr %22, align 8, !tbaa !13
  br label %101

101:                                              ; preds = %99, %69
  %102 = load double, ptr %23, align 8, !tbaa !13
  %103 = load double, ptr %24, align 8, !tbaa !13
  %104 = fsub double %102, %103
  %105 = call double @llvm.fabs.f64(double %104)
  store double %105, ptr %21, align 8, !tbaa !13
  %106 = load double, ptr %21, align 8, !tbaa !13
  %107 = load double, ptr %22, align 8, !tbaa !13
  %108 = fcmp ogt double %106, %107
  br i1 %108, label %109, label %111

109:                                              ; preds = %101
  %110 = load double, ptr %21, align 8, !tbaa !13
  store double %110, ptr %22, align 8, !tbaa !13
  br label %111

111:                                              ; preds = %109, %101
  %112 = load double, ptr %22, align 8, !tbaa !13
  %113 = load ptr, ptr %17, align 8, !tbaa !9
  %114 = load i32, ptr %19, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %19, align 4, !tbaa !5
  %116 = sext i32 %114 to i64
  %117 = getelementptr inbounds double, ptr %113, i64 %116
  store double %112, ptr %117, align 8, !tbaa !13
  %118 = load i32, ptr %18, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %18, align 4, !tbaa !5
  br label %65, !llvm.loop !15

120:                                              ; preds = %65
  %121 = load i32, ptr %19, align 4, !tbaa !5
  %122 = load ptr, ptr %16, align 8, !tbaa !9
  store i32 %121, ptr %122, align 4, !tbaa !5
  %123 = load i32, ptr %10, align 4, !tbaa !5
  %124 = load ptr, ptr %15, align 8, !tbaa !9
  store i32 %123, ptr %124, align 4, !tbaa !5
  store i32 0, ptr %9, align 4
  store i32 1, ptr %26, align 4
  br label %125

125:                                              ; preds = %120, %60, %51, %47, %37, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %126 = load i32, ptr %9, align 4
  ret i32 %126
}

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.fabs.f64(double) #0

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local range(i32 0, 14) i32 @TA_S_TRANGE(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 %59, label %10

10:                                               ; preds = %8
  %11 = icmp slt i32 %1, %0
  br i1 %11, label %59, 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 %19, label %59

19:                                               ; preds = %12
  %20 = tail call i32 @llvm.umax.i32(i32 %0, i32 1)
  %21 = icmp ugt i32 %20, %1
  br i1 %21, label %42, label %.preheader

.preheader:                                       ; preds = %19
  %invariant.gep = getelementptr i8, ptr %4, i64 -4
  %22 = tail call i32 @llvm.umax.i32(i32 %0, i32 1)
  %umax = zext nneg i32 %22 to i64
  %23 = add nuw i32 %1, 1
  %24 = sub i32 %23, %20
  %wide.trip.count = zext i32 %24 to i64
  %min.iters.check = icmp ult i32 %24, 2
  br i1 %min.iters.check, label %.lr.ph.preheader, label %vector.ph

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

vector.ph:                                        ; preds = %.preheader
  %n.vec = and i64 %wide.trip.count, 4294967294
  %ind.end = add nuw nsw i64 %n.vec, %umax
  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, %umax
  %25 = getelementptr inbounds float, ptr %3, i64 %offset.idx
  %wide.load = load <2 x float>, ptr %25, align 4, !tbaa !5
  %26 = fpext <2 x float> %wide.load to <2 x double>
  %27 = getelementptr inbounds float, ptr %2, i64 %offset.idx
  %wide.load72 = load <2 x float>, ptr %27, align 4, !tbaa !5
  %28 = fpext <2 x float> %wide.load72 to <2 x double>
  %29 = getelementptr float, ptr %invariant.gep, i64 %offset.idx
  %wide.load73 = load <2 x float>, ptr %29, align 4, !tbaa !5
  %30 = fpext <2 x float> %wide.load73 to <2 x double>
  %31 = fsub <2 x double> %28, %26
  %32 = fsub <2 x double> %30, %28
  %33 = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %32)
  %34 = fcmp ogt <2 x double> %33, %31
  %35 = select <2 x i1> %34, <2 x double> %33, <2 x double> %31
  %36 = fsub <2 x double> %30, %26
  %37 = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %36)
  %38 = fcmp ogt <2 x double> %37, %35
  %39 = select <2 x i1> %38, <2 x double> %37, <2 x double> %35
  %40 = getelementptr inbounds double, ptr %7, i64 %index
  store <2 x double> %39, ptr %40, align 8, !tbaa !9
  %index.next = add nuw i64 %index, 2
  %41 = icmp eq i64 %index.next, %n.vec
  br i1 %41, 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.preheader

42:                                               ; preds = %19
  store i32 0, ptr %5, align 4, !tbaa !15
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %59

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.lr.ph ], [ %indvars.iv68.ph, %.lr.ph.preheader ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader ]
  %43 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  %44 = load float, ptr %43, align 4, !tbaa !5
  %45 = fpext float %44 to double
  %46 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %47 = load float, ptr %46, align 4, !tbaa !5
  %48 = fpext float %47 to double
  %gep = getelementptr float, ptr %invariant.gep, i64 %indvars.iv
  %49 = load float, ptr %gep, align 4, !tbaa !5
  %50 = fpext float %49 to double
  %51 = fsub double %48, %45
  %52 = fsub double %50, %48
  %53 = tail call double @llvm.fabs.f64(double %52)
  %54 = fcmp ogt double %53, %51
  %.046 = select i1 %54, double %53, double %51
  %55 = fsub double %50, %45
  %56 = tail call double @llvm.fabs.f64(double %55)
  %57 = fcmp ogt double %56, %.046
  %.1 = select i1 %57, double %56, double %.046
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %58 = getelementptr inbounds double, ptr %7, i64 %indvars.iv68
  store double %.1, ptr %58, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next69, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph, %middle.block
  store i32 %24, ptr %6, align 4, !tbaa !15
  store i32 %20, ptr %5, align 4, !tbaa !15
  br label %59

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fabs.v2f64(<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 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !12, !14, !13}


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