; LLVM IR from y-mitsui/DpBayesianNet :: dpBayesianNet (combination)

; 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 @combination(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store double 1.000000e+00, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store double 1.000000e+00, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %19, %2
  %9 = load i32, ptr %7, align 4, !tbaa !5
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %12, label %22

12:                                               ; preds = %8
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = sub nsw i32 %13, %14
  %16 = sitofp i32 %15 to double
  %17 = load double, ptr %5, align 8, !tbaa !9
  %18 = fmul double %17, %16
  store double %18, ptr %5, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %12
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %7, align 4, !tbaa !5
  br label %8, !llvm.loop !11

22:                                               ; preds = %8
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %34, %22
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %27, label %37

27:                                               ; preds = %23
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = sub nsw i32 %28, %29
  %31 = sitofp i32 %30 to double
  %32 = load double, ptr %6, align 8, !tbaa !9
  %33 = fmul double %32, %31
  store double %33, ptr %6, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %27
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %7, align 4, !tbaa !5
  br label %23, !llvm.loop !13

37:                                               ; preds = %23
  %38 = load double, ptr %5, align 8, !tbaa !9
  %39 = load double, ptr %6, align 8, !tbaa !9
  %40 = fdiv double %38, %39
  %41 = fptosi double %40 to i32
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret i32 %41
}

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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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(none) uwtable
define dso_local i32 @combination(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %1, 0
  br i1 %3, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %xtraiter = and i32 %1, 3
  %4 = icmp ult i32 %1, 4
  br i1 %4, label %.preheader.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %1, 2147483644
  br label %.lr.ph

.preheader.unr-lcssa:                             ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa28.ph = phi double [ poison, %.lr.ph.preheader ], [ %23, %.lr.ph ]
  %.017.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %24, %.lr.ph ]
  %.01416.unr = phi double [ 1.000000e+00, %.lr.ph.preheader ], [ %23, %.lr.ph ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader.unr-lcssa, %.lr.ph.epil
  %.017.epil = phi i32 [ %8, %.lr.ph.epil ], [ %.017.unr, %.preheader.unr-lcssa ]
  %.01416.epil = phi double [ %7, %.lr.ph.epil ], [ %.01416.unr, %.preheader.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader.unr-lcssa ]
  %5 = sub nsw i32 %0, %.017.epil
  %6 = sitofp i32 %5 to double
  %7 = fmul double %.01416.epil, %6
  %8 = add nuw nsw i32 %.017.epil, 1
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader, label %.lr.ph.epil, !llvm.loop !5

.preheader:                                       ; preds = %.lr.ph.epil, %.preheader.unr-lcssa
  %.lcssa28 = phi double [ %.lcssa28.ph, %.preheader.unr-lcssa ], [ %7, %.lr.ph.epil ]
  br i1 %3, label %.lr.ph20.preheader, label %._crit_edge

.lr.ph20.preheader:                               ; preds = %.preheader
  %xtraiter30 = and i32 %1, 3
  %9 = icmp ult i32 %1, 4
  br i1 %9, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph20.preheader.new

.lr.ph20.preheader.new:                           ; preds = %.lr.ph20.preheader
  %unroll_iter34 = and i32 %1, 2147483644
  br label %.lr.ph20

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.017 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %24, %.lr.ph ]
  %.01416 = phi double [ 1.000000e+00, %.lr.ph.preheader.new ], [ %23, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %10 = sub nsw i32 %0, %.017
  %11 = sitofp i32 %10 to double
  %12 = fmul double %.01416, %11
  %.neg = xor i32 %.017, -1
  %13 = add i32 %.neg, %0
  %14 = sitofp i32 %13 to double
  %15 = fmul double %12, %14
  %16 = or disjoint i32 %.017, 2
  %17 = sub nsw i32 %0, %16
  %18 = sitofp i32 %17 to double
  %19 = fmul double %15, %18
  %20 = or disjoint i32 %.017, 3
  %21 = sub nsw i32 %0, %20
  %22 = sitofp i32 %21 to double
  %23 = fmul double %19, %22
  %24 = add nuw nsw i32 %.017, 4
  %niter.next.3 = add i32 %niter, 4
  %niter.ncmp.3 = icmp eq i32 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader.unr-lcssa, label %.lr.ph, !llvm.loop !7

.lr.ph20:                                         ; preds = %.lr.ph20, %.lr.ph20.preheader.new
  %.119 = phi i32 [ 0, %.lr.ph20.preheader.new ], [ %39, %.lr.ph20 ]
  %.01318 = phi double [ 1.000000e+00, %.lr.ph20.preheader.new ], [ %38, %.lr.ph20 ]
  %niter35 = phi i32 [ 0, %.lr.ph20.preheader.new ], [ %niter35.next.3, %.lr.ph20 ]
  %25 = sub nsw i32 %1, %.119
  %26 = sitofp i32 %25 to double
  %27 = fmul double %.01318, %26
  %.neg36 = xor i32 %.119, -1
  %28 = add nsw i32 %.neg36, %1
  %29 = sitofp i32 %28 to double
  %30 = fmul double %27, %29
  %31 = or disjoint i32 %.119, 2
  %32 = sub nsw i32 %1, %31
  %33 = sitofp i32 %32 to double
  %34 = fmul double %30, %33
  %35 = or disjoint i32 %.119, 3
  %36 = sub nsw i32 %1, %35
  %37 = sitofp i32 %36 to double
  %38 = fmul double %34, %37
  %39 = add nuw nsw i32 %.119, 4
  %niter35.next.3 = add i32 %niter35, 4
  %niter35.ncmp.3 = icmp eq i32 %niter35.next.3, %unroll_iter34
  br i1 %niter35.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph20, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph20, %.lr.ph20.preheader
  %.lcssa.ph = phi double [ poison, %.lr.ph20.preheader ], [ %38, %.lr.ph20 ]
  %.119.unr = phi i32 [ 0, %.lr.ph20.preheader ], [ %39, %.lr.ph20 ]
  %.01318.unr = phi double [ 1.000000e+00, %.lr.ph20.preheader ], [ %38, %.lr.ph20 ]
  %lcmp.mod32.not = icmp eq i32 %xtraiter30, 0
  br i1 %lcmp.mod32.not, label %._crit_edge, label %.lr.ph20.epil

.lr.ph20.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph20.epil
  %.119.epil = phi i32 [ %43, %.lr.ph20.epil ], [ %.119.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01318.epil = phi double [ %42, %.lr.ph20.epil ], [ %.01318.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter31 = phi i32 [ %epil.iter31.next, %.lr.ph20.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %40 = sub nsw i32 %1, %.119.epil
  %41 = sitofp i32 %40 to double
  %42 = fmul double %.01318.epil, %41
  %43 = add nuw nsw i32 %.119.epil, 1
  %epil.iter31.next = add i32 %epil.iter31, 1
  %epil.iter31.cmp.not = icmp eq i32 %epil.iter31.next, %xtraiter30
  br i1 %epil.iter31.cmp.not, label %._crit_edge, label %.lr.ph20.epil, !llvm.loop !10

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph20.epil, %2, %.preheader
  %.014.lcssa25 = phi double [ %.lcssa28, %.preheader ], [ 1.000000e+00, %2 ], [ %.lcssa28, %.lr.ph20.epil ], [ %.lcssa28, %._crit_edge.loopexit.unr-lcssa ]
  %.013.lcssa = phi double [ 1.000000e+00, %.preheader ], [ 1.000000e+00, %2 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %42, %.lr.ph20.epil ]
  %44 = fdiv double %.014.lcssa25, %.013.lcssa
  %45 = fptosi double %44 to i32
  ret i32 %45
}

attributes #0 = { nofree norecurse nosync nounwind memory(none) 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.unroll.disable"}
!7 = distinct !{!7, !8}
!8 = !{!"llvm.loop.mustprogress"}
!9 = distinct !{!9, !8}
!10 = distinct !{!10, !6}


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