; LLVM IR from lzyrapx/Competitive-Programming :: 百度之星/百度之星2017-资格赛/02（pb_ds）.ll (Z7addEdgeiix)

; 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 { i64, i32, i32, i32 }

@edge = external dso_local global [444444 x %struct.Edge], align 16
@head = external dso_local global [3333 x i32], align 16
@top = external dso_local global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z7addEdgeiix(i32 noundef %0, i32 noundef %1, i64 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %7 = load i64, ptr %6, align 8, !tbaa !9
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %3
  br label %69

10:                                               ; preds = %3
  %11 = load i64, ptr %6, align 8, !tbaa !9
  %12 = load i32, ptr @top, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %13
  %15 = getelementptr inbounds %struct.Edge, ptr %14, i32 0, i32 0
  store i64 %11, ptr %15, align 8, !tbaa !11
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = load i32, ptr @top, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.Edge, ptr %19, i32 0, i32 1
  store i32 %16, ptr %20, align 8, !tbaa !13
  %21 = load i32, ptr @top, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  %23 = load i32, ptr @top, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.Edge, ptr %25, i32 0, i32 3
  store i32 %22, ptr %26, align 8, !tbaa !14
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [3333 x i32], ptr @head, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = load i32, ptr @top, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %32
  %34 = getelementptr inbounds %struct.Edge, ptr %33, i32 0, i32 2
  store i32 %30, ptr %34, align 4, !tbaa !15
  %35 = load i32, ptr @top, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr @top, align 4, !tbaa !5
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [3333 x i32], ptr @head, i64 0, i64 %38
  store i32 %35, ptr %39, align 4, !tbaa !5
  %40 = load i64, ptr %6, align 8, !tbaa !9
  %41 = load i32, ptr @top, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.Edge, ptr %43, i32 0, i32 0
  store i64 %40, ptr %44, align 8, !tbaa !11
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = load i32, ptr @top, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %47
  %49 = getelementptr inbounds %struct.Edge, ptr %48, i32 0, i32 1
  store i32 %45, ptr %49, align 8, !tbaa !13
  %50 = load i32, ptr @top, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = load i32, ptr @top, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.Edge, ptr %54, i32 0, i32 3
  store i32 %51, ptr %55, align 8, !tbaa !14
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [3333 x i32], ptr @head, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = load i32, ptr @top, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.Edge, ptr %62, i32 0, i32 2
  store i32 %59, ptr %63, align 4, !tbaa !15
  %64 = load i32, ptr @top, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr @top, align 4, !tbaa !5
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [3333 x i32], ptr @head, i64 0, i64 %67
  store i32 %64, ptr %68, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %10, %9
  ret void
}

attributes #0 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS4Edge", !10, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 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 { i64, i32, i32, i32 }

@edge = external dso_local local_unnamed_addr global [444444 x %struct.Edge], align 16
@head = external dso_local local_unnamed_addr global [3333 x i32], align 16
@top = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z7addEdgeiix(i32 noundef %0, i32 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq i64 %2, 0
  br i1 %4, label %25, label %5

5:                                                ; preds = %3
  %6 = load i32, ptr @top, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %7
  store i64 %2, ptr %8, align 8, !tbaa !9
  %9 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %7, i32 1
  store i32 %1, ptr %9, align 8, !tbaa !12
  %10 = add nsw i32 %6, 1
  %11 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %7, i32 3
  store i32 %10, ptr %11, align 8, !tbaa !13
  %12 = sext i32 %0 to i64
  %13 = getelementptr inbounds [3333 x i32], ptr @head, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %7, i32 2
  store i32 %14, ptr %15, align 4, !tbaa !14
  store i32 %6, ptr %13, align 4, !tbaa !5
  %16 = sext i32 %10 to i64
  %17 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %16
  store i64 %2, ptr %17, align 8, !tbaa !9
  %18 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %16, i32 1
  store i32 %0, ptr %18, align 8, !tbaa !12
  %19 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %16, i32 3
  store i32 %6, ptr %19, align 8, !tbaa !13
  %20 = sext i32 %1 to i64
  %21 = getelementptr inbounds [3333 x i32], ptr @head, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds [444444 x %struct.Edge], ptr @edge, i64 0, i64 %16, i32 2
  store i32 %22, ptr %23, align 4, !tbaa !14
  %24 = add nsw i32 %6, 2
  store i32 %24, ptr @top, align 4, !tbaa !5
  store i32 %10, ptr %21, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %3, %5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) 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 = !{!10, !11, i64 0}
!10 = !{!"_ZTS4Edge", !11, i64 0, !6, i64 8, !6, i64 12, !6, i64 16}
!11 = !{!"long long", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 16}
!14 = !{!10, !6, i64 12}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass