; LLVM IR from maliput/maliput :: src/maliput/api (basic_id_index)

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7maliput3api12BasicIdIndex7AddLaneEPKNS0_4LaneE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) #0 align 2

; 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 @_ZN7maliput3api12BasicIdIndex10AddSegmentEPKNS0_7SegmentE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7maliput3api12BasicIdIndex11AddJunctionEPKNS0_8JunctionE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7maliput3api12BasicIdIndex14AddBranchPointEPKNS0_11BranchPointE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7maliput3api12BasicIdIndex13WalkAndAddAllEPKNS0_12RoadGeometryE(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %53, %2
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call noundef i32 @_ZNK7maliput3api12RoadGeometry13num_junctionsEv(ptr noundef nonnull align 8 dereferenceable(8) %15)
  %17 = icmp slt i32 %14, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %13
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %56

19:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = call noundef ptr @_ZNK7maliput3api12RoadGeometry8junctionEi(ptr noundef nonnull align 8 dereferenceable(8) %20, i32 noundef %21)
  store ptr %22, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN7maliput3api12BasicIdIndex11AddJunctionEPKNS0_8JunctionE(ptr noundef nonnull align 8 dereferenceable(232) %12, ptr noundef %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %49, %19
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call noundef i32 @_ZNK7maliput3api8Junction12num_segmentsEv(ptr noundef nonnull align 8 dereferenceable(8) %26)
  %28 = icmp slt i32 %25, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %52

30:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = call noundef ptr @_ZNK7maliput3api8Junction7segmentEi(ptr noundef nonnull align 8 dereferenceable(8) %31, i32 noundef %32)
  store ptr %33, ptr %9, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN7maliput3api12BasicIdIndex10AddSegmentEPKNS0_7SegmentE(ptr noundef nonnull align 8 dereferenceable(232) %12, ptr noundef %34)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %45, %30
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = call noundef i32 @_ZNK7maliput3api7Segment9num_lanesEv(ptr noundef nonnull align 8 dereferenceable(8) %37)
  %39 = icmp slt i32 %36, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %48

41:                                               ; preds = %35
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = call noundef ptr @_ZNK7maliput3api7Segment4laneEi(ptr noundef nonnull align 8 dereferenceable(8) %42, i32 noundef %43)
  call void @_ZN7maliput3api12BasicIdIndex7AddLaneEPKNS0_4LaneE(ptr noundef nonnull align 8 dereferenceable(232) %12, ptr noundef %44)
  br label %45

45:                                               ; preds = %41
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %10, align 4, !tbaa !9
  br label %35, !llvm.loop !11

48:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %8, align 4, !tbaa !9
  br label %24, !llvm.loop !13

52:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %5, align 4, !tbaa !9
  br label %13, !llvm.loop !14

56:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %67, %56
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = call noundef i32 @_ZNK7maliput3api12RoadGeometry17num_branch_pointsEv(ptr noundef nonnull align 8 dereferenceable(8) %59)
  %61 = icmp slt i32 %58, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %57
  store i32 11, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %70

63:                                               ; preds = %57
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = call noundef ptr @_ZNK7maliput3api12RoadGeometry12branch_pointEi(ptr noundef nonnull align 8 dereferenceable(8) %64, i32 noundef %65)
  call void @_ZN7maliput3api12BasicIdIndex14AddBranchPointEPKNS0_11BranchPointE(ptr noundef nonnull align 8 dereferenceable(232) %12, ptr noundef %66)
  br label %67

67:                                               ; preds = %63
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %11, align 4, !tbaa !9
  br label %57, !llvm.loop !15

70:                                               ; preds = %62
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7maliput3api12RoadGeometry13num_junctionsEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7maliput3api12RoadGeometry8junctionEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7maliput3api8Junction12num_segmentsEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7maliput3api8Junction7segmentEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7maliput3api7Segment9num_lanesEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7maliput3api7Segment4laneEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7maliput3api12RoadGeometry17num_branch_pointsEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7maliput3api12RoadGeometry12branch_pointEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #0 align 2

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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


; 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 void @_ZN7maliput3api12BasicIdIndex7AddLaneEPKNS0_4LaneE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7maliput3api12BasicIdIndex10AddSegmentEPKNS0_7SegmentE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7maliput3api12BasicIdIndex11AddJunctionEPKNS0_8JunctionE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7maliput3api12BasicIdIndex14AddBranchPointEPKNS0_11BranchPointE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7maliput3api12BasicIdIndex13WalkAndAddAllEPKNS0_12RoadGeometryE(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef nonnull %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i32 @_ZNK7maliput3api12RoadGeometry13num_junctionsEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph32, label %.preheader

.preheader:                                       ; preds = %._crit_edge29, %2
  %5 = tail call noundef i32 @_ZNK7maliput3api12RoadGeometry17num_branch_pointsEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph34, label %._crit_edge35

.lr.ph32:                                         ; preds = %2, %._crit_edge29
  %.02330 = phi i32 [ %10, %._crit_edge29 ], [ 0, %2 ]
  %7 = tail call noundef ptr @_ZNK7maliput3api12RoadGeometry8junctionEi(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %.02330)
  tail call void @_ZN7maliput3api12BasicIdIndex11AddJunctionEPKNS0_8JunctionE(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef %7)
  %8 = tail call noundef i32 @_ZNK7maliput3api8Junction12num_segmentsEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph28, label %._crit_edge29

._crit_edge29:                                    ; preds = %._crit_edge, %.lr.ph32
  %10 = add nuw nsw i32 %.02330, 1
  %11 = tail call noundef i32 @_ZNK7maliput3api12RoadGeometry13num_junctionsEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %.lr.ph32, label %.preheader, !llvm.loop !5

.lr.ph28:                                         ; preds = %.lr.ph32, %._crit_edge
  %.02426 = phi i32 [ %16, %._crit_edge ], [ 0, %.lr.ph32 ]
  %13 = tail call noundef ptr @_ZNK7maliput3api8Junction7segmentEi(ptr noundef nonnull align 8 dereferenceable(8) %7, i32 noundef %.02426)
  tail call void @_ZN7maliput3api12BasicIdIndex10AddSegmentEPKNS0_7SegmentE(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef %13)
  %14 = tail call noundef i32 @_ZNK7maliput3api7Segment9num_lanesEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph28
  %16 = add nuw nsw i32 %.02426, 1
  %17 = tail call noundef i32 @_ZNK7maliput3api8Junction12num_segmentsEv(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %.lr.ph28, label %._crit_edge29, !llvm.loop !7

.lr.ph:                                           ; preds = %.lr.ph28, %.lr.ph
  %.02225 = phi i32 [ %20, %.lr.ph ], [ 0, %.lr.ph28 ]
  %19 = tail call noundef ptr @_ZNK7maliput3api7Segment4laneEi(ptr noundef nonnull align 8 dereferenceable(8) %13, i32 noundef %.02225)
  tail call void @_ZN7maliput3api12BasicIdIndex7AddLaneEPKNS0_4LaneE(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef %19)
  %20 = add nuw nsw i32 %.02225, 1
  %21 = tail call noundef i32 @_ZNK7maliput3api7Segment9num_lanesEv(ptr noundef nonnull align 8 dereferenceable(8) %13)
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !8

._crit_edge35:                                    ; preds = %.lr.ph34, %.preheader
  ret void

.lr.ph34:                                         ; preds = %.preheader, %.lr.ph34
  %.033 = phi i32 [ %24, %.lr.ph34 ], [ 0, %.preheader ]
  %23 = tail call noundef ptr @_ZNK7maliput3api12RoadGeometry12branch_pointEi(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %.033)
  tail call void @_ZN7maliput3api12BasicIdIndex14AddBranchPointEPKNS0_11BranchPointE(ptr noundef nonnull align 8 dereferenceable(232) %0, ptr noundef %23)
  %24 = add nuw nsw i32 %.033, 1
  %25 = tail call noundef i32 @_ZNK7maliput3api12RoadGeometry17num_branch_pointsEv(ptr noundef nonnull align 8 dereferenceable(8) %1)
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %.lr.ph34, label %._crit_edge35, !llvm.loop !9
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7maliput3api12RoadGeometry13num_junctionsEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7maliput3api12RoadGeometry8junctionEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7maliput3api8Junction12num_segmentsEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7maliput3api8Junction7segmentEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7maliput3api7Segment9num_lanesEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7maliput3api7Segment4laneEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7maliput3api12RoadGeometry17num_branch_pointsEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK7maliput3api12RoadGeometry12branch_pointEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0 align 2

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

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}
!9 = distinct !{!9, !6}


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