; 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_FuncDef = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.TA_FuncInfo = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, ptr }

@TA_DEF_Tables = external hidden global [26 x ptr], align 16
@TA_DEF_TablesSize = external hidden global [26 x ptr], align 16

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

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

21:                                               ; preds = %18, %2
  store i32 2, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

22:                                               ; preds = %18
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %23, align 8, !tbaa !5
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 0
  %26 = load i8, ptr %25, align 1, !tbaa !9
  store i8 %26, ptr %6, align 1, !tbaa !9
  %27 = load i8, ptr %6, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %22
  store i32 2, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

31:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %32 = call ptr @__ctype_tolower_loc() #5
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = load i8, ptr %6, align 1, !tbaa !9
  %35 = sext i8 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr %33, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !10
  store i32 %38, ptr %14, align 4, !tbaa !10
  %39 = load i32, ptr %14, align 4, !tbaa !10
  store i32 %39, ptr %15, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %40 = load i32, ptr %15, align 4, !tbaa !10
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %7, align 1, !tbaa !9
  %42 = load i8, ptr %7, align 1, !tbaa !9
  %43 = sext i8 %42 to i32
  %44 = icmp slt i32 %43, 97
  br i1 %44, label %49, label %45

45:                                               ; preds = %31
  %46 = load i8, ptr %7, align 1, !tbaa !9
  %47 = sext i8 %46 to i32
  %48 = icmp sgt i32 %47, 122
  br i1 %48, label %49, label %50

49:                                               ; preds = %45, %31
  store i32 5, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

50:                                               ; preds = %45
  %51 = load i8, ptr %7, align 1, !tbaa !9
  %52 = sext i8 %51 to i32
  %53 = sub nsw i32 %52, 97
  %54 = trunc i32 %53 to i8
  store i8 %54, ptr %7, align 1, !tbaa !9
  %55 = load i8, ptr %7, align 1, !tbaa !9
  %56 = sext i8 %55 to i32
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [26 x ptr], ptr @TA_DEF_Tables, i64 0, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  store ptr %59, ptr %8, align 8, !tbaa !5
  %60 = load i8, ptr %7, align 1, !tbaa !9
  %61 = sext i8 %60 to i32
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [26 x ptr], ptr @TA_DEF_TablesSize, i64 0, i64 %62
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = load i32, ptr %64, align 4, !tbaa !10
  store i32 %65, ptr %12, align 4, !tbaa !10
  %66 = load i32, ptr %12, align 4, !tbaa !10
  %67 = icmp ult i32 %66, 1
  br i1 %67, label %68, label %69

68:                                               ; preds = %50
  store i32 5, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

69:                                               ; preds = %50
  store i32 0, ptr %11, align 4, !tbaa !10
  br label %70

70:                                               ; preds = %106, %69
  %71 = load i32, ptr %11, align 4, !tbaa !10
  %72 = load i32, ptr %12, align 4, !tbaa !10
  %73 = icmp ult i32 %71, %72
  br i1 %73, label %74, label %109

74:                                               ; preds = %70
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = load i32, ptr %11, align 4, !tbaa !10
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds ptr, ptr %75, i64 %77
  %79 = load ptr, ptr %78, align 8, !tbaa !5
  store ptr %79, ptr %9, align 8, !tbaa !5
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %87

82:                                               ; preds = %74
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.TA_FuncDef, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !12
  %86 = icmp ne ptr %85, null
  br i1 %86, label %88, label %87

87:                                               ; preds = %82, %74
  store i32 5003, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

88:                                               ; preds = %82
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.TA_FuncDef, ptr %89, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !12
  store ptr %91, ptr %10, align 8, !tbaa !5
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  %93 = icmp ne ptr %92, null
  br i1 %93, label %95, label %94

94:                                               ; preds = %88
  store i32 5004, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

95:                                               ; preds = %88
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.TA_FuncInfo, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8, !tbaa !14
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = call i32 @strcmp(ptr noundef %98, ptr noundef %99) #6
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %102, label %105

102:                                              ; preds = %95
  %103 = load ptr, ptr %9, align 8, !tbaa !5
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %103, ptr %104, align 8, !tbaa !5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

105:                                              ; preds = %95
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %11, align 4, !tbaa !10
  %108 = add i32 %107, 1
  store i32 %108, ptr %11, align 4, !tbaa !10
  br label %70, !llvm.loop !16

109:                                              ; preds = %70
  store i32 5, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %110

110:                                              ; preds = %109, %102, %94, %87, %68, %49, %30, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  %111 = load i32, ptr %3, align 4
  ret i32 %111
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

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 willreturn memory(none) "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 #3 = { nounwind willreturn memory(read) "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 willreturn memory(none) }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 8}
!13 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!14 = !{!15, !6, i64 0}
!15 = !{!"TA_FuncInfo", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !6, i64 48}
!16 = distinct !{!16, !17}
!17 = !{!"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"

@TA_DEF_Tables = external hidden local_unnamed_addr global [26 x ptr], align 16
@TA_DEF_TablesSize = external hidden local_unnamed_addr global [26 x ptr], align 16

; Function Attrs: nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 5004) i32 @TA_GetFuncHandle(ptr noundef readonly %0, ptr noundef writeonly %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %.loopexit, label %5

5:                                                ; preds = %2
  store ptr null, ptr %1, align 8, !tbaa !5
  %6 = load i8, ptr %0, align 1, !tbaa !9
  %7 = icmp eq i8 %6, 0
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %5
  %9 = tail call ptr @__ctype_tolower_loc() #3
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = sext i8 %6 to i64
  %12 = getelementptr inbounds i32, ptr %10, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !10
  %sext = shl i32 %13, 24
  %14 = ashr exact i32 %sext, 24
  %15 = add nsw i32 %14, -123
  %or.cond4 = icmp ult i32 %15, -26
  br i1 %or.cond4, label %.loopexit, label %16

16:                                               ; preds = %8
  %17 = add i32 %13, 159
  %18 = and i32 %17, 255
  %19 = zext nneg i32 %18 to i64
  %20 = getelementptr inbounds [26 x ptr], ptr @TA_DEF_Tables, i64 0, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds [26 x ptr], ptr @TA_DEF_TablesSize, i64 0, i64 %19
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = load i32, ptr %23, align 4, !tbaa !10
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %16
  %wide.trip.count = zext i32 %24 to i64
  br label %.preheader

26:                                               ; preds = %32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.preheader, !llvm.loop !12

.preheader:                                       ; preds = %.preheader.preheader, %26
  %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %26 ]
  %27 = getelementptr inbounds ptr, ptr %21, i64 %indvars.iv
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %.not = icmp eq ptr %28, null
  br i1 %.not, label %.loopexit, label %29

29:                                               ; preds = %.preheader
  %30 = getelementptr inbounds i8, ptr %28, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !14
  %.not39 = icmp eq ptr %31, null
  br i1 %.not39, label %.loopexit, label %32

32:                                               ; preds = %29
  %33 = load ptr, ptr %31, align 8, !tbaa !16
  %34 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %33, ptr noundef nonnull dereferenceable(1) %0) #4
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %26

36:                                               ; preds = %32
  store ptr %28, ptr %1, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %26, %.preheader, %29, %16, %8, %5, %2, %36
  %.0 = phi i32 [ 0, %36 ], [ 2, %2 ], [ 2, %5 ], [ 5, %8 ], [ 5, %16 ], [ 5, %26 ], [ 5003, %.preheader ], [ 5003, %29 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

attributes #0 = { nofree nounwind memory(read, argmem: 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" }
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 #3 = { nounwind willreturn memory(none) }
attributes #4 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !6, i64 8}
!15 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!16 = !{!17, !6, i64 0}
!17 = !{!"TA_FuncInfo", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !6, i64 48}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass