; LLVM IR from ros2/rcutils :: src (logging)

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

@g_rcutils_log_severity_names = external dso_local constant [51 x ptr], align 16
@.str.7 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [47 x i8], align 1

declare zeroext i1 @rcutils_allocator_is_valid(ptr noundef) #0

declare void @rcutils_set_error_state(ptr noundef, ptr noundef, i64 noundef) #0

; 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: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @rcutils_logging_severity_level_from_string(ptr noundef %0, ptr noundef byval(%struct.rcutils_allocator_s) align 8 %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %15 = call zeroext i1 @rcutils_allocator_is_valid(ptr noundef %1)
  br i1 %15, label %19, label %16

16:                                               ; preds = %3
  br label %17

17:                                               ; preds = %16
  call void @rcutils_set_error_state(ptr noundef @.str.29, ptr noundef @.str.7, i64 noundef 820)
  br label %18

18:                                               ; preds = %17
  store i32 11, ptr %4, align 4
  br label %111

19:                                               ; preds = %3
  br label %20

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

23:                                               ; preds = %20
  br label %24

24:                                               ; preds = %23
  call void @rcutils_set_error_state(ptr noundef @.str.30, ptr noundef @.str.7, i64 noundef 821)
  br label %25

25:                                               ; preds = %24
  store i32 11, ptr %4, align 4
  br label %111

26:                                               ; preds = %20
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = icmp eq ptr null, %29
  br i1 %30, label %31, label %34

31:                                               ; preds = %28
  br label %32

32:                                               ; preds = %31
  call void @rcutils_set_error_state(ptr noundef @.str.31, ptr noundef @.str.7, i64 noundef 822)
  br label %33

33:                                               ; preds = %32
  store i32 11, ptr %4, align 4
  br label %111

34:                                               ; preds = %28
  br label %35

35:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 41, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = call ptr @rcutils_strdup(ptr noundef %36, ptr noundef byval(%struct.rcutils_allocator_s) align 8 %1)
  store ptr %37, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = icmp eq ptr null, %38
  br i1 %39, label %40, label %44

40:                                               ; preds = %35
  br label %41

41:                                               ; preds = %40
  call void @rcutils_set_error_state(ptr noundef @.str.32, ptr noundef @.str.7, i64 noundef 829)
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  store i32 10, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %110

44:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %72, %44
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %46, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = icmp ne i8 %50, 0
  br i1 %51, label %53, label %52

52:                                               ; preds = %45
  store i32 14, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %75

53:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %54 = call ptr @__ctype_toupper_loc() #6
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %56, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = sext i8 %60 to i32
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i32, ptr %55, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  store i32 %64, ptr %11, align 4, !tbaa !9
  %65 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %65, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %66 = load i32, ptr %12, align 4, !tbaa !9
  %67 = trunc i32 %66 to i8
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds i8, ptr %68, i64 %70
  store i8 %67, ptr %71, align 1, !tbaa !11
  br label %72

72:                                               ; preds = %53
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %10, align 4, !tbaa !9
  br label %45, !llvm.loop !12

75:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store i64 0, ptr %13, align 8, !tbaa !14
  br label %76

76:                                               ; preds = %99, %75
  %77 = load i64, ptr %13, align 8, !tbaa !14
  %78 = icmp ult i64 %77, 51
  br i1 %78, label %80, label %79

79:                                               ; preds = %76
  store i32 17, ptr %9, align 4
  br label %102

80:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %81 = load i64, ptr %13, align 8, !tbaa !14
  %82 = getelementptr inbounds [51 x ptr], ptr @g_rcutils_log_severity_names, i64 0, i64 %81
  %83 = load ptr, ptr %82, align 8, !tbaa !5
  store ptr %83, ptr %14, align 8, !tbaa !5
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = icmp ne ptr %84, null
  br i1 %85, label %86, label %95

86:                                               ; preds = %80
  %87 = load ptr, ptr %14, align 8, !tbaa !5
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = call i32 @strcmp(ptr noundef %87, ptr noundef %88) #7
  %90 = icmp eq i32 %89, 0
  br i1 %90, label %91, label %95

91:                                               ; preds = %86
  %92 = load i64, ptr %13, align 8, !tbaa !14
  %93 = trunc i64 %92 to i32
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %93, ptr %94, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 17, ptr %9, align 4
  br label %96

95:                                               ; preds = %86, %80
  store i32 0, ptr %9, align 4
  br label %96

96:                                               ; preds = %95, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  %97 = load i32, ptr %9, align 4
  switch i32 %97, label %102 [
    i32 0, label %98
  ]

98:                                               ; preds = %96
  br label %99

99:                                               ; preds = %98
  %100 = load i64, ptr %13, align 8, !tbaa !14
  %101 = add i64 %100, 1
  store i64 %101, ptr %13, align 8, !tbaa !14
  br label %76, !llvm.loop !16

102:                                              ; preds = %96, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %103

103:                                              ; preds = %102
  %104 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %1, i32 0, i32 1
  %105 = load ptr, ptr %104, align 8, !tbaa !17
  %106 = load ptr, ptr %8, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %1, i32 0, i32 4
  %108 = load ptr, ptr %107, align 8, !tbaa !19
  call void %105(ptr noundef %106, ptr noundef %108)
  %109 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %109, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %110

110:                                              ; preds = %103, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %111

111:                                              ; preds = %110, %33, %25, %18
  %112 = load i32, ptr %4, align 4
  ret i32 %112
}

declare ptr @rcutils_strdup(ptr noundef, ptr noundef byval(%struct.rcutils_allocator_s) align 8) #0

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_toupper_loc() #4

attributes #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 willreturn memory(read) "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 = { nounwind willreturn memory(none) "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 = { nounwind willreturn memory(none) }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !13}
!17 = !{!18, !6, i64 8}
!18 = !{!"rcutils_allocator_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!19 = !{!18, !6, i64 32}


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

%struct.rcutils_allocator_s = type { ptr, ptr, ptr, ptr, ptr }

@g_rcutils_log_severity_names = external dso_local local_unnamed_addr constant [51 x ptr], align 16
@.str.7 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [47 x i8], align 1

declare zeroext i1 @rcutils_allocator_is_valid(ptr noundef) local_unnamed_addr #0

declare void @rcutils_set_error_state(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 42) i32 @rcutils_logging_severity_level_from_string(ptr noundef %0, ptr noundef byval(%struct.rcutils_allocator_s) align 8 %1, ptr noundef writeonly %2) local_unnamed_addr #2 {
  %4 = call zeroext i1 @rcutils_allocator_is_valid(ptr noundef nonnull %1) #4
  br i1 %4, label %6, label %5

5:                                                ; preds = %3
  call void @rcutils_set_error_state(ptr noundef nonnull @.str.29, ptr noundef nonnull @.str.7, i64 noundef 820) #4
  br label %41

6:                                                ; preds = %3
  %7 = icmp eq ptr %0, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %6
  call void @rcutils_set_error_state(ptr noundef nonnull @.str.30, ptr noundef nonnull @.str.7, i64 noundef 821) #4
  br label %41

9:                                                ; preds = %6
  %10 = icmp eq ptr %2, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %9
  call void @rcutils_set_error_state(ptr noundef nonnull @.str.31, ptr noundef nonnull @.str.7, i64 noundef 822) #4
  br label %41

12:                                               ; preds = %9
  %13 = call ptr @rcutils_strdup(ptr noundef nonnull %0, ptr noundef nonnull byval(%struct.rcutils_allocator_s) align 8 %1) #4
  %14 = icmp eq ptr %13, null
  br i1 %14, label %17, label %.preheader38

.preheader38:                                     ; preds = %12
  %15 = load i8, ptr %13, align 1, !tbaa !5
  %.not40 = icmp eq i8 %15, 0
  br i1 %.not40, label %.preheader.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader38
  %16 = tail call ptr @__ctype_toupper_loc() #5
  br label %18

17:                                               ; preds = %12
  call void @rcutils_set_error_state(ptr noundef nonnull @.str.32, ptr noundef nonnull @.str.7, i64 noundef 829) #4
  br label %41

18:                                               ; preds = %.lr.ph, %18
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %18 ]
  %19 = phi i8 [ %15, %.lr.ph ], [ %27, %18 ]
  %20 = getelementptr inbounds i8, ptr %13, i64 %indvars.iv
  %21 = load ptr, ptr %16, align 8, !tbaa !8
  %22 = sext i8 %19 to i64
  %23 = getelementptr inbounds i32, ptr %21, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !10
  %25 = trunc i32 %24 to i8
  store i8 %25, ptr %20, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = getelementptr inbounds i8, ptr %13, i64 %indvars.iv.next
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %.not = icmp eq i8 %27, 0
  br i1 %.not, label %.preheader.preheader, label %18, !llvm.loop !12

.preheader.preheader:                             ; preds = %18, %.preheader38
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %35
  %.02442 = phi i64 [ %36, %35 ], [ 0, %.preheader.preheader ]
  %28 = getelementptr inbounds [51 x ptr], ptr @g_rcutils_log_severity_names, i64 0, i64 %.02442
  %29 = load ptr, ptr %28, align 8, !tbaa !8
  %.not34 = icmp eq ptr %29, null
  br i1 %.not34, label %35, label %30

30:                                               ; preds = %.preheader
  %31 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %29, ptr noundef nonnull dereferenceable(1) %13) #6
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %30
  %34 = trunc nuw nsw i64 %.02442 to i32
  store i32 %34, ptr %2, align 4, !tbaa !10
  br label %.loopexit

35:                                               ; preds = %30, %.preheader
  %36 = add nuw nsw i64 %.02442, 1
  %exitcond.not = icmp eq i64 %36, 51
  br i1 %exitcond.not, label %.loopexit, label %.preheader, !llvm.loop !14

.loopexit:                                        ; preds = %35, %33
  %.2 = phi i32 [ 0, %33 ], [ 41, %35 ]
  %37 = getelementptr inbounds i8, ptr %1, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds i8, ptr %1, i64 32
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  call void %38(ptr noundef nonnull %13, ptr noundef %40) #4
  br label %41

41:                                               ; preds = %17, %.loopexit, %11, %8, %5
  %.1 = phi i32 [ 11, %8 ], [ 11, %11 ], [ 11, %5 ], [ 10, %17 ], [ %.2, %.loopexit ]
  ret i32 %.1
}

declare ptr @rcutils_strdup(ptr noundef, ptr noundef byval(%struct.rcutils_allocator_s) align 8) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_toupper_loc() local_unnamed_addr #3

attributes #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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { nounwind willreturn memory(none) }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!16, !9, i64 8}
!16 = !{!"rcutils_allocator_s", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32}
!17 = !{!16, !9, i64 32}


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