; LLVM IR from rodrigo-lc/simulation-program-using-graphs :: include/graph (graph)

; 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.graphs = type { i32, ptr }

@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 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

declare void @perror(ptr noundef) #1

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

; 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, ...) #3

declare ptr @getHead(ptr noundef) #1

declare ptr @getData(ptr noundef) #1

declare i32 @vertexGetID(ptr noundef) #1

declare ptr @getNext(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @exportGraphDot(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %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 ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %19, label %16

16:                                               ; preds = %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %16, %2
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.4) #5
  call void @exit(i32 noundef 1) #6
  unreachable

22:                                               ; preds = %16
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call noalias ptr @fopen(ptr noundef %23, ptr noundef @.str.5)
  store ptr %24, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  call void @perror(ptr noundef @.str.6)
  call void @exit(i32 noundef 1) #6
  unreachable

28:                                               ; preds = %22
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str.7) #5
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.graphs, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call ptr @getHead(ptr noundef %33)
  store ptr %34, ptr %6, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %76, %28
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %79

38:                                               ; preds = %35
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = call ptr @getData(ptr noundef %39)
  store ptr %40, ptr %8, align 8, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call ptr @vertexGetEdges(ptr noundef %41)
  store ptr %42, ptr %12, align 8, !tbaa !5
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = call ptr @getHead(ptr noundef %43)
  store ptr %44, ptr %7, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %57, %54, %38
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %76

48:                                               ; preds = %45
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = call ptr @getData(ptr noundef %49)
  store ptr %50, ptr %10, align 8, !tbaa !5
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = call i32 @edgeGetStatus(ptr noundef %51)
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %54, label %57

54:                                               ; preds = %48
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = call ptr @getNext(ptr noundef %55)
  store ptr %56, ptr %7, align 8, !tbaa !5
  br label %45, !llvm.loop !12

57:                                               ; preds = %48
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  call void @edgeSetStatus(ptr noundef %58, i32 noundef 1)
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = call ptr @edgeGetAdjacent(ptr noundef %59)
  store ptr %60, ptr %9, align 8, !tbaa !5
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = call ptr @searchAdjacent(ptr noundef %61, ptr noundef %62)
  store ptr %63, ptr %11, align 8, !tbaa !5
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  call void @edgeSetStatus(ptr noundef %64, i32 noundef 1)
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = call i32 @edgeGetWeight(ptr noundef %65)
  store i32 %66, ptr %13, align 4, !tbaa !14
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = call i32 @vertexGetID(ptr noundef %68)
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = call i32 @vertexGetID(ptr noundef %70)
  %72 = load i32, ptr %13, align 4, !tbaa !14
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %67, ptr noundef @.str.8, i32 noundef %69, i32 noundef %71, i32 noundef %72) #5
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = call ptr @getNext(ptr noundef %74)
  store ptr %75, ptr %7, align 8, !tbaa !5
  br label %45, !llvm.loop !12

76:                                               ; preds = %45
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = call ptr @getNext(ptr noundef %77)
  store ptr %78, ptr %6, align 8, !tbaa !5
  br label %35, !llvm.loop !15

79:                                               ; preds = %35
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef @.str.9) #5
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = call i32 @fclose(ptr noundef %82)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

declare ptr @vertexGetEdges(ptr noundef) #1

declare i32 @edgeGetStatus(ptr noundef) #1

declare void @edgeSetStatus(ptr noundef, i32 noundef) #1

declare ptr @edgeGetAdjacent(ptr noundef) #1

declare ptr @searchAdjacent(ptr noundef, ptr noundef) #1

declare i32 @edgeGetWeight(ptr noundef) #1

declare i32 @fclose(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 "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 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"graphs", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!11, !11, i64 0}
!15 = distinct !{!15, !13}


; 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.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #0

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

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

declare ptr @getHead(ptr noundef) local_unnamed_addr #2

declare ptr @getData(ptr noundef) local_unnamed_addr #2

declare i32 @vertexGetID(ptr noundef) local_unnamed_addr #2

declare ptr @getNext(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @exportGraphDot(ptr noundef readonly %0, ptr noundef readonly %1) local_unnamed_addr #3 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %5, label %8

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

8:                                                ; preds = %2
  %9 = tail call noalias ptr @fopen(ptr noundef nonnull %0, ptr noundef nonnull @.str.5)
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  tail call void @perror(ptr noundef nonnull @.str.6) #6
  tail call void @exit(i32 noundef 1) #5
  unreachable

12:                                               ; preds = %8
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.7) #7
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = tail call ptr @getHead(ptr noundef %15) #7
  %.not35 = icmp eq ptr %16, null
  br i1 %.not35, label %._crit_edge39, label %.lr.ph38

.lr.ph38:                                         ; preds = %12, %._crit_edge
  %.036 = phi ptr [ %31, %._crit_edge ], [ %16, %12 ]
  %17 = tail call ptr @getData(ptr noundef nonnull %.036) #7
  %18 = tail call ptr @vertexGetEdges(ptr noundef %17) #7
  %19 = tail call ptr @getHead(ptr noundef %18) #7
  %.not3233 = icmp eq ptr %19, null
  br i1 %.not3233, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph38, %.backedge
  %.02834 = phi ptr [ %23, %.backedge ], [ %19, %.lr.ph38 ]
  %20 = tail call ptr @getData(ptr noundef nonnull %.02834) #7
  %21 = tail call i32 @edgeGetStatus(ptr noundef %20) #7
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %.backedge, label %24

.backedge:                                        ; preds = %.lr.ph, %24
  %23 = tail call ptr @getNext(ptr noundef nonnull %.02834) #7
  %.not32 = icmp eq ptr %23, null
  br i1 %.not32, label %._crit_edge, label %.lr.ph, !llvm.loop !12

24:                                               ; preds = %.lr.ph
  tail call void @edgeSetStatus(ptr noundef %20, i32 noundef 1) #7
  %25 = tail call ptr @edgeGetAdjacent(ptr noundef %20) #7
  %26 = tail call ptr @searchAdjacent(ptr noundef %25, ptr noundef %17) #7
  tail call void @edgeSetStatus(ptr noundef %26, i32 noundef 1) #7
  %27 = tail call i32 @edgeGetWeight(ptr noundef %20) #7
  %28 = tail call i32 @vertexGetID(ptr noundef %17) #7
  %29 = tail call i32 @vertexGetID(ptr noundef %25) #7
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.8, i32 noundef %28, i32 noundef %29, i32 noundef %27) #7
  br label %.backedge

._crit_edge:                                      ; preds = %.backedge, %.lr.ph38
  %31 = tail call ptr @getNext(ptr noundef nonnull %.036) #7
  %.not = icmp eq ptr %31, null
  br i1 %.not, label %._crit_edge39, label %.lr.ph38, !llvm.loop !14

._crit_edge39:                                    ; preds = %._crit_edge, %12
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %9, ptr noundef nonnull @.str.9) #7
  %33 = tail call i32 @fclose(ptr noundef nonnull %9)
  ret void
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #0

declare ptr @vertexGetEdges(ptr noundef) local_unnamed_addr #2

declare i32 @edgeGetStatus(ptr noundef) local_unnamed_addr #2

declare void @edgeSetStatus(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @edgeGetAdjacent(ptr noundef) local_unnamed_addr #2

declare ptr @searchAdjacent(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @edgeGetWeight(ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #0

attributes #0 = { 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 #1 = { 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 #2 = { "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 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 #4 = { cold nounwind }
attributes #5 = { noreturn nounwind }
attributes #6 = { cold }
attributes #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"graphs", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass