; LLVM IR from div-bargali/Data-Structures-and-Algorithms :: C++/Algorithms/Mathematical/Hosoya.ll (Z6Hosoyaii)

; 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: mustprogress uwtable
define dso_local noundef i32 @_Z6Hosoyaii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %6 = load i32, ptr %4, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %11

8:                                                ; preds = %2
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %29, label %11

11:                                               ; preds = %8, %2
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %17

14:                                               ; preds = %11
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %29, label %17

17:                                               ; preds = %14, %11
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %29, label %23

23:                                               ; preds = %20, %17
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = icmp eq i32 %24, 2
  br i1 %25, label %26, label %30

26:                                               ; preds = %23
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %30

29:                                               ; preds = %26, %20, %14, %8
  store i32 1, ptr %3, align 4
  br label %61

30:                                               ; preds = %26, %23
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp sgt i32 %31, %32
  br i1 %33, label %34, label %44

34:                                               ; preds = %30
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sub nsw i32 %35, 1
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = call noundef i32 @_Z6Hosoyaii(i32 noundef %36, i32 noundef %37)
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sub nsw i32 %39, 2
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = call noundef i32 @_Z6Hosoyaii(i32 noundef %40, i32 noundef %41)
  %43 = add nsw i32 %38, %42
  store i32 %43, ptr %3, align 4
  br label %61

44:                                               ; preds = %30
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = icmp eq i32 %45, %46
  br i1 %47, label %48, label %60

48:                                               ; preds = %44
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = sub nsw i32 %51, 1
  %53 = call noundef i32 @_Z6Hosoyaii(i32 noundef %50, i32 noundef %52)
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sub nsw i32 %54, 2
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sub nsw i32 %56, 2
  %58 = call noundef i32 @_Z6Hosoyaii(i32 noundef %55, i32 noundef %57)
  %59 = add nsw i32 %53, %58
  store i32 %59, ptr %3, align 4
  br label %61

60:                                               ; preds = %44
  store i32 0, ptr %3, align 4
  br label %61

61:                                               ; preds = %60, %48, %34, %29
  %62 = load i32, ptr %3, align 4
  ret i32 %62
}

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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 nosync nounwind willreturn memory(none) uwtable
define dso_local noundef i32 @_Z6Hosoyaii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %27, %2
  %accumulator.tr = phi i32 [ 0, %2 ], [ %accumulator.ret.tr, %27 ]
  %.tr = phi i32 [ %0, %2 ], [ %30, %27 ]
  %.tr118 = phi i32 [ %1, %2 ], [ %30, %27 ]
  %3 = or i32 %.tr, %.tr118
  %or.cond38 = icmp eq i32 %3, 0
  br i1 %or.cond38, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %tailrecurse
  %4 = icmp eq i32 %.tr118, 0
  %5 = icmp eq i32 %.tr118, 1
  br i1 %4, label %.lr.ph.split.split.us, label %.lr.ph.split.us.split

.lr.ph.split.us.split:                            ; preds = %.lr.ph
  %6 = add i32 %.tr, -1
  %or.cond532.us64 = icmp ult i32 %6, 2
  %or.cond31.us65 = and i1 %5, %or.cond532.us64
  br i1 %or.cond31.us65, label %.loopexit, label %.lr.ph68

.lr.ph68:                                         ; preds = %.lr.ph.split.us.split
  br i1 %5, label %.lr.ph68.split, label %.lr.ph68.split.us

.lr.ph68.split.us:                                ; preds = %.lr.ph68
  %7 = icmp sgt i32 %.tr, %.tr118
  br i1 %7, label %tailrecurse.us.us, label %.split.us

tailrecurse.us.us:                                ; preds = %.lr.ph68.split.us, %tailrecurse.us.us
  %.tr40.us66.us73 = phi i32 [ %10, %tailrecurse.us.us ], [ %.tr, %.lr.ph68.split.us ]
  %accumulator.tr39.us67.us72 = phi i32 [ %11, %tailrecurse.us.us ], [ 0, %.lr.ph68.split.us ]
  %8 = add nsw i32 %.tr40.us66.us73, -1
  %9 = tail call noundef i32 @_Z6Hosoyaii(i32 noundef %8, i32 noundef %.tr118)
  %10 = add nsw i32 %.tr40.us66.us73, -2
  %11 = add nsw i32 %9, %accumulator.tr39.us67.us72
  %12 = icmp sgt i32 %10, %.tr118
  br i1 %12, label %tailrecurse.us.us, label %.split.us

.lr.ph68.split:                                   ; preds = %.lr.ph68, %tailrecurse.us
  %accumulator.tr39.us67 = phi i32 [ %17, %tailrecurse.us ], [ 0, %.lr.ph68 ]
  %.tr40.us66 = phi i32 [ %16, %tailrecurse.us ], [ %.tr, %.lr.ph68 ]
  %13 = icmp sgt i32 %.tr40.us66, 1
  br i1 %13, label %tailrecurse.us, label %.split.us

tailrecurse.us:                                   ; preds = %.lr.ph68.split
  %14 = add nsw i32 %.tr40.us66, -1
  %15 = tail call noundef i32 @_Z6Hosoyaii(i32 noundef %14, i32 noundef 1)
  %16 = add nsw i32 %.tr40.us66, -2
  %17 = add nsw i32 %15, %accumulator.tr39.us67
  %18 = add nsw i32 %.tr40.us66, -3
  %or.cond532.us = icmp ult i32 %18, 2
  br i1 %or.cond532.us, label %.loopexit, label %.lr.ph68.split

.lr.ph.split.split.us:                            ; preds = %.lr.ph, %tailrecurse.us51
  %.tr40.us47 = phi i32 [ %24, %tailrecurse.us51 ], [ %.tr, %.lr.ph ]
  %accumulator.tr39.us48 = phi i32 [ %25, %tailrecurse.us51 ], [ 0, %.lr.ph ]
  %19 = icmp eq i32 %.tr40.us47, 1
  br i1 %19, label %.loopexit, label %20

20:                                               ; preds = %.lr.ph.split.split.us
  %21 = icmp sgt i32 %.tr40.us47, 0
  br i1 %21, label %tailrecurse.us51, label %.split.us

tailrecurse.us51:                                 ; preds = %20
  %22 = add nsw i32 %.tr40.us47, -1
  %23 = tail call noundef i32 @_Z6Hosoyaii(i32 noundef %22, i32 noundef 0)
  %24 = add nsw i32 %.tr40.us47, -2
  %25 = add nsw i32 %23, %accumulator.tr39.us48
  %or.cond.us52 = icmp eq i32 %24, 0
  br i1 %or.cond.us52, label %.loopexit, label %.lr.ph.split.split.us

.split.us:                                        ; preds = %tailrecurse.us.us, %.lr.ph68.split, %20, %.lr.ph68.split.us
  %.us-phi44 = phi i32 [ 0, %.lr.ph68.split.us ], [ %accumulator.tr39.us48, %20 ], [ %accumulator.tr39.us67, %.lr.ph68.split ], [ %11, %tailrecurse.us.us ]
  %.us-phi45 = phi i32 [ %.tr, %.lr.ph68.split.us ], [ %.tr40.us47, %20 ], [ %.tr40.us66, %.lr.ph68.split ], [ %10, %tailrecurse.us.us ]
  %26 = icmp eq i32 %.us-phi45, %.tr118
  br i1 %26, label %27, label %.loopexit

27:                                               ; preds = %.split.us
  %28 = add nsw i32 %.tr118, -1
  %29 = tail call noundef i32 @_Z6Hosoyaii(i32 noundef %28, i32 noundef %28)
  %30 = add nsw i32 %.tr118, -2
  %31 = add i32 %29, %.us-phi44
  %accumulator.ret.tr = add i32 %31, %accumulator.tr
  br label %tailrecurse

.loopexit:                                        ; preds = %tailrecurse.us, %.lr.ph.split.split.us, %tailrecurse.us51, %tailrecurse, %.lr.ph.split.us.split, %.split.us
  %accumulator.tr37 = phi i32 [ %.us-phi44, %.split.us ], [ 0, %tailrecurse ], [ 0, %.lr.ph.split.us.split ], [ %accumulator.tr39.us48, %.lr.ph.split.split.us ], [ %25, %tailrecurse.us51 ], [ %17, %tailrecurse.us ]
  %.0 = phi i32 [ 0, %.split.us ], [ 1, %tailrecurse ], [ 1, %.lr.ph.split.us.split ], [ 1, %tailrecurse.us51 ], [ 1, %.lr.ph.split.split.us ], [ 1, %tailrecurse.us ]
  %accumulator.ret.tr34 = add nsw i32 %.0, %accumulator.tr37
  %accumulator.ret.tr119 = add i32 %accumulator.ret.tr34, %accumulator.tr
  ret i32 %accumulator.ret.tr119
}

attributes #0 = { mustprogress nofree nosync nounwind willreturn 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)"}


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