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

; 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: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4dfs4c(i8 noundef signext %0) #1 {
  %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 1
  %7 = getelementptr inbounds [3 x i8], ptr %6, i64 0, i64 0
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = icmp ne i8 %8, 0
  br i1 %9, label %10, label %17

10:                                               ; preds = %1
  %11 = load i8, ptr %2, align 1, !tbaa !5
  %12 = sext i8 %11 to i64
  %13 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %12
  %14 = getelementptr inbounds %struct.Node, ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds [3 x i8], ptr %14, i64 0, i64 0
  %16 = load i8, ptr %15, align 1, !tbaa !5
  call void @_Z4dfs4c(i8 noundef signext %16)
  br label %17

17:                                               ; preds = %10, %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 1
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = icmp ne i8 %23, 0
  br i1 %24, label %25, label %32

25:                                               ; preds = %17
  %26 = load i8, ptr %2, align 1, !tbaa !5
  %27 = sext i8 %26 to i64
  %28 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.Node, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds [3 x i8], ptr %29, i64 0, i64 1
  %31 = load i8, ptr %30, align 1, !tbaa !5
  call void @_Z4dfs4c(i8 noundef signext %31)
  br label %32

32:                                               ; preds = %25, %17
  %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 2
  %38 = load i8, ptr %37, align 1, !tbaa !5
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %47

40:                                               ; preds = %32
  %41 = load i8, ptr %2, align 1, !tbaa !5
  %42 = sext i8 %41 to i64
  %43 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.Node, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds [3 x i8], ptr %44, i64 0, i64 2
  %46 = load i8, ptr %45, align 1, !tbaa !5
  call void @_Z4dfs4c(i8 noundef signext %46)
  br label %47

47:                                               ; preds = %40, %32
  %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 0
  %52 = load i8, ptr %51, align 4, !tbaa !8
  %53 = sext i8 %52 to i32
  %54 = call i32 @putchar(i32 noundef %53)
  ret void
}

attributes #0 = { 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" }
attributes #1 = { 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: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z4dfs4c(i8 noundef signext %0) local_unnamed_addr #1 {
  %2 = sext i8 %0 to i64
  %3 = getelementptr inbounds [30 x %struct.Node], ptr @a, i64 0, i64 %2
  %4 = getelementptr inbounds i8, ptr %3, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !5
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %7, label %6

6:                                                ; preds = %1
  tail call void @_Z4dfs4c(i8 noundef signext %5)
  br label %7

7:                                                ; preds = %6, %1
  %8 = getelementptr inbounds i8, ptr %3, i64 2
  %9 = load i8, ptr %8, align 2, !tbaa !5
  %.not9 = icmp eq i8 %9, 0
  br i1 %.not9, label %11, label %10

10:                                               ; preds = %7
  tail call void @_Z4dfs4c(i8 noundef signext %9)
  br label %11

11:                                               ; preds = %10, %7
  %12 = getelementptr inbounds i8, ptr %3, i64 3
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %.not10 = icmp eq i8 %13, 0
  br i1 %.not10, label %15, label %14

14:                                               ; preds = %11
  tail call void @_Z4dfs4c(i8 noundef signext %13)
  br label %15

15:                                               ; preds = %14, %11
  %16 = load i8, ptr %3, align 4, !tbaa !8
  %17 = sext i8 %16 to i32
  %18 = tail call i32 @putchar(i32 noundef %17)
  ret void
}

attributes #0 = { 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" }
attributes #1 = { 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, !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}


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