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

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

@stderr = external global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [4 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: noreturn nounwind
declare void @exit(i32 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, ...) #2

declare ptr @getHead(ptr noundef) #3

declare ptr @getData(ptr noundef) #3

declare ptr @getNext(ptr noundef) #3

declare i32 @printf(ptr noundef, ...) #3

declare ptr @getTail(ptr noundef) #3

declare ptr @getPrevious(ptr noundef) #3

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

10:                                               ; preds = %1
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str.25) #5
  call void @exit(i32 noundef 1) #6
  unreachable

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = call ptr @getHead(ptr noundef %14)
  store ptr %15, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !9
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.26)
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.27)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.28)
  br label %19

19:                                               ; preds = %43, %13
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %54

22:                                               ; preds = %19
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.29, i32 noundef %23)
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = call ptr @getData(ptr noundef %25)
  store ptr %26, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = call ptr @getTail(ptr noundef %27)
  store ptr %28, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  br label %29

29:                                               ; preds = %32, %22
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %43

32:                                               ; preds = %29
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call ptr @getData(ptr noundef %33)
  store ptr %34, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.edges, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct.vertexes, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.30, i32 noundef %39)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call ptr @getPrevious(ptr noundef %41)
  store ptr %42, ptr %6, align 8, !tbaa !5
  br label %29, !llvm.loop !15

43:                                               ; preds = %29
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.edges, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = getelementptr inbounds %struct.vertexes, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 8, !tbaa !13
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.31, i32 noundef %48)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call ptr @getNext(ptr noundef %50)
  store ptr %51, ptr %3, align 8, !tbaa !5
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %19, !llvm.loop !18

54:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"edges", !10, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !6, i64 32, !10, i64 40}
!13 = !{!14, !10, i64 16}
!14 = !{!"vertexes", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !6, i64 16}
!18 = distinct !{!18, !16}


; 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.25 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

declare ptr @getHead(ptr noundef) local_unnamed_addr #2

declare ptr @getData(ptr noundef) local_unnamed_addr #2

declare ptr @getNext(ptr noundef) local_unnamed_addr #2

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

declare ptr @getTail(ptr noundef) local_unnamed_addr #2

declare ptr @getPrevious(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @printLoops(ptr noundef %0) local_unnamed_addr #3 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %3, label %6

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

6:                                                ; preds = %1
  %7 = tail call ptr @getHead(ptr noundef nonnull %0) #6
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.26)
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.27)
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.28)
  %.not19 = icmp eq ptr %7, null
  br i1 %.not19, label %._crit_edge25, label %.lr.ph24

.lr.ph24:                                         ; preds = %6, %._crit_edge
  %.022 = phi ptr [ %.1.lcssa, %._crit_edge ], [ undef, %6 ]
  %.01321 = phi i32 [ %27, %._crit_edge ], [ 1, %6 ]
  %.01420 = phi ptr [ %26, %._crit_edge ], [ %7, %6 ]
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.29, i32 noundef %.01321)
  %12 = tail call ptr @getData(ptr noundef nonnull %.01420) #6
  %13 = tail call ptr @getTail(ptr noundef %12) #6
  %.not1617 = icmp eq ptr %13, null
  br i1 %.not1617, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph24, %.lr.ph
  %.01218 = phi ptr [ %20, %.lr.ph ], [ %13, %.lr.ph24 ]
  %14 = tail call ptr @getData(ptr noundef nonnull %.01218) #6
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %18 = load i32, ptr %17, align 8, !tbaa !12
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.30, i32 noundef %18)
  %20 = tail call ptr @getPrevious(ptr noundef nonnull %.01218) #6
  %.not16 = icmp eq ptr %20, null
  br i1 %.not16, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph24
  %.1.lcssa = phi ptr [ %.022, %.lr.ph24 ], [ %14, %.lr.ph ]
  %21 = getelementptr inbounds i8, ptr %.1.lcssa, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %24 = load i32, ptr %23, align 8, !tbaa !12
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.31, i32 noundef %24)
  %26 = tail call ptr @getNext(ptr noundef nonnull %.01420) #6
  %27 = add nuw nsw i32 %.01321, 1
  %.not = icmp eq ptr %26, null
  br i1 %.not, label %._crit_edge25, label %.lr.ph24, !llvm.loop !17

._crit_edge25:                                    ; preds = %._crit_edge, %6
  ret void
}

attributes #0 = { 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 #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 = { "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 = { 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 = !{!"edges", !11, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !11, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 16}
!13 = !{!"vertexes", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !6, i64 16}
!17 = distinct !{!17, !15}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass