; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/1539（dfs）.ll (Z3dfsiii)

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

@n = external dso_local global i32, align 4
@vis = external dso_local global [23 x i8], align 16
@mark = external dso_local global [23 x i8], align 16
@len = external dso_local global i32, align 4
@ans = external dso_local global i32, align 4
@flag = external dso_local global i32, align 4
@bit = external dso_local global [23 x i32], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = load i32, ptr %6, align 4, !tbaa !5
  %10 = add nsw i32 %8, %9
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = icmp sgt i32 %10, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %82

14:                                               ; preds = %3
  %15 = load i32, ptr @len, align 4, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp eq i32 %15, %16
  br i1 %17, label %18, label %56

18:                                               ; preds = %14
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = add nsw i32 %20, %19
  store i32 %21, ptr %5, align 4, !tbaa !5
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %25, label %50

25:                                               ; preds = %18
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = load i32, ptr @ans, align 4, !tbaa !5
  %28 = icmp sgt i32 %26, %27
  br i1 %28, label %29, label %50

29:                                               ; preds = %25
  %30 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %30, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @flag, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %46, %29
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = load i32, ptr @len, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %49

36:                                               ; preds = %31
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [23 x i8], ptr @mark, i64 0, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !9, !range !11, !noundef !12
  %41 = trunc i8 %40 to i1
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [23 x i8], ptr @vis, i64 0, i64 %43
  %45 = zext i1 %41 to i8
  store i8 %45, ptr %44, align 1, !tbaa !9
  br label %46

46:                                               ; preds = %36
  %47 = load i32, ptr %7, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %7, align 4, !tbaa !5
  br label %31, !llvm.loop !13

49:                                               ; preds = %35
  br label %82

50:                                               ; preds = %25, %18
  %51 = load i32, ptr @ans, align 4, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = icmp eq i32 %51, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %50
  store i32 1, ptr @flag, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %54, %50
  br label %82

56:                                               ; preds = %14
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = mul nsw i32 %60, 10
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [23 x i32], ptr @bit, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = add nsw i32 %61, %65
  call void @_Z3dfsiii(i32 noundef %58, i32 noundef %59, i32 noundef %66)
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [23 x i8], ptr @mark, i64 0, i64 %68
  store i8 1, ptr %69, align 1, !tbaa !9
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = add nsw i32 %72, %73
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [23 x i32], ptr @bit, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  call void @_Z3dfsiii(i32 noundef %71, i32 noundef %74, i32 noundef %78)
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [23 x i8], ptr @mark, i64 0, i64 %80
  store i8 0, ptr %81, align 1, !tbaa !9
  br label %82

82:                                               ; preds = %56, %55, %49, %13
  ret void
}

; 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

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 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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

@n = external dso_local local_unnamed_addr global i32, align 4
@vis = external dso_local local_unnamed_addr global [23 x i8], align 16
@mark = external dso_local local_unnamed_addr global [23 x i8], align 16
@len = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i32, align 4
@flag = external dso_local local_unnamed_addr global i32, align 4
@bit = external dso_local local_unnamed_addr global [23 x i32], align 16

; Function Attrs: mustprogress nofree nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = add nsw i32 %2, %1
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp sgt i32 %4, %5
  br i1 %6, label %common.ret29, label %7

7:                                                ; preds = %3
  %8 = load i32, ptr @len, align 4, !tbaa !5
  %9 = icmp eq i32 %8, %0
  br i1 %9, label %10, label %19

10:                                               ; preds = %7
  %11 = load i32, ptr @ans, align 4
  %12 = icmp sgt i32 %4, %11
  br i1 %12, label %13, label %16

13:                                               ; preds = %10
  store i32 %4, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @flag, align 4, !tbaa !5
  %14 = icmp sgt i32 %0, 0
  br i1 %14, label %.lr.ph.preheader, label %common.ret29

.lr.ph.preheader:                                 ; preds = %13
  %15 = zext nneg i32 %0 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @vis, ptr nonnull align 16 @mark, i64 %15, i1 false), !tbaa !9
  br label %common.ret29

16:                                               ; preds = %10
  %17 = icmp eq i32 %11, %4
  br i1 %17, label %18, label %common.ret29

18:                                               ; preds = %16
  store i32 1, ptr @flag, align 4, !tbaa !5
  br label %common.ret29

common.ret29:                                     ; preds = %16, %18, %3, %13, %.lr.ph.preheader, %19
  ret void

19:                                               ; preds = %7
  %20 = add nsw i32 %0, 1
  %21 = mul nsw i32 %2, 10
  %22 = sext i32 %0 to i64
  %23 = getelementptr inbounds [23 x i32], ptr @bit, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = add nsw i32 %24, %21
  tail call void @_Z3dfsiii(i32 noundef %20, i32 noundef %1, i32 noundef %25)
  %26 = getelementptr inbounds [23 x i8], ptr @mark, i64 0, i64 %22
  store i8 1, ptr %26, align 1, !tbaa !9
  %27 = load i32, ptr %23, align 4, !tbaa !5
  tail call void @_Z3dfsiii(i32 noundef %20, i32 noundef %4, i32 noundef %27)
  store i8 0, ptr %26, align 1, !tbaa !9
  br label %common.ret29
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

!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 = !{!"bool", !7, i64 0}


; Effective O3 passes: ConstraintEliminationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass