; LLVM IR from siconos/siconos :: externals/lbl/metis4/mkwayfmh.ll_ (MocIsHBalanced)

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

14:                                               ; preds = %62, %4
  %15 = load i32, ptr %10, align 4, !tbaa !5
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %18, label %65

18:                                               ; preds = %14
  store float 0.000000e+00, ptr %12, align 4, !tbaa !11
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %46, %18
  %20 = load i32, ptr %11, align 4, !tbaa !5
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %23, label %49

23:                                               ; preds = %19
  %24 = load ptr, ptr %8, align 8, !tbaa !9
  %25 = load i32, ptr %11, align 4, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = mul nsw i32 %25, %26
  %28 = load i32, ptr %10, align 4, !tbaa !5
  %29 = add nsw i32 %27, %28
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds float, ptr %24, i64 %30
  %32 = load float, ptr %31, align 4, !tbaa !11
  %33 = load float, ptr %12, align 4, !tbaa !11
  %34 = fcmp ogt float %32, %33
  br i1 %34, label %35, label %45

35:                                               ; preds = %23
  %36 = load ptr, ptr %8, align 8, !tbaa !9
  %37 = load i32, ptr %11, align 4, !tbaa !5
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = mul nsw i32 %37, %38
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = add nsw i32 %39, %40
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %36, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !11
  store float %44, ptr %12, align 4, !tbaa !11
  br label %45

45:                                               ; preds = %35, %23
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %11, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %11, align 4, !tbaa !5
  br label %19, !llvm.loop !13

49:                                               ; preds = %19
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = load i32, ptr %10, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %50, i64 %52
  %54 = load float, ptr %53, align 4, !tbaa !11
  %55 = load float, ptr %12, align 4, !tbaa !11
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = sitofp i32 %56 to float
  %58 = fmul float %55, %57
  %59 = fcmp olt float %54, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %49
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %66

61:                                               ; preds = %49
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %10, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %10, align 4, !tbaa !5
  br label %14, !llvm.loop !15

65:                                               ; preds = %14
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %66

66:                                               ; preds = %65, %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %67 = load i32, ptr %5, align 4
  ret i32 %67
}

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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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: read) uwtable
define dso_local range(i32 0, 2) i32 @__MocIsHBalanced(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = icmp sgt i32 %0, 0
  br i1 %5, label %.preheader.lr.ph, label %._crit_edge28

.preheader.lr.ph:                                 ; preds = %4
  %6 = icmp sgt i32 %1, 0
  %7 = sitofp i32 %1 to float
  br i1 %6, label %.preheader.us.preheader, label %.preheader.lr.ph.split

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %8 = zext nneg i32 %0 to i64
  %wide.trip.count39 = zext nneg i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count39, 1
  %9 = icmp eq i32 %1, 1
  %unroll_iter = and i64 %wide.trip.count39, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %16
  %indvars.iv41 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next42, %16 ]
  %invariant.gep = getelementptr inbounds float, ptr %2, i64 %indvars.iv41
  br i1 %9, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %indvars.iv36 = phi i64 [ %indvars.iv.next37.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %.026.us = phi float [ %.1.us.1, %.preheader.us.new ], [ 0.000000e+00, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %10 = mul nuw nsw i64 %indvars.iv36, %8
  %gep = getelementptr inbounds float, ptr %invariant.gep, i64 %10
  %11 = load float, ptr %gep, align 4, !tbaa !5
  %12 = fcmp ogt float %11, %.026.us
  %.1.us = select i1 %12, float %11, float %.026.us
  %indvars.iv.next37 = or disjoint i64 %indvars.iv36, 1
  %13 = mul nuw nsw i64 %indvars.iv.next37, %8
  %gep.1 = getelementptr inbounds float, ptr %invariant.gep, i64 %13
  %14 = load float, ptr %gep.1, align 4, !tbaa !5
  %15 = fcmp ogt float %14, %.1.us
  %.1.us.1 = select i1 %15, float %14, float %.1.us
  %indvars.iv.next37.1 = add nuw nsw i64 %indvars.iv36, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !9

16:                                               ; preds = %._crit_edge.us
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %exitcond45.not = icmp eq i64 %indvars.iv.next42, %8
  br i1 %exitcond45.not, label %._crit_edge28, label %.preheader.us, !llvm.loop !11

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %.1.us.lcssa.ph = phi float [ poison, %.preheader.us ], [ %.1.us.1, %.preheader.us.new ]
  %indvars.iv36.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next37.1, %.preheader.us.new ]
  %.026.us.unr = phi float [ 0.000000e+00, %.preheader.us ], [ %.1.us.1, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %17 = mul nuw nsw i64 %indvars.iv36.unr, %8
  %gep.epil = getelementptr inbounds float, ptr %invariant.gep, i64 %17
  %18 = load float, ptr %gep.epil, align 4, !tbaa !5
  %19 = fcmp ogt float %18, %.026.us.unr
  %.1.us.epil = select i1 %19, float %18, float %.026.us.unr
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %.1.us.lcssa = phi float [ %.1.us.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %.1.us.epil, %._crit_edge.us.epilog-lcssa ]
  %20 = getelementptr inbounds float, ptr %3, i64 %indvars.iv41
  %21 = load float, ptr %20, align 4, !tbaa !5
  %22 = fmul float %.1.us.lcssa, %7
  %23 = fcmp olt float %21, %22
  br i1 %23, label %._crit_edge28, label %16

.preheader.lr.ph.split:                           ; preds = %.preheader.lr.ph
  %24 = tail call float @llvm.copysign.f32(float 0.000000e+00, float %7)
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.preheader

25:                                               ; preds = %.preheader
  %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 %._crit_edge28, label %.preheader, !llvm.loop !11

.preheader:                                       ; preds = %.preheader.lr.ph.split, %25
  %indvars.iv = phi i64 [ 0, %.preheader.lr.ph.split ], [ %indvars.iv.next, %25 ]
  %26 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = fcmp olt float %27, %24
  br i1 %28, label %._crit_edge28, label %25

._crit_edge28:                                    ; preds = %.preheader, %25, %._crit_edge.us, %16, %4
  %.021 = phi i32 [ 1, %4 ], [ 1, %16 ], [ 0, %._crit_edge.us ], [ 1, %25 ], [ 0, %.preheader ]
  ret i32 %.021
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.copysign.f32(float, float) #1

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: read) 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 speculatable willreturn memory(none) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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