; 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_ParamHolderOptInput = type { %union.TA_ParamHolderOptInData, ptr }
%union.TA_ParamHolderOptInData = type { double }
%struct.TA_OptInputParameterInfo = type { i32, ptr, i32, ptr, ptr, double, ptr, ptr }

; 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_SetOptInputParamInteger(ptr noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %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 i32 %2, ptr %7, align 4, !tbaa !9
  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 %14, label %15

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

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

23:                                               ; preds = %15
  store i32 7, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %70

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

30:                                               ; preds = %24
  store i32 6, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %70

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

37:                                               ; preds = %31
  store i32 2, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %70

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

49:                                               ; preds = %38
  store i32 5002, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %70

50:                                               ; preds = %38
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.TA_OptInputParameterInfo, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !21
  %54 = icmp ne i32 %53, 2
  br i1 %54, label %55, label %61

55:                                               ; preds = %50
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.TA_OptInputParameterInfo, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !21
  %59 = icmp ne i32 %58, 3
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  store i32 8, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %70

61:                                               ; preds = %55, %50
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.TA_ParamHolderPriv, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !18
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds %struct.TA_ParamHolderOptInput, ptr %65, i64 %67
  %69 = getelementptr inbounds %struct.TA_ParamHolderOptInput, ptr %68, i32 0, i32 0
  store i32 %62, ptr %69, align 8, !tbaa !24
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %70

70:                                               ; preds = %61, %60, %49, %37, %30, %23, %14
  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
  %71 = load i32, ptr %4, align 4
  ret i32 %71
}

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 40}
!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 16}
!19 = !{!20, !6, i64 8}
!20 = !{!"", !7, i64 0, !6, i64 8}
!21 = !{!22, !10, i64 0}
!22 = !{!"TA_OptInputParameterInfo", !10, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !23, i64 40, !6, i64 48, !6, i64 56}
!23 = !{!"double", !7, i64 0}
!24 = !{!7, !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"

%struct.TA_ParamHolderOptInput = type { %union.TA_ParamHolderOptInData, ptr }
%union.TA_ParamHolderOptInData = type { double }

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

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

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

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %10, i64 40
  %13 = load i32, ptr %12, align 8, !tbaa !14
  %.not21 = icmp ugt i32 %13, %1
  br i1 %.not21, label %14, label %25

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %6, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  %17 = zext i32 %1 to i64
  %18 = getelementptr inbounds %struct.TA_ParamHolderOptInput, ptr %16, i64 %17, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !17
  %.not22 = icmp eq ptr %19, null
  br i1 %.not22, label %25, label %20

20:                                               ; preds = %14
  %21 = load i32, ptr %19, align 8, !tbaa !19
  %22 = and i32 %21, -2
  %switch = icmp eq i32 %22, 2
  br i1 %switch, label %23, label %25

23:                                               ; preds = %20
  %24 = getelementptr inbounds %struct.TA_ParamHolderOptInput, ptr %16, i64 %17
  store i32 %2, ptr %24, align 8, !tbaa !22
  br label %25

25:                                               ; preds = %20, %14, %11, %8, %5, %3, %23
  %.0 = phi i32 [ 0, %23 ], [ 2, %3 ], [ 7, %5 ], [ 6, %8 ], [ 2, %11 ], [ 5002, %14 ], [ 8, %20 ]
  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 40}
!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 16}
!17 = !{!18, !7, i64 8}
!18 = !{!"", !8, i64 0, !7, i64 8}
!19 = !{!20, !12, i64 0}
!20 = !{!"TA_OptInputParameterInfo", !12, i64 0, !7, i64 8, !12, i64 16, !7, i64 24, !7, i64 32, !21, i64 40, !7, i64 48, !7, i64 56}
!21 = !{!"double", !8, i64 0}
!22 = !{!8, !8, i64 0}


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