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

; 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_ParamHolder = type { ptr }
%struct.TA_ParamHolderPriv = type { i32, ptr, ptr, ptr, i32, i32, ptr }
%struct.TA_FuncInfo = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, ptr }
%struct.TA_ParamHolderInput = type { %union.TA_ParamHolderInputData, ptr }
%union.TA_ParamHolderInputData = type { %struct.TA_PricePtrs }
%struct.TA_PricePtrs = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.TA_InputParameterInfo = type { i32, ptr, i32 }

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @TA_SetInputParamIntegerPtr(ptr noundef %0, i32 noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %17, label %14

14:                                               ; preds = %3
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14, %3
  store i32 2, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %75

18:                                               ; preds = %14
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.TA_ParamHolder, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  store ptr %21, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.TA_ParamHolderPriv, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !13
  %25 = icmp ne i32 %24, -1576881662
  br i1 %25, label %26, label %27

26:                                               ; preds = %18
  store i32 7, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %75

27:                                               ; preds = %18
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.TA_ParamHolderPriv, ptr %28, i32 0, i32 6
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  store ptr %30, ptr %10, align 8, !tbaa !5
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %34, label %33

33:                                               ; preds = %27
  store i32 6, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %75

34:                                               ; preds = %27
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.TA_FuncInfo, ptr %36, i32 0, i32 5
  %38 = load i32, ptr %37, align 4, !tbaa !16
  %39 = icmp uge i32 %35, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %34
  store i32 2, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %75

41:                                               ; preds = %34
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.TA_ParamHolderPriv, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds %struct.TA_ParamHolderInput, ptr %44, i64 %46
  %48 = getelementptr inbounds %struct.TA_ParamHolderInput, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !19
  store ptr %49, ptr %9, align 8, !tbaa !5
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %53, label %52

52:                                               ; preds = %41
  store i32 5002, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %75

53:                                               ; preds = %41
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.TA_InputParameterInfo, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !21
  %57 = icmp ne i32 %56, 2
  br i1 %57, label %58, label %59

58:                                               ; preds = %53
  store i32 8, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %75

59:                                               ; preds = %53
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.TA_ParamHolderPriv, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds %struct.TA_ParamHolderInput, ptr %63, i64 %65
  %67 = getelementptr inbounds %struct.TA_ParamHolderInput, ptr %66, i32 0, i32 0
  store ptr %60, ptr %67, align 8, !tbaa !23
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = shl i32 1, %68
  %70 = xor i32 %69, -1
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.TA_ParamHolderPriv, ptr %71, i32 0, i32 4
  %73 = load i32, ptr %72, align 8, !tbaa !24
  %74 = and i32 %73, %70
  store i32 %74, ptr %72, align 8, !tbaa !24
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %75

75:                                               ; preds = %59, %58, %52, %40, %33, %26, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %76 = load i32, ptr %4, align 4
  ret i32 %76
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"TA_ParamHolder", !6, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40}
!15 = !{!14, !6, i64 40}
!16 = !{!17, !10, i64 36}
!17 = !{!"TA_FuncInfo", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !6, i64 48}
!18 = !{!14, !6, i64 8}
!19 = !{!20, !6, i64 48}
!20 = !{!"", !7, i64 0, !6, i64 48}
!21 = !{!22, !10, i64 0}
!22 = !{!"TA_InputParameterInfo", !10, i64 0, !6, i64 8, !10, i64 16}
!23 = !{!7, !7, i64 0}
!24 = !{!14, !10, i64 32}


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

%struct.TA_ParamHolderInput = type { %union.TA_ParamHolderInputData, ptr }
%union.TA_ParamHolderInputData = type { %struct.TA_PricePtrs }
%struct.TA_PricePtrs = type { ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 5003) i32 @TA_SetInputParamIntegerPtr(ptr noundef readonly %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %2, null
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %30, label %6

6:                                                ; preds = %3
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = load i32, ptr %7, align 8, !tbaa !10
  %.not = icmp eq i32 %8, -1576881662
  br i1 %.not, label %9, label %30

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %7, i64 40
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %.not23 = icmp eq ptr %11, null
  br i1 %.not23, label %30, label %12

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %11, i64 36
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %.not24 = icmp ugt i32 %14, %1
  br i1 %.not24, label %15, label %30

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %7, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = zext i32 %1 to i64
  %19 = getelementptr inbounds %struct.TA_ParamHolderInput, ptr %17, i64 %18
  %20 = getelementptr inbounds i8, ptr %19, i64 48
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %.not25 = icmp eq ptr %21, null
  br i1 %.not25, label %30, label %22

22:                                               ; preds = %15
  %23 = load i32, ptr %21, align 8, !tbaa !19
  %.not26 = icmp eq i32 %23, 2
  br i1 %.not26, label %24, label %30

24:                                               ; preds = %22
  store ptr %2, ptr %19, align 8, !tbaa !21
  %25 = shl nuw i32 1, %1
  %26 = xor i32 %25, -1
  %27 = getelementptr inbounds i8, ptr %7, i64 32
  %28 = load i32, ptr %27, align 8, !tbaa !22
  %29 = and i32 %28, %26
  store i32 %29, ptr %27, align 8, !tbaa !22
  br label %30

30:                                               ; preds = %22, %15, %12, %9, %6, %3, %24
  %.0 = phi i32 [ 0, %24 ], [ 2, %3 ], [ 7, %6 ], [ 6, %9 ], [ 2, %12 ], [ 5002, %15 ], [ 8, %22 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, 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" }

!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, !7, i64 0}
!6 = !{!"TA_ParamHolder", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 0}
!11 = !{!"", !12, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !12, i64 32, !12, i64 36, !7, i64 40}
!12 = !{!"int", !8, i64 0}
!13 = !{!11, !7, i64 40}
!14 = !{!15, !12, i64 36}
!15 = !{!"TA_FuncInfo", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !7, i64 48}
!16 = !{!11, !7, i64 8}
!17 = !{!18, !7, i64 48}
!18 = !{!"", !8, i64 0, !7, i64 48}
!19 = !{!20, !12, i64 0}
!20 = !{!"TA_InputParameterInfo", !12, i64 0, !7, i64 8, !12, i64 16}
!21 = !{!8, !8, i64 0}
!22 = !{!11, !12, i64 32}


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