; LLVM IR from siconos/siconos :: externals/lbl/metis4/mfm2.ll_ (IsBetter2wayBalance)

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

18:                                               ; preds = %73, %4
  %19 = load i32, ptr %10, align 4, !tbaa !5
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %76

22:                                               ; preds = %18
  %23 = load ptr, ptr %7, align 8, !tbaa !9
  %24 = load i32, ptr %10, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds float, ptr %23, i64 %25
  %27 = load float, ptr %26, align 4, !tbaa !11
  %28 = fsub float %27, 1.000000e+00
  %29 = load ptr, ptr %9, align 8, !tbaa !9
  %30 = load i32, ptr %10, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %29, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !11
  %34 = fsub float %33, 1.000000e+00
  %35 = fdiv float %28, %34
  store float %35, ptr %16, align 4, !tbaa !11
  %36 = load float, ptr %12, align 4, !tbaa !11
  %37 = load float, ptr %16, align 4, !tbaa !11
  %38 = fcmp olt float %36, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %22
  %40 = load float, ptr %16, align 4, !tbaa !11
  br label %43

41:                                               ; preds = %22
  %42 = load float, ptr %12, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %41, %39
  %44 = phi float [ %40, %39 ], [ %42, %41 ]
  store float %44, ptr %12, align 4, !tbaa !11
  %45 = load float, ptr %16, align 4, !tbaa !11
  %46 = load float, ptr %14, align 4, !tbaa !11
  %47 = fadd float %46, %45
  store float %47, ptr %14, align 4, !tbaa !11
  %48 = load ptr, ptr %8, align 8, !tbaa !9
  %49 = load i32, ptr %10, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds float, ptr %48, i64 %50
  %52 = load float, ptr %51, align 4, !tbaa !11
  %53 = fsub float %52, 1.000000e+00
  %54 = load ptr, ptr %9, align 8, !tbaa !9
  %55 = load i32, ptr %10, 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 = fsub float %58, 1.000000e+00
  %60 = fdiv float %53, %59
  store float %60, ptr %16, align 4, !tbaa !11
  %61 = load float, ptr %13, align 4, !tbaa !11
  %62 = load float, ptr %16, align 4, !tbaa !11
  %63 = fcmp olt float %61, %62
  br i1 %63, label %64, label %66

64:                                               ; preds = %43
  %65 = load float, ptr %16, align 4, !tbaa !11
  br label %68

66:                                               ; preds = %43
  %67 = load float, ptr %13, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %66, %64
  %69 = phi float [ %65, %64 ], [ %67, %66 ]
  store float %69, ptr %13, align 4, !tbaa !11
  %70 = load float, ptr %16, align 4, !tbaa !11
  %71 = load float, ptr %15, align 4, !tbaa !11
  %72 = fadd float %71, %70
  store float %72, ptr %15, align 4, !tbaa !11
  br label %73

73:                                               ; preds = %68
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %10, align 4, !tbaa !5
  br label %18, !llvm.loop !13

76:                                               ; preds = %18
  %77 = load float, ptr %12, align 4, !tbaa !11
  %78 = load float, ptr %13, align 4, !tbaa !11
  %79 = fcmp olt float %77, %78
  br i1 %79, label %80, label %81

80:                                               ; preds = %76
  store i32 1, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %91

81:                                               ; preds = %76
  %82 = load float, ptr %12, align 4, !tbaa !11
  %83 = load float, ptr %13, align 4, !tbaa !11
  %84 = fcmp ogt float %82, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %81
  store i32 0, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %91

86:                                               ; preds = %81
  %87 = load float, ptr %14, align 4, !tbaa !11
  %88 = load float, ptr %15, align 4, !tbaa !11
  %89 = fcmp ole float %87, %88
  %90 = zext i1 %89 to i32
  store i32 %90, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %91

91:                                               ; preds = %86, %85, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  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
  %92 = load i32, ptr %5, align 4
  ret i32 %92
}

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

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


; 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 @__IsBetter2wayBalance(i32 noundef %0, ptr nocapture noundef readonly %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 %.lr.ph.preheader, label %.thread

.lr.ph.preheader:                                 ; preds = %4
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %6 = phi <2 x float> [ zeroinitializer, %.lr.ph.preheader ], [ %23, %.lr.ph ]
  %7 = phi <2 x float> [ zeroinitializer, %.lr.ph.preheader ], [ %22, %.lr.ph ]
  %8 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %9 = load float, ptr %8, align 4, !tbaa !5
  %10 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = fadd float %11, -1.000000e+00
  %13 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = insertelement <2 x float> poison, float %9, i64 0
  %16 = insertelement <2 x float> %15, float %14, i64 1
  %17 = fadd <2 x float> %16, <float -1.000000e+00, float -1.000000e+00>
  %18 = insertelement <2 x float> poison, float %12, i64 0
  %19 = shufflevector <2 x float> %18, <2 x float> poison, <2 x i32> zeroinitializer
  %20 = fdiv <2 x float> %17, %19
  %21 = fcmp olt <2 x float> %7, %20
  %22 = select <2 x i1> %21, <2 x float> %20, <2 x float> %7
  %23 = fadd <2 x float> %6, %20
  %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_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph
  %24 = extractelement <2 x float> %22, i64 0
  %25 = extractelement <2 x float> %22, i64 1
  %26 = fcmp olt float %24, %25
  br i1 %26, label %34, label %27

27:                                               ; preds = %._crit_edge
  %28 = fcmp ogt float %24, %25
  br i1 %28, label %34, label %.thread

.thread:                                          ; preds = %4, %27
  %29 = phi <2 x float> [ %23, %27 ], [ zeroinitializer, %4 ]
  %30 = extractelement <2 x float> %29, i64 0
  %31 = extractelement <2 x float> %29, i64 1
  %32 = fcmp ole float %30, %31
  %33 = zext i1 %32 to i32
  br label %34

34:                                               ; preds = %27, %._crit_edge, %.thread
  %.0 = phi i32 [ %33, %.thread ], [ 1, %._crit_edge ], [ 0, %27 ]
  ret i32 %.0
}

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

!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"}


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