; LLVM IR from MostafaTwfiq/C-DataStructures-And-Algorithms :: DataStructure/Graphs/Sources (UndirectedGraph)

; 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.UndirectedGraph = type { ptr, ptr, ptr }
%struct.UDGraphEdge = type { ptr, i32 }
%struct.UDGraphNode = type { ptr, ptr, ptr, ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [42 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [9 x i8], align 1

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare ptr @hashMapGet(ptr noundef, ptr noundef) #4

declare i32 @arrayListGetIndex(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local i32 @udGraphContainsEdge(ptr noundef %0, ptr noundef %1, ptr noundef %2) #5 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %20

17:                                               ; preds = %3
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.7, ptr noundef @.str.6, ptr noundef @.str.2) #6
  call void @exit(i32 noundef -83386157) #7
  unreachable

20:                                               ; preds = %3
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str, ptr noundef @.str.10, ptr noundef @.str.2) #6
  call void @exit(i32 noundef -83384987) #7
  unreachable

26:                                               ; preds = %20
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %32

29:                                               ; preds = %26
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str, ptr noundef @.str.11, ptr noundef @.str.2) #6
  call void @exit(i32 noundef -83384987) #7
  unreachable

32:                                               ; preds = %26
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.UndirectedGraph, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call ptr @hashMapGet(ptr noundef %37, ptr noundef %38)
  store ptr %39, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.UndirectedGraph, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = call ptr @hashMapGet(ptr noundef %42, ptr noundef %43)
  store ptr %44, ptr %9, align 8, !tbaa !5
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %50, label %47

47:                                               ; preds = %34
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %51

50:                                               ; preds = %47, %34
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %89

51:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %52 = call noalias ptr @malloc(i64 noundef 16) #8
  store ptr %52, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %53 = call noalias ptr @malloc(i64 noundef 16) #8
  store ptr %53, ptr %12, align 8, !tbaa !5
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = icmp eq ptr %54, null
  br i1 %55, label %59, label %56

56:                                               ; preds = %51
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %62

59:                                               ; preds = %56, %51
  %60 = load ptr, ptr @stderr, align 8, !tbaa !5
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef @.str.5, ptr noundef @.str.13, ptr noundef @.str.2) #6
  call void @exit(i32 noundef -833811484) #7
  unreachable

62:                                               ; preds = %56
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.UDGraphEdge, ptr %64, i32 0, i32 0
  store ptr %63, ptr %65, align 8, !tbaa !11
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.UDGraphEdge, ptr %67, i32 0, i32 0
  store ptr %66, ptr %68, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.UDGraphNode, ptr %69, i32 0, i32 1
  %71 = load ptr, ptr %70, align 8, !tbaa !14
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = call i32 @arrayListGetIndex(ptr noundef %71, ptr noundef %72)
  store i32 %73, ptr %13, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.UDGraphNode, ptr %74, i32 0, i32 1
  %76 = load ptr, ptr %75, align 8, !tbaa !14
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = call i32 @arrayListGetIndex(ptr noundef %76, ptr noundef %77)
  store i32 %78, ptr %14, align 4, !tbaa !16
  %79 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %79) #6
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %80) #6
  %81 = load i32, ptr %13, align 4, !tbaa !16
  %82 = icmp sge i32 %81, 0
  br i1 %82, label %83, label %86

83:                                               ; preds = %62
  %84 = load i32, ptr %14, align 4, !tbaa !16
  %85 = icmp sge i32 %84, 0
  br label %86

86:                                               ; preds = %83, %62
  %87 = phi i1 [ false, %62 ], [ %85, %83 ]
  %88 = zext i1 %87 to i32
  store i32 %88, ptr %4, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %89

89:                                               ; preds = %86, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %90 = load i32, ptr %4, align 4
  ret i32 %90
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { noreturn nounwind "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 allocsize(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 #4 = { "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 #5 = { 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" }
attributes #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"UndirectedGraph", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!12, !6, i64 0}
!12 = !{!"UDGraphEdge", !6, i64 0, !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"UDGraphNode", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!13, !13, i64 0}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [42 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

declare ptr @hashMapGet(ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @arrayListGetIndex(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @udGraphContainsEdge(ptr noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #5 {
  %4 = icmp eq ptr %0, null
  br i1 %4, label %5, label %8

5:                                                ; preds = %3
  %6 = load ptr, ptr @stderr, align 8, !tbaa !5
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2) #6
  tail call void @exit(i32 noundef -83386157) #7
  unreachable

8:                                                ; preds = %3
  %9 = icmp eq ptr %1, null
  br i1 %9, label %10, label %13

10:                                               ; preds = %8
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str, ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.2) #6
  tail call void @exit(i32 noundef -83384987) #7
  unreachable

13:                                               ; preds = %8
  %14 = icmp eq ptr %2, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %13
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str, ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.2) #6
  tail call void @exit(i32 noundef -83384987) #7
  unreachable

18:                                               ; preds = %13
  %19 = load ptr, ptr %0, align 8, !tbaa !9
  %20 = tail call ptr @hashMapGet(ptr noundef %19, ptr noundef nonnull %1) #8
  %21 = load ptr, ptr %0, align 8, !tbaa !9
  %22 = tail call ptr @hashMapGet(ptr noundef %21, ptr noundef nonnull %2) #8
  %23 = icmp eq ptr %20, null
  %24 = icmp eq ptr %22, null
  %or.cond = select i1 %23, i1 true, i1 %24
  br i1 %or.cond, label %44, label %25

25:                                               ; preds = %18
  %26 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #9
  %27 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #9
  %28 = icmp eq ptr %26, null
  %29 = icmp eq ptr %27, null
  %or.cond3 = or i1 %28, %29
  br i1 %or.cond3, label %30, label %33

30:                                               ; preds = %25
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.2) #6
  tail call void @exit(i32 noundef -833811484) #7
  unreachable

33:                                               ; preds = %25
  store ptr %20, ptr %26, align 8, !tbaa !11
  store ptr %22, ptr %27, align 8, !tbaa !11
  %34 = getelementptr inbounds i8, ptr %20, i64 8
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = tail call i32 @arrayListGetIndex(ptr noundef %35, ptr noundef nonnull %27) #8
  %37 = getelementptr inbounds i8, ptr %22, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = tail call i32 @arrayListGetIndex(ptr noundef %38, ptr noundef nonnull %26) #8
  tail call void @free(ptr noundef nonnull %26) #8
  tail call void @free(ptr noundef nonnull %27) #8
  %40 = icmp sgt i32 %36, -1
  %41 = icmp sgt i32 %39, -1
  %42 = select i1 %40, i1 %41, i1 false
  %43 = zext i1 %42 to i32
  br label %44

44:                                               ; preds = %18, %33
  %.0 = phi i32 [ %43, %33 ], [ 0, %18 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nofree nounwind "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 = { noreturn nounwind "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { "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 #5 = { 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" }
attributes #6 = { cold nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"UndirectedGraph", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!12, !6, i64 0}
!12 = !{!"UDGraphEdge", !6, i64 0, !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 8}
!15 = !{!"UDGraphNode", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}


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