; LLVM IR from tangjz/acm-icpc :: 51nod/1570.ll (Z3dfsii)

; 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 { [65537 x i32] }

@que = external dso_local global [125 x %struct.Node], align 16
@expID = external dso_local global i32, align 4
@digit = external dso_local global [16 x i32], align 16
@ways = external dso_local global i32, align 4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsii(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 16
  br i1 %6, label %7, label %16

7:                                                ; preds = %2
  %8 = load i32, ptr @expID, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [125 x %struct.Node], ptr @que, i64 0, i64 %9
  %11 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [65537 x i32], ptr %11, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) @ways, i32 noundef %15)
  br label %43

16:                                               ; preds = %2
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [16 x i32], ptr @digit, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = icmp eq i32 %20, -1
  br i1 %21, label %22, label %32

22:                                               ; preds = %16
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  %25 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z3dfsii(i32 noundef %24, i32 noundef %25)
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = shl i32 1, %29
  %31 = or i32 %28, %30
  call void @_Z3dfsii(i32 noundef %27, i32 noundef %31)
  br label %43

32:                                               ; preds = %16
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [16 x i32], ptr @digit, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = shl i32 %39, %40
  %42 = or i32 %35, %41
  call void @_Z3dfsii(i32 noundef %34, i32 noundef %42)
  br label %43

43:                                               ; preds = %32, %22, %7
  ret void
}

attributes #0 = { inlinehint mustprogress 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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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 { [65537 x i32] }

@que = external dso_local local_unnamed_addr global [125 x %struct.Node], align 16
@expID = external dso_local local_unnamed_addr global i32, align 4
@digit = external dso_local local_unnamed_addr global [16 x i32], align 16
@ways = external dso_local global i32, align 4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3dfsii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq i32 %0, 16
  br i1 %3, label %tailrecurse._crit_edge, label %.lr.ph

tailrecurse._crit_edge:                           ; preds = %tailrecurse.backedge, %2
  %.tr13.lcssa = phi i32 [ %1, %2 ], [ %.tr13.be, %tailrecurse.backedge ]
  %4 = load i32, ptr @expID, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds [125 x %struct.Node], ptr @que, i64 0, i64 %5
  %7 = sext i32 %.tr13.lcssa to i64
  %8 = getelementptr inbounds [65537 x i32], ptr %6, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  tail call void @_Z7mod_incRii(ptr noundef nonnull align 4 dereferenceable(4) @ways, i32 noundef %9)
  ret void

.lr.ph:                                           ; preds = %2, %tailrecurse.backedge
  %.tr1315 = phi i32 [ %.tr13.be, %tailrecurse.backedge ], [ %1, %2 ]
  %.tr14 = phi i32 [ %14, %tailrecurse.backedge ], [ %0, %2 ]
  %10 = sext i32 %.tr14 to i64
  %11 = getelementptr inbounds [16 x i32], ptr @digit, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = icmp eq i32 %12, -1
  %14 = add nsw i32 %.tr14, 1
  br i1 %13, label %15, label %tailrecurse.backedge

15:                                               ; preds = %.lr.ph
  tail call void @_Z3dfsii(i32 noundef %14, i32 noundef %.tr1315)
  br label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %.lr.ph, %15
  %.pn16 = phi i32 [ 1, %15 ], [ %12, %.lr.ph ]
  %.pn = shl i32 %.pn16, %.tr14
  %.tr13.be = or i32 %.pn, %.tr1315
  %16 = icmp eq i32 %14, 16
  br i1 %16, label %tailrecurse._crit_edge, label %.lr.ph
}

attributes #0 = { inlinehint mustprogress 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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass