; LLVM IR from tangjz/acm-icpc :: lydsy/1016.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.Line = type { i32, i32, i32 }
%struct.Union = type { [201 x i32] }

@edge = external dso_local global [200001 x %struct.Line], align 16
@now = external dso_local global i32, align 4
@tmp = external dso_local global i32, align 4
@sum = external dso_local global i32, align 4
@LAST = external dso_local global %struct.Union, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %struct.Union, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = load i32, ptr @now, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  %9 = icmp eq i32 %6, %8
  br i1 %9, label %10, label %17

10:                                               ; preds = %2
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = load i32, ptr @tmp, align 4, !tbaa !5
  %13 = icmp eq i32 %11, %12
  br i1 %13, label %14, label %17

14:                                               ; preds = %10
  %15 = load i32, ptr @sum, align 4, !tbaa !5
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr @sum, align 4, !tbaa !5
  br label %44

17:                                               ; preds = %10, %2
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = load i32, ptr @now, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  %21 = icmp eq i32 %18, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  br label %44

23:                                               ; preds = %17
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  %26 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z3dfsii(i32 noundef %25, i32 noundef %26)
  call void @llvm.lifetime.start.p0(i64 804, ptr %5) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 @LAST, i64 804, i1 false), !tbaa.struct !9
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [200001 x %struct.Line], ptr @edge, i64 0, i64 %28
  %30 = getelementptr inbounds %struct.Line, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [200001 x %struct.Line], ptr @edge, i64 0, i64 %33
  %35 = getelementptr inbounds %struct.Line, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !13
  %37 = call noundef zeroext i1 @_ZN5Union7combineEii(ptr noundef nonnull align 4 dereferenceable(804) @LAST, i32 noundef %31, i32 noundef %36)
  br i1 %37, label %38, label %43

38:                                               ; preds = %23
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  call void @_Z3dfsii(i32 noundef %40, i32 noundef %42)
  br label %43

43:                                               ; preds = %38, %23
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @LAST, ptr align 4 %5, i64 804, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 804, ptr %5) #3
  br label %44

44:                                               ; preds = %43, %22, %14
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5Union7combineEii(ptr noundef nonnull align 4 dereferenceable(804), i32 noundef, i32 noundef) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree 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 = !{i64 0, i64 804, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Line", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 4}


; 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.Line = type { i32, i32, i32 }
%struct.Union = type { [201 x i32] }

@edge = external dso_local local_unnamed_addr global [200001 x %struct.Line], align 16
@now = external dso_local local_unnamed_addr global i32, align 4
@tmp = external dso_local local_unnamed_addr global i32, align 4
@sum = external dso_local local_unnamed_addr global i32, align 4
@LAST = external dso_local global %struct.Union, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %.sroa.0 = alloca [201 x i32], align 4
  %3 = load i32, ptr @now, align 4, !tbaa !5
  %4 = add nsw i32 %3, 1
  %5 = icmp eq i32 %4, %0
  %6 = load i32, ptr @tmp, align 4
  %7 = icmp eq i32 %6, %1
  %or.cond = select i1 %5, i1 %7, i1 false
  br i1 %or.cond, label %8, label %11

8:                                                ; preds = %2
  %9 = load i32, ptr @sum, align 4, !tbaa !5
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr @sum, align 4, !tbaa !5
  br label %23

11:                                               ; preds = %2
  br i1 %5, label %23, label %12

12:                                               ; preds = %11
  %13 = add nsw i32 %0, 1
  tail call void @_Z3dfsii(i32 noundef %13, i32 noundef %1)
  call void @llvm.lifetime.start.p0(i64 804, ptr nonnull %.sroa.0)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(804) %.sroa.0, ptr noundef nonnull align 4 dereferenceable(804) @LAST, i64 804, i1 false), !tbaa.struct !9
  %14 = sext i32 %0 to i64
  %15 = getelementptr inbounds [200001 x %struct.Line], ptr @edge, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %15, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !13
  %19 = tail call noundef zeroext i1 @_ZN5Union7combineEii(ptr noundef nonnull align 4 dereferenceable(804) @LAST, i32 noundef %16, i32 noundef %18)
  br i1 %19, label %20, label %22

20:                                               ; preds = %12
  %21 = add nsw i32 %1, 1
  tail call void @_Z3dfsii(i32 noundef %13, i32 noundef %21)
  br label %22

22:                                               ; preds = %20, %12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(804) @LAST, ptr noundef nonnull align 4 dereferenceable(804) %.sroa.0, i64 804, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 804, ptr nonnull %.sroa.0)
  br label %23

23:                                               ; preds = %11, %22, %8
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5Union7combineEii(ptr noundef nonnull align 4 dereferenceable(804), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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 = !{i64 0, i64 804, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS4Line", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 4}


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