; LLVM IR from Dev-XYS/Algorithms :: Bigraph-Matching(Edmonds-Karp).ll (Z8add_edgeii)

; 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.vertex = type { i32, i32, i32, i32, i8 }
%struct.edge = type { i32, i32, i32 }

@V = external dso_local global [10000 x %struct.vertex], align 16
@E = external dso_local global [100000 x %struct.edge], align 16
@ec = external dso_local global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z8add_edgeii(i32 noundef %0, i32 noundef %1) #0 {
  %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 = sext i32 %5 to i64
  %7 = getelementptr inbounds [10000 x %struct.vertex], ptr @V, i64 0, i64 %6
  %8 = getelementptr inbounds %struct.vertex, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = load i32, ptr @ec, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %11
  %13 = getelementptr inbounds %struct.edge, ptr %12, i32 0, i32 1
  store i32 %9, ptr %13, align 4, !tbaa !12
  %14 = load i32, ptr @ec, align 4, !tbaa !5
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [10000 x %struct.vertex], ptr @V, i64 0, i64 %16
  %18 = getelementptr inbounds %struct.vertex, ptr %17, i32 0, i32 0
  store i32 %14, ptr %18, align 4, !tbaa !9
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = load i32, ptr @ec, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %21
  %23 = getelementptr inbounds %struct.edge, ptr %22, i32 0, i32 0
  store i32 %19, ptr %23, align 4, !tbaa !14
  %24 = load i32, ptr @ec, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %25
  %27 = getelementptr inbounds %struct.edge, ptr %26, i32 0, i32 2
  store i32 1, ptr %27, align 4, !tbaa !15
  %28 = load i32, ptr @ec, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr @ec, align 4, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [10000 x %struct.vertex], ptr @V, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.vertex, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = load i32, ptr @ec, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.edge, ptr %37, i32 0, i32 1
  store i32 %34, ptr %38, align 4, !tbaa !12
  %39 = load i32, ptr @ec, align 4, !tbaa !5
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [10000 x %struct.vertex], ptr @V, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.vertex, ptr %42, i32 0, i32 0
  store i32 %39, ptr %43, align 4, !tbaa !9
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = load i32, ptr @ec, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.edge, ptr %47, i32 0, i32 0
  store i32 %44, ptr %48, align 4, !tbaa !14
  %49 = load i32, ptr @ec, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.edge, ptr %51, i32 0, i32 2
  store i32 0, ptr %52, align 4, !tbaa !15
  %53 = load i32, ptr @ec, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr @ec, align 4, !tbaa !5
  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, !6, i64 0}
!10 = !{!"_ZTS6vertex", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !11, i64 16}
!11 = !{!"bool", !7, i64 0}
!12 = !{!13, !6, i64 4}
!13 = !{!"_ZTS4edge", !6, i64 0, !6, i64 4, !6, i64 8}
!14 = !{!13, !6, i64 0}
!15 = !{!13, !6, i64 8}


; 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.vertex = type { i32, i32, i32, i32, i8 }
%struct.edge = type { i32, i32, i32 }

@V = external dso_local local_unnamed_addr global [10000 x %struct.vertex], align 16
@E = external dso_local local_unnamed_addr global [100000 x %struct.edge], align 16
@ec = 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 @_Z8add_edgeii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds [10000 x %struct.vertex], ptr @V, i64 0, i64 %3
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = load i32, ptr @ec, align 4, !tbaa !11
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %7, i32 1
  store i32 %5, ptr %8, align 4, !tbaa !12
  store i32 %6, ptr %4, align 4, !tbaa !5
  %9 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %7
  store i32 %1, ptr %9, align 4, !tbaa !14
  %10 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %7, i32 2
  store i32 1, ptr %10, align 4, !tbaa !15
  %11 = add nsw i32 %6, 1
  %12 = sext i32 %1 to i64
  %13 = getelementptr inbounds [10000 x %struct.vertex], ptr @V, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %11 to i64
  %16 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %15, i32 1
  store i32 %14, ptr %16, align 4, !tbaa !12
  store i32 %11, ptr %13, align 4, !tbaa !5
  %17 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %15
  store i32 %0, ptr %17, align 4, !tbaa !14
  %18 = getelementptr inbounds [100000 x %struct.edge], ptr @E, i64 0, i64 %15, i32 2
  store i32 0, ptr %18, align 4, !tbaa !15
  %19 = add nsw i32 %6, 2
  store i32 %19, ptr @ec, align 4, !tbaa !11
  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, !7, i64 0}
!6 = !{!"_ZTS6vertex", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 4}
!13 = !{!"_ZTS4edge", !7, i64 0, !7, i64 4, !7, i64 8}
!14 = !{!13, !7, i64 0}
!15 = !{!13, !7, i64 8}


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