; LLVM IR from tangjz/acm-icpc :: lydsy/3306.ll (Z3dfsi)

; 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.Edge = type { i32, i32 }

@n = external dso_local global i32, align 4
@val = external dso_local global [131072 x i32], align 16
@tot = external dso_local global i32, align 4
@pre = external dso_local global [131072 x i32], align 16
@dep = external dso_local global [131072 x i32], align 16
@fa = external dso_local global [131072 x [17 x i32]], align 16
@in = external dso_local global [131072 x i32], align 16
@out = external dso_local global [131072 x i32], align 16
@e = external dso_local global [131072 x %struct.Edge], align 16

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3updiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsi(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %7 = load i32, ptr @tot, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  store i32 %8, ptr @tot, align 4, !tbaa !5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [131072 x i32], ptr @in, i64 0, i64 %10
  store i32 %8, ptr %11, align 4, !tbaa !5
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [131072 x i32], ptr @in, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [131072 x i32], ptr @val, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  call void @_Z3updiiiii(i32 noundef 1, i32 noundef 1, i32 noundef %12, i32 noundef %16, i32 noundef %20)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [131072 x i32], ptr @pre, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr %3, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %83, %1
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %89

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [131072 x %struct.Edge], ptr @e, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.Edge, ptr %32, i32 0, i32 1
  store ptr %33, ptr %5, align 8, !tbaa !9
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [131072 x i32], ptr @dep, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [131072 x i32], ptr @dep, i64 0, i64 %41
  store i32 %38, ptr %42, align 4, !tbaa !5
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = load ptr, ptr %5, align 8, !tbaa !9
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %46
  %48 = getelementptr inbounds [17 x i32], ptr %47, i64 0, i64 0
  store i32 %43, ptr %48, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %77, %29
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = icmp slt i32 %50, 17
  br i1 %51, label %53, label %52

52:                                               ; preds = %49
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %80

53:                                               ; preds = %49
  %54 = load ptr, ptr %5, align 8, !tbaa !9
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %56
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = sub nsw i32 %58, 1
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [17 x i32], ptr %57, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %63
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [17 x i32], ptr %64, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !9
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %72
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [17 x i32], ptr %73, i64 0, i64 %75
  store i32 %69, ptr %76, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %53
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %6, align 4, !tbaa !5
  br label %49, !llvm.loop !11

80:                                               ; preds = %52
  %81 = load ptr, ptr %5, align 8, !tbaa !9
  %82 = load i32, ptr %81, align 4, !tbaa !5
  call void @_Z3dfsi(i32 noundef %82)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %83

83:                                               ; preds = %80
  %84 = load i32, ptr %3, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [131072 x %struct.Edge], ptr @e, i64 0, i64 %85
  %87 = getelementptr inbounds %struct.Edge, ptr %86, i32 0, i32 0
  %88 = load i32, ptr %87, align 8, !tbaa !13
  store i32 %88, ptr %3, align 4, !tbaa !5
  br label %25, !llvm.loop !15

89:                                               ; preds = %28
  %90 = load i32, ptr @tot, align 4, !tbaa !5
  %91 = load i32, ptr %2, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [131072 x i32], ptr @out, i64 0, i64 %92
  store i32 %90, ptr %93, align 4, !tbaa !5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4}
!15 = distinct !{!15, !12}


; 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.Edge = type { i32, i32 }

@n = external dso_local local_unnamed_addr global i32, align 4
@val = external dso_local local_unnamed_addr global [131072 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@pre = external dso_local local_unnamed_addr global [131072 x i32], align 16
@dep = external dso_local local_unnamed_addr global [131072 x i32], align 16
@fa = external dso_local local_unnamed_addr global [131072 x [17 x i32]], align 16
@in = external dso_local local_unnamed_addr global [131072 x i32], align 16
@out = external dso_local local_unnamed_addr global [131072 x i32], align 16
@e = external dso_local local_unnamed_addr global [131072 x %struct.Edge], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3updiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsi(i32 noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @tot, align 4, !tbaa !5
  %3 = add nsw i32 %2, 1
  store i32 %3, ptr @tot, align 4, !tbaa !5
  %4 = sext i32 %0 to i64
  %5 = getelementptr inbounds [131072 x i32], ptr @in, i64 0, i64 %4
  store i32 %3, ptr %5, align 4, !tbaa !5
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = getelementptr inbounds [131072 x i32], ptr @val, i64 0, i64 %4
  %8 = load i32, ptr %7, align 4, !tbaa !5
  tail call void @_Z3updiiiii(i32 noundef 1, i32 noundef 1, i32 noundef %6, i32 noundef %3, i32 noundef %8)
  %9 = getelementptr inbounds [131072 x i32], ptr @pre, i64 0, i64 %4
  %.01921 = load i32, ptr %9, align 4, !tbaa !5
  %.not22 = icmp eq i32 %.01921, 0
  br i1 %.not22, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %10 = getelementptr inbounds [131072 x i32], ptr @dep, i64 0, i64 %4
  %11 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %4, i64 0
  br label %14

._crit_edge:                                      ; preds = %14, %1
  %12 = load i32, ptr @tot, align 4, !tbaa !5
  %13 = getelementptr inbounds [131072 x i32], ptr @out, i64 0, i64 %4
  store i32 %12, ptr %13, align 4, !tbaa !5
  ret void

14:                                               ; preds = %.lr.ph, %14
  %.01923 = phi i32 [ %.01921, %.lr.ph ], [ %.019, %14 ]
  %15 = sext i32 %.01923 to i64
  %16 = getelementptr inbounds [131072 x %struct.Edge], ptr @e, i64 0, i64 %15
  %17 = getelementptr inbounds i8, ptr %16, i64 4
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = load i32, ptr %17, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [131072 x i32], ptr @dep, i64 0, i64 %21
  store i32 %19, ptr %22, align 4, !tbaa !5
  %23 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21
  store i32 %0, ptr %23, align 4, !tbaa !5
  %24 = load i32, ptr %11, align 4, !tbaa !5
  %25 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 1
  store i32 %24, ptr %25, align 4, !tbaa !5
  %26 = sext i32 %24 to i64
  %27 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %26, i64 1
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 2
  store i32 %28, ptr %29, align 4, !tbaa !5
  %30 = sext i32 %28 to i64
  %31 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %30, i64 2
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 3
  store i32 %32, ptr %33, align 4, !tbaa !5
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %34, i64 3
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 4
  store i32 %36, ptr %37, align 4, !tbaa !5
  %38 = sext i32 %36 to i64
  %39 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %38, i64 4
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 5
  store i32 %40, ptr %41, align 4, !tbaa !5
  %42 = sext i32 %40 to i64
  %43 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %42, i64 5
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 6
  store i32 %44, ptr %45, align 4, !tbaa !5
  %46 = sext i32 %44 to i64
  %47 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %46, i64 6
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 7
  store i32 %48, ptr %49, align 4, !tbaa !5
  %50 = sext i32 %48 to i64
  %51 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %50, i64 7
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 8
  store i32 %52, ptr %53, align 4, !tbaa !5
  %54 = sext i32 %52 to i64
  %55 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %54, i64 8
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 9
  store i32 %56, ptr %57, align 4, !tbaa !5
  %58 = sext i32 %56 to i64
  %59 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %58, i64 9
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 10
  store i32 %60, ptr %61, align 4, !tbaa !5
  %62 = sext i32 %60 to i64
  %63 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %62, i64 10
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 11
  store i32 %64, ptr %65, align 4, !tbaa !5
  %66 = sext i32 %64 to i64
  %67 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %66, i64 11
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 12
  store i32 %68, ptr %69, align 4, !tbaa !5
  %70 = sext i32 %68 to i64
  %71 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %70, i64 12
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 13
  store i32 %72, ptr %73, align 4, !tbaa !5
  %74 = sext i32 %72 to i64
  %75 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %74, i64 13
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 14
  store i32 %76, ptr %77, align 4, !tbaa !5
  %78 = sext i32 %76 to i64
  %79 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %78, i64 14
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 15
  store i32 %80, ptr %81, align 4, !tbaa !5
  %82 = sext i32 %80 to i64
  %83 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %82, i64 15
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = getelementptr inbounds [131072 x [17 x i32]], ptr @fa, i64 0, i64 %21, i64 16
  store i32 %84, ptr %85, align 4, !tbaa !5
  tail call void @_Z3dfsi(i32 noundef %20)
  %.019 = load i32, ptr %16, align 8, !tbaa !5
  %.not = icmp eq i32 %.019, 0
  br i1 %.not, label %._crit_edge, label %14, !llvm.loop !9
}

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

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass