; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/1515（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"

@x1 = external dso_local global [123 x i8], align 16
@s1 = external dso_local global [123 x i8], align 16
@s2 = external dso_local global [123 x i8], align 16
@stack = external dso_local global [123 x i8], align 16
@len1 = external dso_local global i32, align 4
@len2 = external dso_local global i32, align 4
@len3 = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [1 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; 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
  %8 = alloca i8, align 1
  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
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = load i32, ptr @len2, align 4, !tbaa !5
  %11 = icmp eq i32 %9, %10
  br i1 %11, label %12, label %30

12:                                               ; preds = %3
  %13 = call i32 @puts(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %26, %12
  %15 = load i32, ptr %7, align 4, !tbaa !5
  %16 = load i32, ptr @len3, align 4, !tbaa !5
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %29

19:                                               ; preds = %14
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [123 x i8], ptr @x1, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = sext i8 %23 to i32
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %24)
  br label %26

26:                                               ; preds = %19
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %7, align 4, !tbaa !5
  br label %14, !llvm.loop !10

29:                                               ; preds = %18
  br label %90

30:                                               ; preds = %3
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load i32, ptr @len1, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %61

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [123 x i8], ptr @stack, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !9
  store i8 %38, ptr %8, align 1, !tbaa !9
  %39 = load i32, ptr @len3, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr @len3, align 4, !tbaa !5
  %41 = sext i32 %39 to i64
  %42 = getelementptr inbounds [123 x i8], ptr @x1, i64 0, i64 %41
  store i8 105, ptr %42, align 1, !tbaa !9
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [123 x i8], ptr @s1, i64 0, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [123 x i8], ptr @stack, i64 0, i64 %48
  store i8 %46, ptr %49, align 1, !tbaa !9
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  call void @_Z3dfsiii(i32 noundef %51, i32 noundef %52, i32 noundef %54)
  %55 = load i8, ptr %8, align 1, !tbaa !9
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [123 x i8], ptr @stack, i64 0, i64 %57
  store i8 %55, ptr %58, align 1, !tbaa !9
  %59 = load i32, ptr @len3, align 4, !tbaa !5
  %60 = add nsw i32 %59, -1
  store i32 %60, ptr @len3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  br label %61

61:                                               ; preds = %34, %30
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = icmp sgt i32 %62, 0
  br i1 %63, label %64, label %89

64:                                               ; preds = %61
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [123 x i8], ptr @stack, i64 0, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !9
  %70 = sext i8 %69 to i32
  %71 = load i32, ptr %5, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [123 x i8], ptr @s2, i64 0, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !9
  %75 = sext i8 %74 to i32
  %76 = icmp eq i32 %70, %75
  br i1 %76, label %77, label %89

77:                                               ; preds = %64
  %78 = load i32, ptr @len3, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr @len3, align 4, !tbaa !5
  %80 = sext i32 %78 to i64
  %81 = getelementptr inbounds [123 x i8], ptr @x1, i64 0, i64 %80
  store i8 111, ptr %81, align 1, !tbaa !9
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = sub nsw i32 %85, 1
  call void @_Z3dfsiii(i32 noundef %82, i32 noundef %84, i32 noundef %86)
  %87 = load i32, ptr @len3, align 4, !tbaa !5
  %88 = add nsw i32 %87, -1
  store i32 %88, ptr @len3, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %77, %64, %61
  br label %90

90:                                               ; preds = %89, %29
  ret void
}

declare i32 @puts(ptr noundef) #1

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

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

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

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

@x1 = external dso_local local_unnamed_addr global [123 x i8], align 16
@s1 = external dso_local local_unnamed_addr global [123 x i8], align 16
@s2 = external dso_local local_unnamed_addr global [123 x i8], align 16
@stack = external dso_local local_unnamed_addr global [123 x i8], align 16
@len1 = external dso_local local_unnamed_addr global i32, align 4
@len2 = external dso_local local_unnamed_addr global i32, align 4
@len3 = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [1 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr @len2, align 4, !tbaa !5
  %5 = icmp eq i32 %4, %1
  br i1 %5, label %6, label %17

6:                                                ; preds = %3
  %7 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str)
  %8 = load i32, ptr @len3, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %common.ret24

.lr.ph:                                           ; preds = %6, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %6 ]
  %10 = getelementptr inbounds [123 x i8], ptr @x1, i64 0, i64 %indvars.iv
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %12 = sext i8 %11 to i32
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %12)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr @len3, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = icmp slt i64 %indvars.iv.next, %15
  br i1 %16, label %.lr.ph, label %common.ret24, !llvm.loop !10

17:                                               ; preds = %3
  %18 = load i32, ptr @len1, align 4, !tbaa !5
  %19 = icmp sgt i32 %18, %0
  br i1 %19, label %20, label %35

20:                                               ; preds = %17
  %21 = sext i32 %2 to i64
  %22 = getelementptr inbounds [123 x i8], ptr @stack, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = load i32, ptr @len3, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr @len3, align 4, !tbaa !5
  %26 = sext i32 %24 to i64
  %27 = getelementptr inbounds [123 x i8], ptr @x1, i64 0, i64 %26
  store i8 105, ptr %27, align 1, !tbaa !9
  %28 = sext i32 %0 to i64
  %29 = getelementptr inbounds [123 x i8], ptr @s1, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !9
  store i8 %30, ptr %22, align 1, !tbaa !9
  %31 = add nsw i32 %0, 1
  %32 = add nsw i32 %2, 1
  tail call void @_Z3dfsiii(i32 noundef %31, i32 noundef %1, i32 noundef %32)
  store i8 %23, ptr %22, align 1, !tbaa !9
  %33 = load i32, ptr @len3, align 4, !tbaa !5
  %34 = add nsw i32 %33, -1
  store i32 %34, ptr @len3, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %20, %17
  %36 = icmp sgt i32 %2, 0
  br i1 %36, label %37, label %common.ret24

37:                                               ; preds = %35
  %38 = add nsw i32 %2, -1
  %39 = zext nneg i32 %38 to i64
  %40 = getelementptr inbounds [123 x i8], ptr @stack, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !9
  %42 = sext i32 %1 to i64
  %43 = getelementptr inbounds [123 x i8], ptr @s2, i64 0, i64 %42
  %44 = load i8, ptr %43, align 1, !tbaa !9
  %45 = icmp eq i8 %41, %44
  br i1 %45, label %46, label %common.ret24

common.ret24:                                     ; preds = %35, %37, %6, %.lr.ph, %46
  ret void

46:                                               ; preds = %37
  %47 = load i32, ptr @len3, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr @len3, align 4, !tbaa !5
  %49 = sext i32 %47 to i64
  %50 = getelementptr inbounds [123 x i8], ptr @x1, i64 0, i64 %49
  store i8 111, ptr %50, align 1, !tbaa !9
  %51 = add nsw i32 %1, 1
  tail call void @_Z3dfsiii(i32 noundef %0, i32 noundef %51, i32 noundef %38)
  %52 = load i32, ptr @len3, align 4, !tbaa !5
  %53 = add nsw i32 %52, -1
  store i32 %53, ptr @len3, align 4, !tbaa !5
  br label %common.ret24
}

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

; 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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