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

; 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_CDL3STARSINSOUTH_Lookback() #0 {
  %1 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %2 = getelementptr inbounds %struct.TA_LibcPriv, ptr %1, i32 0, i32 8
  %3 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %2, i64 0, i64 7
  %4 = getelementptr inbounds %struct.TA_CandleSetting, ptr %3, i32 0, i32 2
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.TA_LibcPriv, ptr %6, i32 0, i32 8
  %8 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %7, i64 0, i64 4
  %9 = getelementptr inbounds %struct.TA_CandleSetting, ptr %8, i32 0, i32 2
  %10 = load i32, ptr %9, align 8, !tbaa !9
  %11 = icmp sgt i32 %5, %10
  br i1 %11, label %12, label %18

12:                                               ; preds = %0
  %13 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.TA_LibcPriv, ptr %13, i32 0, i32 8
  %15 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %14, i64 0, i64 7
  %16 = getelementptr inbounds %struct.TA_CandleSetting, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !9
  br label %24

18:                                               ; preds = %0
  %19 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.TA_LibcPriv, ptr %19, i32 0, i32 8
  %21 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %20, i64 0, i64 4
  %22 = getelementptr inbounds %struct.TA_CandleSetting, ptr %21, i32 0, i32 2
  %23 = load i32, ptr %22, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %18, %12
  %25 = phi i32 [ %17, %12 ], [ %23, %18 ]
  %26 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.TA_LibcPriv, ptr %26, i32 0, i32 8
  %28 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %27, i64 0, i64 0
  %29 = getelementptr inbounds %struct.TA_CandleSetting, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 8, !tbaa !9
  %31 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.TA_LibcPriv, ptr %31, i32 0, i32 8
  %33 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %32, i64 0, i64 2
  %34 = getelementptr inbounds %struct.TA_CandleSetting, ptr %33, i32 0, i32 2
  %35 = load i32, ptr %34, align 8, !tbaa !9
  %36 = icmp sgt i32 %30, %35
  br i1 %36, label %37, label %43

37:                                               ; preds = %24
  %38 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TA_LibcPriv, ptr %38, i32 0, i32 8
  %40 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %39, i64 0, i64 0
  %41 = getelementptr inbounds %struct.TA_CandleSetting, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %41, align 8, !tbaa !9
  br label %49

43:                                               ; preds = %24
  %44 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.TA_LibcPriv, ptr %44, i32 0, i32 8
  %46 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %45, i64 0, i64 2
  %47 = getelementptr inbounds %struct.TA_CandleSetting, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %43, %37
  %50 = phi i32 [ %42, %37 ], [ %48, %43 ]
  %51 = icmp sgt i32 %25, %50
  br i1 %51, label %52, label %78

52:                                               ; preds = %49
  %53 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.TA_LibcPriv, ptr %53, i32 0, i32 8
  %55 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %54, i64 0, i64 7
  %56 = getelementptr inbounds %struct.TA_CandleSetting, ptr %55, i32 0, i32 2
  %57 = load i32, ptr %56, align 8, !tbaa !9
  %58 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.TA_LibcPriv, ptr %58, i32 0, i32 8
  %60 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %59, i64 0, i64 4
  %61 = getelementptr inbounds %struct.TA_CandleSetting, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !9
  %63 = icmp sgt i32 %57, %62
  br i1 %63, label %64, label %70

64:                                               ; preds = %52
  %65 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.TA_LibcPriv, ptr %65, i32 0, i32 8
  %67 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %66, i64 0, i64 7
  %68 = getelementptr inbounds %struct.TA_CandleSetting, ptr %67, i32 0, i32 2
  %69 = load i32, ptr %68, align 8, !tbaa !9
  br label %76

70:                                               ; preds = %52
  %71 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.TA_LibcPriv, ptr %71, i32 0, i32 8
  %73 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %72, i64 0, i64 4
  %74 = getelementptr inbounds %struct.TA_CandleSetting, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !9
  br label %76

76:                                               ; preds = %70, %64
  %77 = phi i32 [ %69, %64 ], [ %75, %70 ]
  br label %104

78:                                               ; preds = %49
  %79 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.TA_LibcPriv, ptr %79, i32 0, i32 8
  %81 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %80, i64 0, i64 0
  %82 = getelementptr inbounds %struct.TA_CandleSetting, ptr %81, i32 0, i32 2
  %83 = load i32, ptr %82, align 8, !tbaa !9
  %84 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.TA_LibcPriv, ptr %84, i32 0, i32 8
  %86 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %85, i64 0, i64 2
  %87 = getelementptr inbounds %struct.TA_CandleSetting, ptr %86, i32 0, i32 2
  %88 = load i32, ptr %87, align 8, !tbaa !9
  %89 = icmp sgt i32 %83, %88
  br i1 %89, label %90, label %96

90:                                               ; preds = %78
  %91 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.TA_LibcPriv, ptr %91, i32 0, i32 8
  %93 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %92, i64 0, i64 0
  %94 = getelementptr inbounds %struct.TA_CandleSetting, ptr %93, i32 0, i32 2
  %95 = load i32, ptr %94, align 8, !tbaa !9
  br label %102

96:                                               ; preds = %78
  %97 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.TA_LibcPriv, ptr %97, i32 0, i32 8
  %99 = getelementptr inbounds [11 x %struct.TA_CandleSetting], ptr %98, i64 0, i64 2
  %100 = getelementptr inbounds %struct.TA_CandleSetting, ptr %99, i32 0, i32 2
  %101 = load i32, ptr %100, align 8, !tbaa !9
  br label %102

102:                                              ; preds = %96, %90
  %103 = phi i32 [ %95, %90 ], [ %101, %96 ]
  br label %104

104:                                              ; preds = %102, %76
  %105 = phi i32 [ %77, %76 ], [ %103, %102 ]
  %106 = add nsw i32 %105, 2
  ret i32 %106
}

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 = !{!"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}


; 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_CDL3STARSINSOUTH_Lookback() local_unnamed_addr #0 {
  %1 = load ptr, ptr @TA_Globals, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %1, i64 384
  %3 = load i32, ptr %2, align 8, !tbaa !9
  %4 = getelementptr inbounds i8, ptr %1, i64 312
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %. = tail call i32 @llvm.smax.i32(i32 %3, i32 %5)
  %6 = getelementptr inbounds i8, ptr %1, i64 216
  %7 = load i32, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %1, i64 264
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = tail call i32 @llvm.smax.i32(i32 %7, i32 %9)
  %spec.select = tail call i32 @llvm.smax.i32(i32 %., i32 %10)
  %11 = add nsw i32 %spec.select, 2
  ret i32 %11
}

; 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,JumpThreadingPass,PostOrderFunctionAttrsPass,SimplifyCFGPass,TailCallElimPass