; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd/948.ll (Z4dfs1c)

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

%struct.Node = type { i8, [3 x i8] }

@a = external dso_local global [30 x %struct.Node], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4dfs1c(i8 noundef signext %0) #0 {
  %2 = alloca i8, align 1
  store i8 %0, ptr %2, align 1, !tbaa !5
  %3 = load i8, ptr %2, align 1, !tbaa !5
  %4 = sext i8 %3 to i64
  %5 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %4
  %6 = getelementptr inbounds %struct.Node, ptr %5, i32 0, i32 0
  %7 = load i8, ptr %6, align 4, !tbaa !8
  %8 = sext i8 %7 to i32
  %9 = call i32 @putchar(i32 noundef %8)
  %10 = load i8, ptr %2, align 1, !tbaa !5
  %11 = sext i8 %10 to i64
  %12 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %11
  %13 = getelementptr inbounds %struct.Node, ptr %12, i32 0, i32 1
  %14 = getelementptr inbounds [3 x i8], ptr %13, i64 0, i64 0
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %17, label %24

17:                                               ; preds = %1
  %18 = load i8, ptr %2, align 1, !tbaa !5
  %19 = sext i8 %18 to i64
  %20 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.Node, ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds [3 x i8], ptr %21, i64 0, i64 0
  %23 = load i8, ptr %22, align 1, !tbaa !5
  call void @_Z4dfs1c(i8 noundef signext %23)
  br label %24

24:                                               ; preds = %17, %1
  %25 = load i8, ptr %2, align 1, !tbaa !5
  %26 = sext i8 %25 to i64
  %27 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Node, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds [3 x i8], ptr %28, i64 0, i64 1
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = icmp ne i8 %30, 0
  br i1 %31, label %32, label %39

32:                                               ; preds = %24
  %33 = load i8, ptr %2, align 1, !tbaa !5
  %34 = sext i8 %33 to i64
  %35 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.Node, ptr %35, i32 0, i32 1
  %37 = getelementptr inbounds [3 x i8], ptr %36, i64 0, i64 1
  %38 = load i8, ptr %37, align 1, !tbaa !5
  call void @_Z4dfs1c(i8 noundef signext %38)
  br label %39

39:                                               ; preds = %32, %24
  %40 = load i8, ptr %2, align 1, !tbaa !5
  %41 = sext i8 %40 to i64
  %42 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.Node, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds [3 x i8], ptr %43, i64 0, i64 2
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = icmp ne i8 %45, 0
  br i1 %46, label %47, label %54

47:                                               ; preds = %39
  %48 = load i8, ptr %2, align 1, !tbaa !5
  %49 = sext i8 %48 to i64
  %50 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.Node, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds [3 x i8], ptr %51, i64 0, i64 2
  %53 = load i8, ptr %52, align 1, !tbaa !5
  call void @_Z4dfs1c(i8 noundef signext %53)
  br label %54

54:                                               ; preds = %47, %39
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #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 = { inlinehint 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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !6, i64 0}
!9 = !{!"_ZTS4Node", !6, i64 0, !6, i64 1}


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

%struct.Node = type { i8, [3 x i8] }

@a = external dso_local local_unnamed_addr global [30 x %struct.Node], align 16

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z4dfs1c(i8 noundef signext %0) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %14, %1
  %.tr = phi i8 [ %0, %1 ], [ %16, %14 ]
  %2 = sext i8 %.tr to i64
  %3 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %2
  %4 = load i8, ptr %3, align 4, !tbaa !5
  %5 = sext i8 %4 to i32
  %6 = tail call i32 @putchar(i32 noundef %5)
  %7 = getelementptr inbounds i8, ptr %3, i64 1
  %8 = load i8, ptr %7, align 1, !tbaa !9
  %.not = icmp eq i8 %8, 0
  br i1 %.not, label %10, label %9

9:                                                ; preds = %tailrecurse
  tail call void @_Z4dfs1c(i8 noundef signext %8)
  br label %10

10:                                               ; preds = %9, %tailrecurse
  %11 = getelementptr inbounds i8, ptr %3, i64 2
  %12 = load i8, ptr %11, align 2, !tbaa !9
  %.not9 = icmp eq i8 %12, 0
  br i1 %.not9, label %14, label %13

13:                                               ; preds = %10
  tail call void @_Z4dfs1c(i8 noundef signext %12)
  br label %14

14:                                               ; preds = %13, %10
  %15 = getelementptr inbounds i8, ptr %3, i64 3
  %16 = load i8, ptr %15, align 1, !tbaa !9
  %.not10 = icmp eq i8 %16, 0
  br i1 %.not10, label %17, label %tailrecurse

17:                                               ; preds = %14
  ret void
}

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) 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 = { inlinehint 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" }

!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, !7, i64 0}
!6 = !{!"_ZTS4Node", !7, i64 0, !7, i64 1}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass