; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libSimuTilts/library.ll (Z8binarizePfS_fii)

; 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: mustprogress nounwind uwtable
define dso_local void @_Z8binarizePfS_fii(ptr noundef %0, ptr noundef %1, float noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %56, %5
  %13 = load i32, ptr %11, align 4, !tbaa !11
  %14 = load i32, ptr %10, align 4, !tbaa !11
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %59

17:                                               ; preds = %12
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i32, ptr %11, align 4, !tbaa !11
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds float, ptr %18, i64 %20
  %22 = load float, ptr %21, align 4, !tbaa !9
  %23 = load float, ptr %8, align 4, !tbaa !9
  %24 = fcmp oge float %22, %23
  br i1 %24, label %25, label %33

25:                                               ; preds = %17
  %26 = load i32, ptr %9, align 4, !tbaa !11
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %33, label %28

28:                                               ; preds = %25
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load i32, ptr %11, align 4, !tbaa !11
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %29, i64 %31
  store float 2.550000e+02, ptr %32, align 4, !tbaa !9
  br label %55

33:                                               ; preds = %25, %17
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i32, ptr %11, align 4, !tbaa !11
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %34, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !9
  %39 = load float, ptr %8, align 4, !tbaa !9
  %40 = fcmp ole float %38, %39
  br i1 %40, label %41, label %49

41:                                               ; preds = %33
  %42 = load i32, ptr %9, align 4, !tbaa !11
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %49

44:                                               ; preds = %41
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = load i32, ptr %11, align 4, !tbaa !11
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds float, ptr %45, i64 %47
  store float 2.550000e+02, ptr %48, align 4, !tbaa !9
  br label %54

49:                                               ; preds = %41, %33
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load i32, ptr %11, align 4, !tbaa !11
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %50, i64 %52
  store float 0.000000e+00, ptr %53, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %49, %44
  br label %55

55:                                               ; preds = %54, %28
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %11, align 4, !tbaa !11
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %11, align 4, !tbaa !11
  br label %12, !llvm.loop !13

59:                                               ; preds = %16
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_Z8binarizePfS_fii(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, float noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = ptrtoint ptr %0 to i64
  %7 = ptrtoint ptr %1 to i64
  %8 = ptrtoint ptr %0 to i64
  %9 = ptrtoint ptr %1 to i64
  %10 = icmp sgt i32 %4, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %.not = icmp eq i32 %3, 0
  %wide.trip.count25 = zext nneg i32 %4 to i64
  %min.iters.check35 = icmp ult i32 %4, 8
  br i1 %.not, label %.lr.ph.split.preheader, label %.lr.ph.split.us.preheader

.lr.ph.split.us.preheader:                        ; preds = %.lr.ph
  %11 = sub i64 %9, %8
  %diff.check = icmp ult i64 %11, 32
  %or.cond = or i1 %min.iters.check35, %diff.check
  br i1 %or.cond, label %.lr.ph.split.us.preheader50, label %vector.ph

.lr.ph.split.us.preheader50:                      ; preds = %middle.block, %.lr.ph.split.us.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.split.us.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count25, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.split.us.prol.loopexit, label %.lr.ph.split.us.prol

.lr.ph.split.us.prol:                             ; preds = %.lr.ph.split.us.preheader50
  %12 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.ph
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = fcmp ugt float %13, %2
  %.sink.prol = select i1 %14, float 0.000000e+00, float 2.550000e+02
  %15 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.ph
  store float %.sink.prol, ptr %15, align 4
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %.lr.ph.split.us.prol.loopexit

.lr.ph.split.us.prol.loopexit:                    ; preds = %.lr.ph.split.us.prol, %.lr.ph.split.us.preheader50
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.split.us.preheader50 ], [ %indvars.iv.next.prol, %.lr.ph.split.us.prol ]
  %16 = add nsw i64 %wide.trip.count25, -1
  %17 = icmp eq i64 %indvars.iv.ph, %16
  br i1 %17, label %._crit_edge, label %.lr.ph.split.us

vector.ph:                                        ; preds = %.lr.ph.split.us.preheader
  %n.vec = and i64 %wide.trip.count25, 2147483640
  %broadcast.splatinsert = insertelement <4 x float> poison, float %2, i64 0
  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %18 = getelementptr inbounds float, ptr %0, i64 %index
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %wide.load = load <4 x float>, ptr %18, align 4, !tbaa !5
  %wide.load30 = load <4 x float>, ptr %19, align 4, !tbaa !5
  %20 = fcmp ugt <4 x float> %wide.load, %broadcast.splat
  %21 = fcmp ugt <4 x float> %wide.load30, %broadcast.splat
  %22 = select <4 x i1> %20, <4 x float> zeroinitializer, <4 x float> <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
  %23 = select <4 x i1> %21, <4 x float> zeroinitializer, <4 x float> <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
  %24 = getelementptr inbounds float, ptr %1, i64 %index
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  store <4 x float> %22, ptr %24, align 4
  store <4 x float> %23, ptr %25, align 4
  %index.next = add nuw i64 %index, 8
  %26 = icmp eq i64 %index.next, %n.vec
  br i1 %26, label %middle.block, label %vector.body, !llvm.loop !9

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

.lr.ph.split.preheader:                           ; preds = %.lr.ph
  %27 = sub i64 %7, %6
  %diff.check32 = icmp ult i64 %27, 32
  %or.cond48 = or i1 %min.iters.check35, %diff.check32
  br i1 %or.cond48, label %.lr.ph.split.preheader49, label %vector.ph36

.lr.ph.split.preheader49:                         ; preds = %middle.block33, %.lr.ph.split.preheader
  %indvars.iv22.ph = phi i64 [ 0, %.lr.ph.split.preheader ], [ %n.vec38, %middle.block33 ]
  %xtraiter52 = and i64 %wide.trip.count25, 1
  %lcmp.mod53.not = icmp eq i64 %xtraiter52, 0
  br i1 %lcmp.mod53.not, label %.lr.ph.split.prol.loopexit, label %.lr.ph.split.prol

.lr.ph.split.prol:                                ; preds = %.lr.ph.split.preheader49
  %28 = getelementptr inbounds float, ptr %0, i64 %indvars.iv22.ph
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = fcmp ult float %29, %2
  %.sink27.prol = select i1 %30, float 0.000000e+00, float 2.550000e+02
  %31 = getelementptr inbounds float, ptr %1, i64 %indvars.iv22.ph
  store float %.sink27.prol, ptr %31, align 4
  %indvars.iv.next23.prol = or disjoint i64 %indvars.iv22.ph, 1
  br label %.lr.ph.split.prol.loopexit

.lr.ph.split.prol.loopexit:                       ; preds = %.lr.ph.split.prol, %.lr.ph.split.preheader49
  %indvars.iv22.unr = phi i64 [ %indvars.iv22.ph, %.lr.ph.split.preheader49 ], [ %indvars.iv.next23.prol, %.lr.ph.split.prol ]
  %32 = add nsw i64 %wide.trip.count25, -1
  %33 = icmp eq i64 %indvars.iv22.ph, %32
  br i1 %33, label %._crit_edge, label %.lr.ph.split

vector.ph36:                                      ; preds = %.lr.ph.split.preheader
  %n.vec38 = and i64 %wide.trip.count25, 2147483640
  %broadcast.splatinsert44 = insertelement <4 x float> poison, float %2, i64 0
  %broadcast.splat45 = shufflevector <4 x float> %broadcast.splatinsert44, <4 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body40

vector.body40:                                    ; preds = %vector.body40, %vector.ph36
  %index41 = phi i64 [ 0, %vector.ph36 ], [ %index.next46, %vector.body40 ]
  %34 = getelementptr inbounds float, ptr %0, i64 %index41
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %wide.load42 = load <4 x float>, ptr %34, align 4, !tbaa !5
  %wide.load43 = load <4 x float>, ptr %35, align 4, !tbaa !5
  %36 = fcmp ult <4 x float> %wide.load42, %broadcast.splat45
  %37 = fcmp ult <4 x float> %wide.load43, %broadcast.splat45
  %38 = select <4 x i1> %36, <4 x float> zeroinitializer, <4 x float> <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
  %39 = select <4 x i1> %37, <4 x float> zeroinitializer, <4 x float> <float 2.550000e+02, float 2.550000e+02, float 2.550000e+02, float 2.550000e+02>
  %40 = getelementptr inbounds float, ptr %1, i64 %index41
  %41 = getelementptr inbounds i8, ptr %40, i64 16
  store <4 x float> %38, ptr %40, align 4
  store <4 x float> %39, ptr %41, align 4
  %index.next46 = add nuw i64 %index41, 8
  %42 = icmp eq i64 %index.next46, %n.vec38
  br i1 %42, label %middle.block33, label %vector.body40, !llvm.loop !13

middle.block33:                                   ; preds = %vector.body40
  %cmp.n47 = icmp eq i64 %n.vec38, %wide.trip.count25
  br i1 %cmp.n47, label %._crit_edge, label %.lr.ph.split.preheader49

.lr.ph.split.us:                                  ; preds = %.lr.ph.split.us.prol.loopexit, %.lr.ph.split.us
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph.split.us ], [ %indvars.iv.unr, %.lr.ph.split.us.prol.loopexit ]
  %43 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %44 = load float, ptr %43, align 4, !tbaa !5
  %45 = fcmp ugt float %44, %2
  %.sink = select i1 %45, float 0.000000e+00, float 2.550000e+02
  %46 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  store float %.sink, ptr %46, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %47 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next
  %48 = load float, ptr %47, align 4, !tbaa !5
  %49 = fcmp ugt float %48, %2
  %.sink.1 = select i1 %49, float 0.000000e+00, float 2.550000e+02
  %50 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next
  store float %.sink.1, ptr %50, align 4
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count25
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph.split.us.prol.loopexit, %.lr.ph.split.us, %.lr.ph.split.prol.loopexit, %.lr.ph.split, %middle.block, %middle.block33, %5
  ret void

.lr.ph.split:                                     ; preds = %.lr.ph.split.prol.loopexit, %.lr.ph.split
  %indvars.iv22 = phi i64 [ %indvars.iv.next23.1, %.lr.ph.split ], [ %indvars.iv22.unr, %.lr.ph.split.prol.loopexit ]
  %51 = getelementptr inbounds float, ptr %0, i64 %indvars.iv22
  %52 = load float, ptr %51, align 4, !tbaa !5
  %53 = fcmp ult float %52, %2
  %.sink27 = select i1 %53, float 0.000000e+00, float 2.550000e+02
  %54 = getelementptr inbounds float, ptr %1, i64 %indvars.iv22
  store float %.sink27, ptr %54, align 4
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %55 = getelementptr inbounds float, ptr %0, i64 %indvars.iv.next23
  %56 = load float, ptr %55, align 4, !tbaa !5
  %57 = fcmp ult float %56, %2
  %.sink27.1 = select i1 %57, float 0.000000e+00, float 2.550000e+02
  %58 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next23
  store float %.sink27.1, ptr %58, align 4
  %indvars.iv.next23.1 = add nuw nsw i64 %indvars.iv22, 2
  %exitcond26.not.1 = icmp eq i64 %indvars.iv.next23.1, %wide.trip.count25
  br i1 %exitcond26.not.1, label %._crit_edge, label %.lr.ph.split, !llvm.loop !15
}

attributes #0 = { mustprogress 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++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11, !12}
!14 = distinct !{!14, !10, !11}
!15 = distinct !{!15, !10, !11}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass