; 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_StringTablePriv = type { i32 }
%struct.TA_StringTable = type { i32, 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; 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_FuncTableAlloc(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %19, label %16

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %16, %2
  store i32 2, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %112

20:                                               ; preds = %16
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %21, align 8, !tbaa !5
  store ptr null, ptr %11, align 8, !tbaa !5
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call i32 @getGroupId(ptr noundef %22, ptr noundef %9)
  store i32 %23, ptr %6, align 4, !tbaa !9
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %20
  %27 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %27, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %112

28:                                               ; preds = %20
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = call i32 @getGroupSize(i32 noundef %29, ptr noundef %10)
  store i32 %30, ptr %6, align 4, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %28
  %34 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %34, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %112

35:                                               ; preds = %28
  %36 = call noalias ptr @malloc(i64 noundef 28) #5
  store ptr %36, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %41, label %39

39:                                               ; preds = %35
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %40, align 8, !tbaa !5
  store i32 3, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %112

41:                                               ; preds = %35
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %42, i8 0, i64 28, i1 false)
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i64 24
  store ptr %44, ptr %12, align 8, !tbaa !5
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.TA_StringTablePriv, ptr %45, i32 0, i32 0
  store i32 -1576226292, ptr %46, align 4, !tbaa !11
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TA_StringTable, ptr %48, i32 0, i32 2
  store ptr %47, ptr %49, align 8, !tbaa !13
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.TA_StringTable, ptr %51, i32 0, i32 0
  store i32 %50, ptr %52, align 8, !tbaa !15
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %109

55:                                               ; preds = %41
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.TA_StringTable, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !15
  %59 = zext i32 %58 to i64
  %60 = mul i64 %59, 8
  %61 = call noalias ptr @malloc(i64 noundef %60) #5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.TA_StringTable, ptr %62, i32 0, i32 1
  store ptr %61, ptr %63, align 8, !tbaa !16
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.TA_StringTable, ptr %64, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  %67 = icmp eq ptr %66, null
  br i1 %67, label %68, label %72

68:                                               ; preds = %55
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %69, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = call i32 @TA_FuncTableFree(ptr noundef %70)
  store i32 3, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %112

72:                                               ; preds = %55
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.TA_StringTable, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !16
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.TA_StringTable, ptr %76, i32 0, i32 0
  %78 = load i32, ptr %77, align 8, !tbaa !15
  %79 = zext i32 %78 to i64
  %80 = mul i64 %79, 8
  call void @llvm.memset.p0.i64(ptr align 1 %75, i8 0, i64 %80, i1 false)
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %81

81:                                               ; preds = %105, %72
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.TA_StringTable, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !15
  %86 = icmp ult i32 %82, %85
  br i1 %86, label %87, label %108

87:                                               ; preds = %81
  %88 = load i32, ptr %9, align 4, !tbaa !9
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = call i32 @getFuncNameByIdx(i32 noundef %88, i32 noundef %89, ptr noundef %11)
  store i32 %90, ptr %6, align 4, !tbaa !9
  %91 = load i32, ptr %6, align 4, !tbaa !9
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %97

93:                                               ; preds = %87
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %94, align 8, !tbaa !5
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = call i32 @TA_FuncTableFree(ptr noundef %95)
  store i32 3, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %112

97:                                               ; preds = %87
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.TA_StringTable, ptr %99, i32 0, i32 1
  %101 = load ptr, ptr %100, align 8, !tbaa !16
  %102 = load i32, ptr %7, align 4, !tbaa !9
  %103 = zext i32 %102 to i64
  %104 = getelementptr inbounds ptr, ptr %101, i64 %103
  store ptr %98, ptr %104, align 8, !tbaa !5
  br label %105

105:                                              ; preds = %97
  %106 = load i32, ptr %7, align 4, !tbaa !9
  %107 = add i32 %106, 1
  store i32 %107, ptr %7, align 4, !tbaa !9
  br label %81, !llvm.loop !17

108:                                              ; preds = %81
  br label %109

109:                                              ; preds = %108, %41
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %110, ptr %111, align 8, !tbaa !5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %112

112:                                              ; preds = %109, %93, %68, %39, %33, %26, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %113 = load i32, ptr %3, align 4
  ret i32 %113
}

; Function Attrs: nounwind uwtable
declare hidden i32 @getGroupId(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @getGroupSize(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @TA_FuncTableFree(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @getFuncNameByIdx(i32 noundef, i32 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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, !10, i64 0}
!12 = !{!"", !10, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"TA_StringTable", !10, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!14, !10, i64 0}
!16 = !{!14, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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_FuncTableAlloc(ptr noundef %0, ptr noundef writeonly %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = icmp eq ptr %0, null
  %7 = icmp eq ptr %1, null
  %or.cond = or i1 %6, %7
  br i1 %or.cond, label %38, label %8

8:                                                ; preds = %2
  store ptr null, ptr %1, align 8, !tbaa !5
  store ptr null, ptr %5, align 8, !tbaa !5
  %9 = call i32 @getGroupId(ptr noundef nonnull %0, ptr noundef nonnull %3)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %38

10:                                               ; preds = %8
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = call i32 @getGroupSize(i32 noundef %11, ptr noundef nonnull %4)
  %.not42 = icmp eq i32 %12, 0
  br i1 %.not42, label %13, label %38

13:                                               ; preds = %10
  %calloc49 = call dereferenceable_or_null(28) ptr @calloc(i64 1, i64 28)
  %.not43 = icmp eq ptr %calloc49, null
  br i1 %.not43, label %14, label %15

14:                                               ; preds = %13
  store ptr null, ptr %1, align 8, !tbaa !5
  br label %38

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %calloc49, i64 24
  store i32 -1576226292, ptr %16, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %calloc49, i64 16
  store ptr %16, ptr %17, align 8, !tbaa !13
  %18 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %18, ptr %calloc49, align 8, !tbaa !15
  %.not44 = icmp eq i32 %18, 0
  br i1 %.not44, label %.loopexit, label %19

19:                                               ; preds = %15
  %20 = zext i32 %18 to i64
  %21 = shl nuw nsw i64 %20, 3
  %calloc = call ptr @calloc(i64 1, i64 %21)
  %22 = getelementptr inbounds i8, ptr %calloc49, i64 8
  store ptr %calloc, ptr %22, align 8, !tbaa !16
  %23 = icmp eq ptr %calloc, null
  br i1 %23, label %24, label %.lr.ph

24:                                               ; preds = %19
  store ptr null, ptr %1, align 8, !tbaa !5
  %25 = call i32 @TA_FuncTableFree(ptr noundef nonnull %calloc49)
  br label %38

.lr.ph:                                           ; preds = %19, %31
  %indvars.iv = phi i64 [ %indvars.iv.next, %31 ], [ 0, %19 ]
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = trunc nuw i64 %indvars.iv to i32
  %28 = call i32 @getFuncNameByIdx(i32 noundef %26, i32 noundef %27, ptr noundef nonnull %5)
  %.not45 = icmp eq i32 %28, 0
  br i1 %.not45, label %31, label %29

29:                                               ; preds = %.lr.ph
  store ptr null, ptr %1, align 8, !tbaa !5
  %30 = call i32 @TA_FuncTableFree(ptr noundef nonnull %calloc49)
  br label %38

31:                                               ; preds = %.lr.ph
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %22, align 8, !tbaa !16
  %34 = getelementptr inbounds ptr, ptr %33, i64 %indvars.iv
  store ptr %32, ptr %34, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = load i32, ptr %calloc49, align 8, !tbaa !15
  %36 = zext i32 %35 to i64
  %37 = icmp ult i64 %indvars.iv.next, %36
  br i1 %37, label %.lr.ph, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %31, %15
  store ptr %calloc49, ptr %1, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %10, %8, %2, %.loopexit, %29, %24, %14
  %.0 = phi i32 [ 3, %24 ], [ 3, %29 ], [ 0, %.loopexit ], [ 3, %14 ], [ 2, %2 ], [ %9, %8 ], [ %12, %10 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @getGroupId(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @getGroupSize(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TA_FuncTableFree(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @getFuncNameByIdx(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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 = !{!"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, !10, i64 0}
!12 = !{!"", !10, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"TA_StringTable", !10, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!14, !10, i64 0}
!16 = !{!14, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass