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

; 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"

%struct.TA_LibcPriv = type { i32, [3 x %struct.TA_ModuleControl], i32, i32, ptr, ptr, i32, [24 x i32], [11 x %struct.TA_CandleSetting] }
%struct.TA_ModuleControl = type { i32, ptr, ptr }
%struct.TA_CandleSetting = type { i32, i32, i32, double }

@TA_Globals = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @TA_CDLABANDONEDBABY_Lookback(double noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  store double %0, ptr %3, align 8, !tbaa !5
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fcmp oeq double %4, -4.000000e+37
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  store double 3.000000e-01, ptr %3, align 8, !tbaa !5
  br label %15

7:                                                ; preds = %1
  %8 = load double, ptr %3, align 8, !tbaa !5
  %9 = fcmp olt double %8, 0.000000e+00
  br i1 %9, label %13, label %10

10:                                               ; preds = %7
  %11 = load double, ptr %3, align 8, !tbaa !5
  %12 = fcmp ogt double %11, 3.000000e+37
  br i1 %12, label %13, label %14

13:                                               ; preds = %10, %7
  store i32 -1, ptr %2, align 4
  br label %83

14:                                               ; preds = %10
  br label %15

15:                                               ; preds = %14, %6
  %16 = load double, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.TA_LibcPriv, ptr %17, i32 0, i32 8
  %19 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %18, i64 0, i64 3
  %20 = getelementptr inbounds %struct.TA_CandleSetting, ptr %19, i32 0, i32 2
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.TA_LibcPriv, ptr %22, i32 0, i32 8
  %24 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %23, i64 0, i64 0
  %25 = getelementptr inbounds %struct.TA_CandleSetting, ptr %24, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !11
  %27 = icmp sgt i32 %21, %26
  br i1 %27, label %28, label %34

28:                                               ; preds = %15
  %29 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.TA_LibcPriv, ptr %29, i32 0, i32 8
  %31 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %30, i64 0, i64 3
  %32 = getelementptr inbounds %struct.TA_CandleSetting, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !11
  br label %40

34:                                               ; preds = %15
  %35 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.TA_LibcPriv, ptr %35, i32 0, i32 8
  %37 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %36, i64 0, i64 0
  %38 = getelementptr inbounds %struct.TA_CandleSetting, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 8, !tbaa !11
  br label %40

40:                                               ; preds = %34, %28
  %41 = phi i32 [ %33, %28 ], [ %39, %34 ]
  %42 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.TA_LibcPriv, ptr %42, i32 0, i32 8
  %44 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %43, i64 0, i64 2
  %45 = getelementptr inbounds %struct.TA_CandleSetting, ptr %44, i32 0, i32 2
  %46 = load i32, ptr %45, align 8, !tbaa !11
  %47 = icmp sgt i32 %41, %46
  br i1 %47, label %48, label %74

48:                                               ; preds = %40
  %49 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.TA_LibcPriv, ptr %49, i32 0, i32 8
  %51 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %50, i64 0, i64 3
  %52 = getelementptr inbounds %struct.TA_CandleSetting, ptr %51, i32 0, i32 2
  %53 = load i32, ptr %52, align 8, !tbaa !11
  %54 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.TA_LibcPriv, ptr %54, i32 0, i32 8
  %56 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %55, i64 0, i64 0
  %57 = getelementptr inbounds %struct.TA_CandleSetting, ptr %56, i32 0, i32 2
  %58 = load i32, ptr %57, align 8, !tbaa !11
  %59 = icmp sgt i32 %53, %58
  br i1 %59, label %60, label %66

60:                                               ; preds = %48
  %61 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.TA_LibcPriv, ptr %61, i32 0, i32 8
  %63 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %62, i64 0, i64 3
  %64 = getelementptr inbounds %struct.TA_CandleSetting, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 8, !tbaa !11
  br label %72

66:                                               ; preds = %48
  %67 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.TA_LibcPriv, ptr %67, i32 0, i32 8
  %69 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %68, i64 0, i64 0
  %70 = getelementptr inbounds %struct.TA_CandleSetting, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 8, !tbaa !11
  br label %72

72:                                               ; preds = %66, %60
  %73 = phi i32 [ %65, %60 ], [ %71, %66 ]
  br label %80

74:                                               ; preds = %40
  %75 = load ptr, ptr @TA_Globals, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.TA_LibcPriv, ptr %75, i32 0, i32 8
  %77 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %76, i64 0, i64 2
  %78 = getelementptr inbounds %struct.TA_CandleSetting, ptr %77, i32 0, i32 2
  %79 = load i32, ptr %78, align 8, !tbaa !11
  br label %80

80:                                               ; preds = %74, %72
  %81 = phi i32 [ %73, %72 ], [ %79, %74 ]
  %82 = add nsw i32 %81, 2
  store i32 %82, ptr %2, align 4
  br label %83

83:                                               ; preds = %80, %13
  %84 = load i32, ptr %2, align 4
  ret i32 %84
}

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" }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16}
!13 = !{!"int", !7, i64 0}


; 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"

@TA_Globals = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local range(i32 -2147483646, -2147483648) i32 @TA_CDLABANDONEDBABY_Lookback(double noundef %0) local_unnamed_addr #0 {
  %2 = fcmp oeq double %0, -4.000000e+37
  br i1 %2, label %6, label %3

3:                                                ; preds = %1
  %4 = fcmp olt double %0, 0.000000e+00
  %5 = fcmp ogt double %0, 3.000000e+37
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %15, label %6

6:                                                ; preds = %1, %3
  %7 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 288
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %7, i64 216
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %. = tail call i32 @llvm.smax.i32(i32 %9, i32 %11)
  %12 = getelementptr inbounds i8, ptr %7, i64 264
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %spec.select = tail call i32 @llvm.smax.i32(i32 %., i32 %13)
  %14 = add nsw i32 %spec.select, 2
  br label %15

15:                                               ; preds = %3, %6
  %.05 = phi i32 [ %14, %6 ], [ -1, %3 ]
  ret i32 %.05
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass