; LLVM IR from int32bit/leetcode :: algorithms/PascalsTriangleII/solve.ll (Z3gcdii)

; 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 @_Z3gcdii(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 = load i32, ptr %5, align 4, !tbaa !5
  %8 = icmp slt i32 %6, %7
  br i1 %8, label %9, label %13

9:                                                ; preds = %2
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = call noundef i32 @_Z3gcdii(i32 noundef %10, i32 noundef %11)
  store i32 %12, ptr %3, align 4
  br label %53

13:                                               ; preds = %2
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %17, ptr %3, align 4
  br label %53

18:                                               ; preds = %13
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = and i32 %19, 1
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %38

22:                                               ; preds = %18
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = and i32 %23, 1
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %33

26:                                               ; preds = %22
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = ashr i32 %27, 1
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = ashr i32 %29, 1
  %31 = call noundef i32 @_Z3gcdii(i32 noundef %28, i32 noundef %30)
  %32 = shl i32 %31, 1
  store i32 %32, ptr %3, align 4
  br label %53

33:                                               ; preds = %22
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = ashr i32 %34, 1
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = call noundef i32 @_Z3gcdii(i32 noundef %35, i32 noundef %36)
  store i32 %37, ptr %3, align 4
  br label %53

38:                                               ; preds = %18
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = and i32 %39, 1
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %47

42:                                               ; preds = %38
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = ashr i32 %44, 1
  %46 = call noundef i32 @_Z3gcdii(i32 noundef %43, i32 noundef %45)
  store i32 %46, ptr %3, align 4
  br label %53

47:                                               ; preds = %38
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sub nsw i32 %49, %50
  %52 = call noundef i32 @_Z3gcdii(i32 noundef %48, i32 noundef %51)
  store i32 %52, ptr %3, align 4
  br label %53

53:                                               ; preds = %47, %42, %33, %26, %16, %9
  %54 = load i32, ptr %3, align 4
  ret i32 %54
}

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 @_Z3gcdii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  br label %tailrecurse.outer.outer

tailrecurse.outer.outer:                          ; preds = %tailrecurse.outer.outer.backedge, %2
  %.tr.ph.ph = phi i32 [ %0, %2 ], [ %.tr.ph.ph.be, %tailrecurse.outer.outer.backedge ]
  %.tr22.ph.ph = phi i32 [ %1, %2 ], [ %.tr22.ph.ph.be, %tailrecurse.outer.outer.backedge ]
  %3 = icmp eq i32 %.tr22.ph.ph, 0
  %4 = and i32 %.tr22.ph.ph, 1
  %5 = icmp eq i32 %4, 0
  br label %tailrecurse.outer

tailrecurse.outer:                                ; preds = %tailrecurse.outer.outer, %.split.us
  %.tr.ph = phi i32 [ %9, %.split.us ], [ %.tr.ph.ph, %tailrecurse.outer.outer ]
  %6 = icmp slt i32 %.tr.ph, %.tr22.ph.ph
  br i1 %6, label %tailrecurse.outer.outer.backedge, label %.lr.ph

.lr.ph:                                           ; preds = %tailrecurse.outer
  %7 = and i32 %.tr.ph, 1
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  br i1 %3, label %common.ret68, label %.split.us

.split.us:                                        ; preds = %.lr.ph.split.us
  %9 = ashr exact i32 %.tr.ph, 1
  br i1 %5, label %14, label %tailrecurse.outer

.lr.ph.split:                                     ; preds = %.lr.ph, %tailrecurse
  %.tr2227 = phi i32 [ %18, %tailrecurse ], [ %.tr22.ph.ph, %.lr.ph ]
  %10 = icmp eq i32 %.tr2227, 0
  br i1 %10, label %common.ret68, label %11

11:                                               ; preds = %.lr.ph.split
  %12 = and i32 %.tr2227, 1
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %tailrecurse, label %20

common.ret68:                                     ; preds = %.lr.ph.split, %.lr.ph.split.us, %14
  %common.ret68.op = phi i32 [ %17, %14 ], [ %.tr.ph, %.lr.ph.split.us ], [ %.tr.ph, %.lr.ph.split ]
  ret i32 %common.ret68.op

14:                                               ; preds = %.split.us
  %15 = ashr exact i32 %.tr22.ph.ph, 1
  %16 = tail call noundef i32 @_Z3gcdii(i32 noundef %9, i32 noundef %15)
  %17 = shl i32 %16, 1
  br label %common.ret68

tailrecurse:                                      ; preds = %11
  %18 = ashr exact i32 %.tr2227, 1
  %19 = icmp slt i32 %.tr.ph, %18
  br i1 %19, label %tailrecurse.outer.outer.backedge, label %.lr.ph.split

20:                                               ; preds = %11
  %21 = sub i32 %.tr.ph, %.tr2227
  br label %tailrecurse.outer.outer.backedge

tailrecurse.outer.outer.backedge:                 ; preds = %tailrecurse.outer, %tailrecurse, %20
  %.tr.ph.ph.be = phi i32 [ %.tr2227, %20 ], [ %18, %tailrecurse ], [ %.tr22.ph.ph, %tailrecurse.outer ]
  %.tr22.ph.ph.be = phi i32 [ %21, %20 ], [ %.tr.ph, %tailrecurse ], [ %.tr.ph, %tailrecurse.outer ]
  br label %tailrecurse.outer.outer
}

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: GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass