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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @TA_APO(i32 noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) #0 {
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  store i32 %0, ptr %11, align 4, !tbaa !5
  store i32 %1, ptr %12, align 4, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !9
  store i32 %3, ptr %14, align 4, !tbaa !5
  store i32 %4, ptr %15, align 4, !tbaa !5
  store i32 %5, ptr %16, align 4, !tbaa !5
  store ptr %6, ptr %17, align 8, !tbaa !9
  store ptr %7, ptr %18, align 8, !tbaa !9
  store ptr %8, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %23 = load i32, ptr %11, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %9
  store i32 12, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

26:                                               ; preds = %9
  %27 = load i32, ptr %12, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %33, label %29

29:                                               ; preds = %26
  %30 = load i32, ptr %12, align 4, !tbaa !5
  %31 = load i32, ptr %11, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %29, %26
  store i32 13, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

34:                                               ; preds = %29
  %35 = load ptr, ptr %13, align 8, !tbaa !9
  %36 = icmp ne ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  store i32 2, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

38:                                               ; preds = %34
  %39 = load i32, ptr %14, align 4, !tbaa !5
  %40 = icmp eq i32 %39, -2147483648
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store i32 12, ptr %14, align 4, !tbaa !5
  br label %50

42:                                               ; preds = %38
  %43 = load i32, ptr %14, align 4, !tbaa !5
  %44 = icmp slt i32 %43, 2
  br i1 %44, label %48, label %45

45:                                               ; preds = %42
  %46 = load i32, ptr %14, align 4, !tbaa !5
  %47 = icmp sgt i32 %46, 100000
  br i1 %47, label %48, label %49

48:                                               ; preds = %45, %42
  store i32 2, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

49:                                               ; preds = %45
  br label %50

50:                                               ; preds = %49, %41
  %51 = load i32, ptr %15, align 4, !tbaa !5
  %52 = icmp eq i32 %51, -2147483648
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  store i32 26, ptr %15, align 4, !tbaa !5
  br label %62

54:                                               ; preds = %50
  %55 = load i32, ptr %15, align 4, !tbaa !5
  %56 = icmp slt i32 %55, 2
  br i1 %56, label %60, label %57

57:                                               ; preds = %54
  %58 = load i32, ptr %15, align 4, !tbaa !5
  %59 = icmp sgt i32 %58, 100000
  br i1 %59, label %60, label %61

60:                                               ; preds = %57, %54
  store i32 2, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

61:                                               ; preds = %57
  br label %62

62:                                               ; preds = %61, %53
  %63 = load i32, ptr %16, align 4, !tbaa !5
  %64 = icmp eq i32 %63, -2147483648
  br i1 %64, label %65, label %66

65:                                               ; preds = %62
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %74

66:                                               ; preds = %62
  %67 = load i32, ptr %16, align 4, !tbaa !5
  %68 = icmp slt i32 %67, 0
  br i1 %68, label %72, label %69

69:                                               ; preds = %66
  %70 = load i32, ptr %16, align 4, !tbaa !5
  %71 = icmp sgt i32 %70, 8
  br i1 %71, label %72, label %73

72:                                               ; preds = %69, %66
  store i32 2, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

73:                                               ; preds = %69
  br label %74

74:                                               ; preds = %73, %65
  %75 = load ptr, ptr %19, align 8, !tbaa !9
  %76 = icmp ne ptr %75, null
  br i1 %76, label %78, label %77

77:                                               ; preds = %74
  store i32 2, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

78:                                               ; preds = %74
  %79 = load i32, ptr %12, align 4, !tbaa !5
  %80 = load i32, ptr %11, align 4, !tbaa !5
  %81 = sub nsw i32 %79, %80
  %82 = add nsw i32 %81, 1
  %83 = sext i32 %82 to i64
  %84 = mul i64 8, %83
  %85 = call noalias ptr @malloc(i64 noundef %84) #5
  store ptr %85, ptr %20, align 8, !tbaa !9
  %86 = load ptr, ptr %20, align 8, !tbaa !9
  %87 = icmp ne ptr %86, null
  br i1 %87, label %89, label %88

88:                                               ; preds = %78
  store i32 3, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

89:                                               ; preds = %78
  %90 = load i32, ptr %11, align 4, !tbaa !5
  %91 = load i32, ptr %12, align 4, !tbaa !5
  %92 = load ptr, ptr %13, align 8, !tbaa !9
  %93 = load i32, ptr %14, align 4, !tbaa !5
  %94 = load i32, ptr %15, align 4, !tbaa !5
  %95 = load i32, ptr %16, align 4, !tbaa !5
  %96 = load ptr, ptr %17, align 8, !tbaa !9
  %97 = load ptr, ptr %18, align 8, !tbaa !9
  %98 = load ptr, ptr %19, align 8, !tbaa !9
  %99 = load ptr, ptr %20, align 8, !tbaa !9
  %100 = call i32 @TA_INT_PO(i32 noundef %90, i32 noundef %91, ptr noundef %92, i32 noundef %93, i32 noundef %94, i32 noundef %95, ptr noundef %96, ptr noundef %97, ptr noundef %98, ptr noundef %99, i32 noundef 0)
  store i32 %100, ptr %21, align 4, !tbaa !5
  %101 = load ptr, ptr %20, align 8, !tbaa !9
  call void @free(ptr noundef %101) #4
  %102 = load i32, ptr %21, align 4, !tbaa !5
  store i32 %102, ptr %10, align 4
  store i32 1, ptr %22, align 4
  br label %103

103:                                              ; preds = %89, %88, %77, %72, %60, %48, %37, %33, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  %104 = load i32, ptr %10, align 4
  ret i32 %104
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @TA_INT_PO(i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

; Function Attrs: nounwind uwtable
define dso_local i32 @TA_APO(i32 noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) local_unnamed_addr #0 {
  %10 = icmp slt i32 %0, 0
  br i1 %10, label %33, label %11

11:                                               ; preds = %9
  %12 = icmp slt i32 %1, %0
  br i1 %12, label %33, label %13

13:                                               ; preds = %11
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %33, label %14

14:                                               ; preds = %13
  %15 = icmp eq i32 %3, -2147483648
  br i1 %15, label %18, label %16

16:                                               ; preds = %14
  %17 = add i32 %3, -100001
  %or.cond = icmp ult i32 %17, -99999
  br i1 %or.cond, label %33, label %18

18:                                               ; preds = %14, %16
  %.035 = phi i32 [ %3, %16 ], [ 12, %14 ]
  %19 = icmp eq i32 %4, -2147483648
  br i1 %19, label %22, label %20

20:                                               ; preds = %18
  %21 = add i32 %4, -100001
  %or.cond3 = icmp ult i32 %21, -99999
  br i1 %or.cond3, label %33, label %22

22:                                               ; preds = %18, %20
  %.036 = phi i32 [ %4, %20 ], [ 26, %18 ]
  %23 = icmp eq i32 %5, -2147483648
  br i1 %23, label %25, label %24

24:                                               ; preds = %22
  %or.cond5 = icmp ugt i32 %5, 8
  br i1 %or.cond5, label %33, label %25

25:                                               ; preds = %22, %24
  %.037 = phi i32 [ %5, %24 ], [ 0, %22 ]
  %.not46 = icmp eq ptr %8, null
  br i1 %.not46, label %33, label %26

26:                                               ; preds = %25
  %reass.sub = sub nsw i32 %1, %0
  %27 = add i32 %reass.sub, 1
  %28 = sext i32 %27 to i64
  %29 = shl nsw i64 %28, 3
  %30 = tail call noalias ptr @malloc(i64 noundef %29) #3
  %.not47 = icmp eq ptr %30, null
  br i1 %.not47, label %33, label %31

31:                                               ; preds = %26
  %32 = tail call i32 @TA_INT_PO(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %2, i32 noundef %.035, i32 noundef %.036, i32 noundef %.037, ptr noundef %6, ptr noundef %7, ptr noundef nonnull %8, ptr noundef nonnull %30, i32 noundef 0)
  tail call void @free(ptr noundef nonnull %30) #4
  br label %33

33:                                               ; preds = %26, %25, %24, %20, %16, %13, %11, %9, %31
  %.0 = phi i32 [ %32, %31 ], [ 12, %9 ], [ 13, %11 ], [ 2, %13 ], [ 2, %16 ], [ 2, %20 ], [ 2, %24 ], [ 2, %25 ], [ 3, %26 ]
  ret i32 %.0
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @TA_INT_PO(i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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" }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }
attributes #4 = { 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)"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass