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

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

21:                                               ; preds = %7
  store i32 12, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %75

22:                                               ; preds = %7
  %23 = load i32, ptr %10, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %29, label %25

25:                                               ; preds = %22
  %26 = load i32, ptr %10, align 4, !tbaa !5
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %25, %22
  store i32 13, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %75

30:                                               ; preds = %25
  %31 = load ptr, ptr %11, align 8, !tbaa !9
  %32 = icmp ne ptr %31, null
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  store i32 2, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %75

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

37:                                               ; preds = %34
  store i32 2, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %75

38:                                               ; preds = %34
  %39 = load ptr, ptr %15, align 8, !tbaa !9
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %38
  store i32 2, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %75

42:                                               ; preds = %38
  %43 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %43, ptr %17, align 4, !tbaa !5
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %65, %42
  %45 = load i32, ptr %17, align 4, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !5
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %48, label %70

48:                                               ; preds = %44
  %49 = load ptr, ptr %11, align 8, !tbaa !9
  %50 = load i32, ptr %17, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds float, ptr %49, i64 %51
  %53 = load float, ptr %52, align 4, !tbaa !11
  %54 = load ptr, ptr %12, align 8, !tbaa !9
  %55 = load i32, ptr %17, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds float, ptr %54, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !11
  %59 = fdiv float %53, %58
  %60 = fpext float %59 to double
  %61 = load ptr, ptr %15, align 8, !tbaa !9
  %62 = load i32, ptr %16, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %61, i64 %63
  store double %60, ptr %64, align 8, !tbaa !13
  br label %65

65:                                               ; preds = %48
  %66 = load i32, ptr %17, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %17, align 4, !tbaa !5
  %68 = load i32, ptr %16, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %16, align 4, !tbaa !5
  br label %44, !llvm.loop !15

70:                                               ; preds = %44
  %71 = load i32, ptr %16, align 4, !tbaa !5
  %72 = load ptr, ptr %14, align 8, !tbaa !9
  store i32 %71, ptr %72, align 4, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = load ptr, ptr %13, align 8, !tbaa !9
  store i32 %73, ptr %74, align 4, !tbaa !5
  store i32 0, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %75

75:                                               ; preds = %70, %41, %37, %33, %29, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  %76 = load i32, ptr %8, 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 = !{!"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}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local range(i32 0, 14) i32 @TA_S_DIV(i32 noundef %0, i32 noundef %1, ptr noundef readonly %2, ptr noundef readonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5, ptr noundef writeonly %6) local_unnamed_addr #0 {
  %8 = icmp slt i32 %0, 0
  br i1 %8, label %28, label %9

9:                                                ; preds = %7
  %10 = icmp slt i32 %1, %0
  br i1 %10, label %28, label %11

11:                                               ; preds = %9
  %.not = icmp eq ptr %2, null
  %.not29 = icmp eq ptr %3, null
  %or.cond32 = or i1 %.not, %.not29
  %.not30 = icmp eq ptr %6, null
  %or.cond33 = or i1 %or.cond32, %.not30
  br i1 %or.cond33, label %28, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %11
  %12 = zext nneg i32 %0 to i64
  %13 = add nuw i32 %1, 1
  %14 = sub i32 %13, %0
  %wide.trip.count = zext i32 %14 to i64
  %min.iters.check = icmp ult i32 %14, 2
  br i1 %min.iters.check, label %.lr.ph.preheader44, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %wide.trip.count, 4294967294
  %ind.end = add nuw nsw i64 %n.vec, %12
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %index, %12
  %15 = getelementptr inbounds float, ptr %2, i64 %offset.idx
  %wide.load = load <2 x float>, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds float, ptr %3, i64 %offset.idx
  %wide.load43 = load <2 x float>, ptr %16, align 4, !tbaa !5
  %17 = fdiv <2 x float> %wide.load, %wide.load43
  %18 = fpext <2 x float> %17 to <2 x double>
  %19 = getelementptr inbounds double, ptr %6, i64 %index
  store <2 x double> %18, ptr %19, align 8, !tbaa !9
  %index.next = add nuw i64 %index, 2
  %20 = icmp eq i64 %index.next, %n.vec
  br i1 %20, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader44

.lr.ph.preheader44:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv37.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %indvars.iv.ph = phi i64 [ %12, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader44, %.lr.ph
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %.lr.ph ], [ %indvars.iv37.ph, %.lr.ph.preheader44 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader44 ]
  %21 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = fdiv float %22, %24
  %26 = fpext float %25 to double
  %27 = getelementptr inbounds double, ptr %6, i64 %indvars.iv37
  store double %26, ptr %27, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next38, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %middle.block
  store i32 %14, ptr %5, align 4, !tbaa !16
  store i32 %0, ptr %4, align 4, !tbaa !16
  br label %28

28:                                               ; preds = %11, %9, %7, %._crit_edge
  %.023 = phi i32 [ 0, %._crit_edge ], [ 12, %7 ], [ 13, %9 ], [ 2, %11 ]
  ret i32 %.023
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !14, !13}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}


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