; LLVM IR from maliput/maliput :: src/maliput/api/rules/traffic_lights.ll (ZNK7maliput3api5rules4Bulb15GetDefaultStateEv)

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

%"class.std::initializer_list" = type { ptr, i64 }

@.str.9 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [1 x i8], align 1
@__func__._ZNK7maliput3api5rules4Bulb15GetDefaultStateEv = external hidden unnamed_addr constant [16 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7maliput3api5rules4Bulb15GetDefaultStateEv(ptr noundef nonnull align 8 dereferenceable(192) %0) #1 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.std::initializer_list", align 8
  %6 = alloca [3 x i32], align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  %12 = getelementptr inbounds i32, ptr %6, i64 1
  store i32 2, ptr %12, align 4, !tbaa !9
  %13 = getelementptr inbounds i32, ptr %6, i64 2
  store i32 1, ptr %13, align 4, !tbaa !9
  %14 = getelementptr inbounds %"class.std::initializer_list", ptr %5, i32 0, i32 0
  store ptr %6, ptr %14, align 8, !tbaa !11
  %15 = getelementptr inbounds %"class.std::initializer_list", ptr %5, i32 0, i32 1
  store i64 3, ptr %15, align 8, !tbaa !14
  store ptr %5, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef ptr @_ZNKSt16initializer_listIN7maliput3api5rules9BulbStateEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %16) #4
  store ptr %17, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNKSt16initializer_listIN7maliput3api5rules9BulbStateEE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %18) #4
  store ptr %19, ptr %8, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %36, %1
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = icmp ne ptr %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 2, ptr %9, align 4
  br label %39

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %26, ptr %10, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = call noundef zeroext i1 @_ZNK7maliput3api5rules4Bulb12IsValidStateERKNS1_9BulbStateE(ptr noundef nonnull align 8 dereferenceable(192) %11, ptr noundef nonnull align 4 dereferenceable(4) %27)
  br i1 %28, label %29, label %32

29:                                               ; preds = %25
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = load i32, ptr %30, align 4, !tbaa !9
  store i32 %31, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %33

32:                                               ; preds = %25
  store i32 0, ptr %9, align 4
  br label %33

33:                                               ; preds = %32, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %34 = load i32, ptr %9, align 4
  switch i32 %34, label %39 [
    i32 0, label %35
  ]

35:                                               ; preds = %33
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds i32, ptr %37, i32 1
  store ptr %38, ptr %7, align 8, !tbaa !5
  br label %20

39:                                               ; preds = %33, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %40 = load i32, ptr %9, align 4
  switch i32 %40, label %46 [
    i32 2, label %41
    i32 1, label %44
  ]

41:                                               ; preds = %39
  br label %42

42:                                               ; preds = %41
  call void @_ZN7maliput6common8internal5AbortEPKcS3_S3_iS3_(ptr noundef @.str.11, ptr noundef @__func__._ZNK7maliput3api5rules4Bulb15GetDefaultStateEv, ptr noundef @.str.9, i32 noundef 92, ptr noundef @.str.12) #5
  unreachable

43:                                               ; No predecessors!
  unreachable

44:                                               ; preds = %39
  %45 = load i32, ptr %2, align 4
  ret i32 %45

46:                                               ; preds = %39
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIN7maliput3api5rules9BulbStateEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIN7maliput3api5rules9BulbStateEE3endEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7maliput3api5rules4Bulb12IsValidStateERKNS1_9BulbStateE(ptr noundef nonnull align 8 dereferenceable(192), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

; Function Attrs: noreturn
declare void @_ZN7maliput6common8internal5AbortEPKcS3_S3_iS3_(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

!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 = !{!"_ZTSN7maliput3api5rules9BulbStateE", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSSt16initializer_listIN7maliput3api5rules9BulbStateEE", !6, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, 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"

%"class.std::initializer_list" = type { ptr, i64 }

@.str.9 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [1 x i8], align 1
@__func__._ZNK7maliput3api5rules4Bulb15GetDefaultStateEv = external hidden unnamed_addr constant [16 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [27 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7maliput3api5rules4Bulb15GetDefaultStateEv(ptr noundef nonnull align 8 dereferenceable(192) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"class.std::initializer_list", align 8
  %3 = alloca [3 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 2, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 1, ptr %5, align 4, !tbaa !5
  store ptr %3, ptr %2, align 8, !tbaa !9
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  store i64 3, ptr %6, align 8, !tbaa !13
  %7 = call noundef ptr @_ZNKSt16initializer_listIN7maliput3api5rules9BulbStateEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  %8 = call noundef ptr @_ZNKSt16initializer_listIN7maliput3api5rules9BulbStateEE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %2) #4
  %.not21 = icmp eq ptr %7, %8
  br i1 %.not21, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %10
  %.01322 = phi ptr [ %11, %10 ], [ %7, %1 ]
  %9 = call noundef zeroext i1 @_ZNK7maliput3api5rules4Bulb12IsValidStateERKNS1_9BulbStateE(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr noundef nonnull align 4 dereferenceable(4) %.01322)
  br i1 %9, label %12, label %10

10:                                               ; preds = %.lr.ph
  %11 = getelementptr inbounds i8, ptr %.01322, i64 4
  %.not = icmp eq ptr %11, %8
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %10, %1
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  call void @_ZN7maliput6common8internal5AbortEPKcS3_S3_iS3_(ptr noundef nonnull @.str.11, ptr noundef nonnull @__func__._ZNK7maliput3api5rules4Bulb15GetDefaultStateEv, ptr noundef nonnull @.str.9, i32 noundef 92, ptr noundef nonnull @.str.12) #5
  unreachable

12:                                               ; preds = %.lr.ph
  %13 = load i32, ptr %.01322, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  ret i32 %13
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIN7maliput3api5rules9BulbStateEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIN7maliput3api5rules9BulbStateEE3endEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7maliput3api5rules4Bulb12IsValidStateERKNS1_9BulbStateE(ptr noundef nonnull align 8 dereferenceable(192), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: noreturn
declare void @_ZN7maliput6common8internal5AbortEPKcS3_S3_iS3_(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

!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 = !{!"_ZTSN7maliput3api5rules9BulbStateE", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSSt16initializer_listIN7maliput3api5rules9BulbStateEE", !11, i64 0, !12, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 8}


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