; LLVM IR from NishkarshRaj/Design-and-Analysis-of-Algorithms :: graphs (Bellmanford)

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z11createGraphii(i32 noundef, i32 noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 5, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 8, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = call noundef ptr @_Z11createGraphii(i32 noundef %5, i32 noundef %6)
  store ptr %7, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !9
  %9 = getelementptr inbounds %struct.Graph, ptr %8, i32 0, i32 2
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %struct.Edge, ptr %10, i64 0
  %12 = getelementptr inbounds %struct.Edge, ptr %11, i32 0, i32 0
  store i32 0, ptr %12, align 4, !tbaa !13
  %13 = load ptr, ptr %4, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.Graph, ptr %13, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds %struct.Edge, ptr %15, i64 0
  %17 = getelementptr inbounds %struct.Edge, ptr %16, i32 0, i32 1
  store i32 1, ptr %17, align 4, !tbaa !15
  %18 = load ptr, ptr %4, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.Graph, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds %struct.Edge, ptr %20, i64 0
  %22 = getelementptr inbounds %struct.Edge, ptr %21, i32 0, i32 2
  store i32 -1, ptr %22, align 4, !tbaa !16
  %23 = load ptr, ptr %4, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.Graph, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.Edge, ptr %25, i64 1
  %27 = getelementptr inbounds %struct.Edge, ptr %26, i32 0, i32 0
  store i32 0, ptr %27, align 4, !tbaa !13
  %28 = load ptr, ptr %4, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.Graph, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct.Edge, ptr %30, i64 1
  %32 = getelementptr inbounds %struct.Edge, ptr %31, i32 0, i32 1
  store i32 2, ptr %32, align 4, !tbaa !15
  %33 = load ptr, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.Graph, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = getelementptr inbounds %struct.Edge, ptr %35, i64 1
  %37 = getelementptr inbounds %struct.Edge, ptr %36, i32 0, i32 2
  store i32 4, ptr %37, align 4, !tbaa !16
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.Graph, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.Edge, ptr %40, i64 2
  %42 = getelementptr inbounds %struct.Edge, ptr %41, i32 0, i32 0
  store i32 1, ptr %42, align 4, !tbaa !13
  %43 = load ptr, ptr %4, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.Graph, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = getelementptr inbounds %struct.Edge, ptr %45, i64 2
  %47 = getelementptr inbounds %struct.Edge, ptr %46, i32 0, i32 1
  store i32 2, ptr %47, align 4, !tbaa !15
  %48 = load ptr, ptr %4, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.Graph, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = getelementptr inbounds %struct.Edge, ptr %50, i64 2
  %52 = getelementptr inbounds %struct.Edge, ptr %51, i32 0, i32 2
  store i32 3, ptr %52, align 4, !tbaa !16
  %53 = load ptr, ptr %4, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.Graph, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = getelementptr inbounds %struct.Edge, ptr %55, i64 3
  %57 = getelementptr inbounds %struct.Edge, ptr %56, i32 0, i32 0
  store i32 1, ptr %57, align 4, !tbaa !13
  %58 = load ptr, ptr %4, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.Graph, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.Edge, ptr %60, i64 3
  %62 = getelementptr inbounds %struct.Edge, ptr %61, i32 0, i32 1
  store i32 3, ptr %62, align 4, !tbaa !15
  %63 = load ptr, ptr %4, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.Graph, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !11
  %66 = getelementptr inbounds %struct.Edge, ptr %65, i64 3
  %67 = getelementptr inbounds %struct.Edge, ptr %66, i32 0, i32 2
  store i32 2, ptr %67, align 4, !tbaa !16
  %68 = load ptr, ptr %4, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.Graph, ptr %68, i32 0, i32 2
  %70 = load ptr, ptr %69, align 8, !tbaa !11
  %71 = getelementptr inbounds %struct.Edge, ptr %70, i64 4
  %72 = getelementptr inbounds %struct.Edge, ptr %71, i32 0, i32 0
  store i32 1, ptr %72, align 4, !tbaa !13
  %73 = load ptr, ptr %4, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.Graph, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !11
  %76 = getelementptr inbounds %struct.Edge, ptr %75, i64 4
  %77 = getelementptr inbounds %struct.Edge, ptr %76, i32 0, i32 1
  store i32 4, ptr %77, align 4, !tbaa !15
  %78 = load ptr, ptr %4, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.Graph, ptr %78, i32 0, i32 2
  %80 = load ptr, ptr %79, align 8, !tbaa !11
  %81 = getelementptr inbounds %struct.Edge, ptr %80, i64 4
  %82 = getelementptr inbounds %struct.Edge, ptr %81, i32 0, i32 2
  store i32 2, ptr %82, align 4, !tbaa !16
  %83 = load ptr, ptr %4, align 8, !tbaa !9
  %84 = getelementptr inbounds %struct.Graph, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !11
  %86 = getelementptr inbounds %struct.Edge, ptr %85, i64 5
  %87 = getelementptr inbounds %struct.Edge, ptr %86, i32 0, i32 0
  store i32 3, ptr %87, align 4, !tbaa !13
  %88 = load ptr, ptr %4, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.Graph, ptr %88, i32 0, i32 2
  %90 = load ptr, ptr %89, align 8, !tbaa !11
  %91 = getelementptr inbounds %struct.Edge, ptr %90, i64 5
  %92 = getelementptr inbounds %struct.Edge, ptr %91, i32 0, i32 1
  store i32 2, ptr %92, align 4, !tbaa !15
  %93 = load ptr, ptr %4, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.Graph, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !11
  %96 = getelementptr inbounds %struct.Edge, ptr %95, i64 5
  %97 = getelementptr inbounds %struct.Edge, ptr %96, i32 0, i32 2
  store i32 5, ptr %97, align 4, !tbaa !16
  %98 = load ptr, ptr %4, align 8, !tbaa !9
  %99 = getelementptr inbounds %struct.Graph, ptr %98, i32 0, i32 2
  %100 = load ptr, ptr %99, align 8, !tbaa !11
  %101 = getelementptr inbounds %struct.Edge, ptr %100, i64 6
  %102 = getelementptr inbounds %struct.Edge, ptr %101, i32 0, i32 0
  store i32 3, ptr %102, align 4, !tbaa !13
  %103 = load ptr, ptr %4, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.Graph, ptr %103, i32 0, i32 2
  %105 = load ptr, ptr %104, align 8, !tbaa !11
  %106 = getelementptr inbounds %struct.Edge, ptr %105, i64 6
  %107 = getelementptr inbounds %struct.Edge, ptr %106, i32 0, i32 1
  store i32 1, ptr %107, align 4, !tbaa !15
  %108 = load ptr, ptr %4, align 8, !tbaa !9
  %109 = getelementptr inbounds %struct.Graph, ptr %108, i32 0, i32 2
  %110 = load ptr, ptr %109, align 8, !tbaa !11
  %111 = getelementptr inbounds %struct.Edge, ptr %110, i64 6
  %112 = getelementptr inbounds %struct.Edge, ptr %111, i32 0, i32 2
  store i32 1, ptr %112, align 4, !tbaa !16
  %113 = load ptr, ptr %4, align 8, !tbaa !9
  %114 = getelementptr inbounds %struct.Graph, ptr %113, i32 0, i32 2
  %115 = load ptr, ptr %114, align 8, !tbaa !11
  %116 = getelementptr inbounds %struct.Edge, ptr %115, i64 7
  %117 = getelementptr inbounds %struct.Edge, ptr %116, i32 0, i32 0
  store i32 4, ptr %117, align 4, !tbaa !13
  %118 = load ptr, ptr %4, align 8, !tbaa !9
  %119 = getelementptr inbounds %struct.Graph, ptr %118, i32 0, i32 2
  %120 = load ptr, ptr %119, align 8, !tbaa !11
  %121 = getelementptr inbounds %struct.Edge, ptr %120, i64 7
  %122 = getelementptr inbounds %struct.Edge, ptr %121, i32 0, i32 1
  store i32 3, ptr %122, align 4, !tbaa !15
  %123 = load ptr, ptr %4, align 8, !tbaa !9
  %124 = getelementptr inbounds %struct.Graph, ptr %123, i32 0, i32 2
  %125 = load ptr, ptr %124, align 8, !tbaa !11
  %126 = getelementptr inbounds %struct.Edge, ptr %125, i64 7
  %127 = getelementptr inbounds %struct.Edge, ptr %126, i32 0, i32 2
  store i32 -3, ptr %127, align 4, !tbaa !16
  %128 = load ptr, ptr %4, align 8, !tbaa !9
  call void @_Z11BellmanFordP5Graphi(ptr noundef %128, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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 = { mustprogress norecurse 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 #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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS5Graph", !6, i64 0, !6, i64 4, !10, i64 8}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS4Edge", !6, i64 0, !6, i64 4, !6, i64 8}
!15 = !{!14, !6, i64 4}
!16 = !{!14, !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"

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call noundef ptr @_Z11createGraphii(i32 noundef 5, i32 noundef 8)
  %2 = getelementptr inbounds i8, ptr %1, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  store <4 x i32> <i32 0, i32 1, i32 -1, i32 0>, ptr %3, align 4, !tbaa !11
  %4 = getelementptr inbounds i8, ptr %3, i64 16
  store <4 x i32> <i32 2, i32 4, i32 1, i32 2>, ptr %4, align 4, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %3, i64 32
  store <4 x i32> <i32 3, i32 1, i32 3, i32 2>, ptr %5, align 4, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %3, i64 48
  store <4 x i32> <i32 1, i32 4, i32 2, i32 3>, ptr %6, align 4, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %3, i64 64
  store <4 x i32> <i32 2, i32 5, i32 3, i32 1>, ptr %7, align 4, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %3, i64 80
  store <4 x i32> <i32 1, i32 4, i32 3, i32 -3>, ptr %8, align 4, !tbaa !11
  tail call void @_Z11BellmanFordP5Graphi(ptr noundef %1, i32 noundef 0)
  ret i32 0
}

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 norecurse 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, !10, i64 8}
!6 = !{!"_ZTS5Graph", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!7, !7, i64 0}


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