; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/2511（汉诺塔）.ll (Z5solveiixiii)

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

@.str = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solveiixiii(i32 noundef %0, i32 noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i64 %2, ptr %9, align 8, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %14 = load i32, ptr %8, align 4, !tbaa !5
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = sub nsw i32 %14, %15
  %17 = zext i32 %16 to i64
  %18 = shl i64 1, %17
  %19 = sub nsw i64 %18, 1
  store i64 %19, ptr %13, align 8, !tbaa !9
  %20 = load i64, ptr %9, align 8, !tbaa !9
  %21 = load i64, ptr %13, align 8, !tbaa !9
  %22 = icmp sle i64 %20, %21
  br i1 %22, label %23, label %31

23:                                               ; preds = %6
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = sub nsw i32 %25, 1
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = load i32, ptr %10, align 4, !tbaa !5
  %29 = load i32, ptr %12, align 4, !tbaa !5
  %30 = load i32, ptr %11, align 4, !tbaa !5
  call void @_Z5solveiixiii(i32 noundef %24, i32 noundef %26, i64 noundef %27, i32 noundef %28, i32 noundef %29, i32 noundef %30)
  br label %53

31:                                               ; preds = %6
  %32 = load i64, ptr %9, align 8, !tbaa !9
  %33 = load i64, ptr %13, align 8, !tbaa !9
  %34 = add nsw i64 %33, 1
  %35 = icmp eq i64 %32, %34
  br i1 %35, label %36, label %41

36:                                               ; preds = %31
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = load i32, ptr %10, align 4, !tbaa !5
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %37, i32 noundef %38, i32 noundef %39)
  br label %52

41:                                               ; preds = %31
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = load i32, ptr %8, align 4, !tbaa !5
  %44 = sub nsw i32 %43, 1
  %45 = load i64, ptr %9, align 8, !tbaa !9
  %46 = sub nsw i64 %45, 1
  %47 = load i64, ptr %13, align 8, !tbaa !9
  %48 = sub nsw i64 %46, %47
  %49 = load i32, ptr %12, align 4, !tbaa !5
  %50 = load i32, ptr %11, align 4, !tbaa !5
  %51 = load i32, ptr %10, align 4, !tbaa !5
  call void @_Z5solveiixiii(i32 noundef %42, i32 noundef %44, i64 noundef %48, i32 noundef %49, i32 noundef %50, i32 noundef %51)
  br label %52

52:                                               ; preds = %41, %36
  br label %53

53:                                               ; preds = %52, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  ret void
}

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

declare i32 @printf(ptr noundef, ...) #2

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}


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

@.str = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z5solveiixiii(i32 noundef %0, i32 noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  br label %tailrecurse.outer

tailrecurse.outer:                                ; preds = %11, %6
  %.tr23.ph = phi i32 [ %10, %11 ], [ %1, %6 ]
  %.tr24.ph = phi i64 [ %13, %11 ], [ %2, %6 ]
  %.tr25.ph = phi i32 [ %.tr27, %11 ], [ %3, %6 ]
  %.tr26.ph = phi i32 [ %.tr26, %11 ], [ %4, %6 ]
  %.tr27.ph = phi i32 [ %.tr25.ph, %11 ], [ %5, %6 ]
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse, %tailrecurse.outer
  %.tr23 = phi i32 [ %10, %tailrecurse ], [ %.tr23.ph, %tailrecurse.outer ]
  %.tr26 = phi i32 [ %.tr27, %tailrecurse ], [ %.tr26.ph, %tailrecurse.outer ]
  %.tr27 = phi i32 [ %.tr26, %tailrecurse ], [ %.tr27.ph, %tailrecurse.outer ]
  %7 = sub nsw i32 %.tr23, %0
  %8 = zext nneg i32 %7 to i64
  %9 = shl nuw i64 1, %8
  %.not.not = icmp sgt i64 %9, %.tr24.ph
  %10 = add nsw i32 %.tr23, -1
  br i1 %.not.not, label %tailrecurse, label %11

11:                                               ; preds = %tailrecurse
  %12 = icmp eq i64 %9, %.tr24.ph
  %13 = sub i64 %.tr24.ph, %9
  br i1 %12, label %14, label %tailrecurse.outer

14:                                               ; preds = %11
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.tr23, i32 noundef %.tr25.ph, i32 noundef %.tr26)
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { mustprogress nofree 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 #1 = { nofree nounwind "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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass