; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Random/BABTWR/bab.ll (Z5recurii)

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

@h = external dso_local global [91 x i32], align 16
@w = external dso_local global [91 x i32], align 16
@d = external dso_local global [91 x i32], align 16
@n = external dso_local global i32, align 4
@dp = external dso_local global [90 x [90 x i32]], align 16

; 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: mustprogress uwtable
define dso_local noundef i32 @_Z5recurii(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %10 = load i32, ptr %5, align 4, !tbaa !5
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = mul nsw i32 3, %11
  %13 = icmp sgt i32 %10, %12
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %134

15:                                               ; preds = %2
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [90 x [90 x i32]], ptr @dp, i64 0, i64 %17
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [90 x i32], ptr %18, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %32

24:                                               ; preds = %15
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [90 x [90 x i32]], ptr @dp, i64 0, i64 %26
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [90 x i32], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  store i32 %31, ptr %3, align 4
  br label %134

32:                                               ; preds = %15
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %57

35:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  %39 = call noundef i32 @_Z5recurii(i32 noundef %36, i32 noundef %38)
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [91 x i32], ptr @d, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = add nsw i32 %39, %43
  store i32 %44, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  %48 = call noundef i32 @_Z5recurii(i32 noundef %45, i32 noundef %47)
  store i32 %48, ptr %7, align 4, !tbaa !5
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [90 x [90 x i32]], ptr @dp, i64 0, i64 %52
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [90 x i32], ptr %53, i64 0, i64 %55
  store i32 %50, ptr %56, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %131

57:                                               ; preds = %32
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [91 x i32], ptr @h, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [91 x i32], ptr @h, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = icmp slt i32 %61, %65
  br i1 %66, label %67, label %77

67:                                               ; preds = %57
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [91 x i32], ptr @w, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [91 x i32], ptr @w, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = icmp slt i32 %71, %75
  br i1 %76, label %97, label %77

77:                                               ; preds = %67, %57
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [91 x i32], ptr @h, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [91 x i32], ptr @w, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = icmp slt i32 %81, %85
  br i1 %86, label %87, label %119

87:                                               ; preds = %77
  %88 = load i32, ptr %5, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [91 x i32], ptr @w, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [91 x i32], ptr @h, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = icmp slt i32 %91, %95
  br i1 %96, label %97, label %119

97:                                               ; preds = %87, %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %98 = load i32, ptr %5, align 4, !tbaa !5
  %99 = load i32, ptr %5, align 4, !tbaa !5
  %100 = add nsw i32 %99, 1
  %101 = call noundef i32 @_Z5recurii(i32 noundef %98, i32 noundef %100)
  %102 = load i32, ptr %5, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [91 x i32], ptr @d, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = add nsw i32 %101, %105
  store i32 %106, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %107 = load i32, ptr %4, align 4, !tbaa !5
  %108 = load i32, ptr %5, align 4, !tbaa !5
  %109 = add nsw i32 %108, 1
  %110 = call noundef i32 @_Z5recurii(i32 noundef %107, i32 noundef %109)
  store i32 %110, ptr %9, align 4, !tbaa !5
  %111 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [90 x [90 x i32]], ptr @dp, i64 0, i64 %114
  %116 = load i32, ptr %5, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [90 x i32], ptr %115, i64 0, i64 %117
  store i32 %112, ptr %118, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %130

119:                                              ; preds = %87, %77
  %120 = load i32, ptr %4, align 4, !tbaa !5
  %121 = load i32, ptr %5, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  %123 = call noundef i32 @_Z5recurii(i32 noundef %120, i32 noundef %122)
  %124 = load i32, ptr %4, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [90 x [90 x i32]], ptr @dp, i64 0, i64 %125
  %127 = load i32, ptr %5, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [90 x i32], ptr %126, i64 0, i64 %128
  store i32 %123, ptr %129, align 4, !tbaa !5
  br label %130

130:                                              ; preds = %119, %97
  br label %131

131:                                              ; preds = %130, %35
  br label %132

132:                                              ; preds = %131
  br label %133

133:                                              ; preds = %132
  unreachable

134:                                              ; preds = %24, %14
  %135 = load i32, ptr %3, align 4
  ret i32 %135
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
attributes #2 = { inlinehint mustprogress 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 #3 = { 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++ 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"

@h = external dso_local local_unnamed_addr global [91 x i32], align 16
@w = external dso_local local_unnamed_addr global [91 x i32], align 16
@d = external dso_local local_unnamed_addr global [91 x i32], align 16
@n = external dso_local local_unnamed_addr global i32, align 4
@dp = external dso_local local_unnamed_addr global [90 x [90 x i32]], align 16

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, -2147483648) i32 @_Z5recurii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = mul nsw i32 %7, 3
  %9 = icmp slt i32 %8, %1
  br i1 %9, label %56, label %10

10:                                               ; preds = %2
  %11 = sext i32 %0 to i64
  %12 = sext i32 %1 to i64
  %13 = getelementptr inbounds [90 x [90 x i32]], ptr @dp, i64 0, i64 %11, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %56, label %16

16:                                               ; preds = %10
  %17 = icmp eq i32 %0, 0
  br i1 %17, label %18, label %26

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %19 = add nsw i32 %1, 1
  %20 = tail call noundef i32 @_Z5recurii(i32 noundef %1, i32 noundef %19)
  %21 = getelementptr inbounds [91 x i32], ptr @d, i64 0, i64 %12
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = add nsw i32 %22, %20
  store i32 %23, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %24 = tail call noundef i32 @_Z5recurii(i32 noundef 0, i32 noundef %19)
  store i32 %24, ptr %4, align 4, !tbaa !5
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  unreachable

26:                                               ; preds = %16
  %27 = getelementptr inbounds [91 x i32], ptr @h, i64 0, i64 %12
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = getelementptr inbounds [91 x i32], ptr @h, i64 0, i64 %11
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp slt i32 %28, %30
  br i1 %31, label %32, label %._crit_edge

._crit_edge:                                      ; preds = %26
  %.phi.trans.insert = getelementptr inbounds [91 x i32], ptr @w, i64 0, i64 %11
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  br label %38

32:                                               ; preds = %26
  %33 = getelementptr inbounds [91 x i32], ptr @w, i64 0, i64 %12
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = getelementptr inbounds [91 x i32], ptr @w, i64 0, i64 %11
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = icmp slt i32 %34, %36
  br i1 %37, label %45, label %38

38:                                               ; preds = %._crit_edge, %32
  %39 = phi i32 [ %.pre, %._crit_edge ], [ %36, %32 ]
  %40 = icmp slt i32 %28, %39
  br i1 %40, label %41, label %53

41:                                               ; preds = %38
  %42 = getelementptr inbounds [91 x i32], ptr @w, i64 0, i64 %12
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp slt i32 %43, %30
  br i1 %44, label %45, label %53

45:                                               ; preds = %41, %32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %46 = add nsw i32 %1, 1
  %47 = tail call noundef i32 @_Z5recurii(i32 noundef %1, i32 noundef %46)
  %48 = getelementptr inbounds [91 x i32], ptr @d, i64 0, i64 %12
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = add nsw i32 %49, %47
  store i32 %50, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %51 = tail call noundef i32 @_Z5recurii(i32 noundef %0, i32 noundef %46)
  store i32 %51, ptr %6, align 4, !tbaa !5
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  unreachable

53:                                               ; preds = %41, %38
  %54 = add nsw i32 %1, 1
  %55 = tail call noundef i32 @_Z5recurii(i32 noundef %0, i32 noundef %54)
  unreachable

56:                                               ; preds = %10, %2
  %.0 = phi i32 [ 0, %2 ], [ %14, %10 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 #3 = { 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++ TBAA"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass