; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (1997（模拟）（汉诺塔）)

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

@a = external dso_local global [4 x [70 x i32]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5hannoiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  br label %8

8:                                                ; preds = %66, %0
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr %3, align 4, !tbaa !5
  %11 = icmp ne i32 %9, 0
  br i1 %11, label %12, label %67

12:                                               ; preds = %8
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %15 = load i32, ptr @a, align 16, !tbaa !5
  store i32 %15, ptr %4, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %25, %12
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = icmp sge i32 %17, 1
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %28

20:                                               ; preds = %16
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [70 x i32], ptr @a, i64 0, i64 %22
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %23)
  br label %25

25:                                               ; preds = %20
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr %4, align 4, !tbaa !5
  br label %16, !llvm.loop !9

28:                                               ; preds = %19
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef getelementptr inbounds ([4 x [70 x i32]], ptr @a, i64 0, i64 1))
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %30 = load i32, ptr getelementptr inbounds ([4 x [70 x i32]], ptr @a, i64 0, i64 1), align 8, !tbaa !5
  store i32 %30, ptr %5, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %40, %28
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp sge i32 %32, 1
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %43

35:                                               ; preds = %31
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [70 x i32], ptr getelementptr inbounds ([4 x [70 x i32]], ptr @a, i64 0, i64 1), i64 0, i64 %37
  %39 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %38)
  br label %40

40:                                               ; preds = %35
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = add nsw i32 %41, -1
  store i32 %42, ptr %5, align 4, !tbaa !5
  br label %31, !llvm.loop !11

43:                                               ; preds = %34
  %44 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef getelementptr inbounds ([4 x [70 x i32]], ptr @a, i64 0, i64 2))
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %45 = load i32, ptr getelementptr inbounds ([4 x [70 x i32]], ptr @a, i64 0, i64 2), align 16, !tbaa !5
  store i32 %45, ptr %6, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %55, %43
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = icmp sge i32 %47, 1
  br i1 %48, label %50, label %49

49:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %58

50:                                               ; preds = %46
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [70 x i32], ptr getelementptr inbounds ([4 x [70 x i32]], ptr @a, i64 0, i64 2), i64 0, i64 %52
  %54 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %53)
  br label %55

55:                                               ; preds = %50
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = add nsw i32 %56, -1
  store i32 %57, ptr %6, align 4, !tbaa !5
  br label %46, !llvm.loop !12

58:                                               ; preds = %49
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = call noundef i32 @_Z5hannoiiii(i32 noundef %59, i32 noundef 0, i32 noundef 1, i32 noundef 2)
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %58
  %63 = call i32 @puts(ptr noundef @.str.1)
  br label %66

64:                                               ; preds = %58
  %65 = call i32 @puts(ptr noundef @.str.2)
  br label %66

66:                                               ; preds = %64, %62
  br label %8, !llvm.loop !13

67:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

declare i32 @puts(ptr noundef) #3

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 = { mustprogress norecurse 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 = { "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 #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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

@a = external dso_local global [4 x [70 x i32]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5hannoiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr %2, align 4, !tbaa !5
  %.not21 = icmp eq i32 %4, 0
  br i1 %.not21, label %._crit_edge24, label %.lr.ph23

.lr.ph23:                                         ; preds = %0, %._crit_edge20
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %8 = load i32, ptr @a, align 16, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.lr.ph23
  %10 = zext nneg i32 %8 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph23
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 280))
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 280), align 8, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph15.preheader, label %._crit_edge16

.lr.ph15.preheader:                               ; preds = %._crit_edge
  %14 = zext nneg i32 %12 to i64
  br label %.lr.ph15

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %10, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %15 = getelementptr inbounds [70 x i32], ptr @a, i64 0, i64 %indvars.iv
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %15)
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %17 = icmp ugt i64 %indvars.iv, 1
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge16:                                    ; preds = %.lr.ph15, %._crit_edge
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 560))
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 560), align 16, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph19.preheader, label %._crit_edge20

.lr.ph19.preheader:                               ; preds = %._crit_edge16
  %21 = zext nneg i32 %19 to i64
  br label %.lr.ph19

.lr.ph15:                                         ; preds = %.lr.ph15.preheader, %.lr.ph15
  %indvars.iv26 = phi i64 [ %14, %.lr.ph15.preheader ], [ %indvars.iv.next27, %.lr.ph15 ]
  %22 = getelementptr inbounds [70 x i32], ptr getelementptr inbounds (i8, ptr @a, i64 280), i64 0, i64 %indvars.iv26
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %22)
  %indvars.iv.next27 = add nsw i64 %indvars.iv26, -1
  %24 = icmp ugt i64 %indvars.iv26, 1
  br i1 %24, label %.lr.ph15, label %._crit_edge16, !llvm.loop !11

._crit_edge20:                                    ; preds = %.lr.ph19, %._crit_edge16
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = call noundef i32 @_Z5hannoiiii(i32 noundef %25, i32 noundef 0, i32 noundef 1, i32 noundef 2)
  %.not11 = icmp eq i32 %26, 0
  %.str.2..str.1 = select i1 %.not11, ptr @.str.2, ptr @.str.1
  %27 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.2..str.1)
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = add nsw i32 %28, -1
  store i32 %29, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %._crit_edge24, label %.lr.ph23, !llvm.loop !12

.lr.ph19:                                         ; preds = %.lr.ph19.preheader, %.lr.ph19
  %indvars.iv29 = phi i64 [ %21, %.lr.ph19.preheader ], [ %indvars.iv.next30, %.lr.ph19 ]
  %30 = getelementptr inbounds [70 x i32], ptr getelementptr inbounds (i8, ptr @a, i64 560), i64 0, i64 %indvars.iv29
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %30)
  %indvars.iv.next30 = add nsw i64 %indvars.iv29, -1
  %32 = icmp ugt i64 %indvars.iv29, 1
  br i1 %32, label %.lr.ph19, label %._crit_edge20, !llvm.loop !13

._crit_edge24:                                    ; preds = %._crit_edge20, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse 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 = { 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" }
attributes #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass