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

; 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 }
%struct.rcutils_string_map_s = type { ptr }
%struct.rcutils_string_map_impl_s = type { ptr, i64, i64, %struct.rcutils_allocator_s }

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @rcutils_string_map_init(ptr noundef %0, i64 noundef %1, ptr noundef byval(%struct.rcutils_allocator_s) align 8 %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp eq ptr null, %10
  br i1 %11, label %12, label %15

12:                                               ; preds = %9
  br label %13

13:                                               ; preds = %12
  call void @rcutils_set_error_state(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 59)
  br label %14

14:                                               ; preds = %13
  store i32 11, ptr %4, align 4
  br label %79

15:                                               ; preds = %9
  br label %16

16:                                               ; preds = %15
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %24

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  call void @rcutils_set_error_state(ptr noundef @.str.2, ptr noundef @.str.1, i64 noundef 61)
  br label %23

23:                                               ; preds = %22
  store i32 30, ptr %4, align 4
  br label %79

24:                                               ; preds = %16
  %25 = call zeroext i1 @rcutils_allocator_is_valid(ptr noundef %2)
  br i1 %25, label %29, label %26

26:                                               ; preds = %24
  br label %27

27:                                               ; preds = %26
  call void @rcutils_set_error_state(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 65)
  br label %28

28:                                               ; preds = %27
  store i32 11, ptr %4, align 4
  br label %79

29:                                               ; preds = %24
  %30 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %2, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %2, i32 0, i32 4
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = call ptr %31(i64 noundef 64, ptr noundef %33)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %35, i32 0, i32 0
  store ptr %34, ptr %36, align 8, !tbaa !11
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = icmp eq ptr null, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %29
  br label %42

42:                                               ; preds = %41
  call void @rcutils_set_error_state(ptr noundef @.str.4, ptr noundef @.str.1, i64 noundef 68)
  br label %43

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

44:                                               ; preds = %29
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct.rcutils_string_map_impl_s, ptr %47, i32 0, i32 0
  store ptr null, ptr %48, align 8, !tbaa !16
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  %52 = getelementptr inbounds %struct.rcutils_string_map_impl_s, ptr %51, i32 0, i32 1
  store i64 0, ptr %52, align 8, !tbaa !18
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = getelementptr inbounds %struct.rcutils_string_map_impl_s, ptr %55, i32 0, i32 2
  store i64 0, ptr %56, align 8, !tbaa !19
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !11
  %60 = getelementptr inbounds %struct.rcutils_string_map_impl_s, ptr %59, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %60, ptr align 8 %2, i64 40, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = call i32 @rcutils_string_map_reserve(ptr noundef %61, i64 noundef %62)
  store i32 %63, ptr %7, align 4, !tbaa !21
  %64 = load i32, ptr %7, align 4, !tbaa !21
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %77

66:                                               ; preds = %44
  %67 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %2, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !23
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  %72 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %2, i32 0, i32 4
  %73 = load ptr, ptr %72, align 8, !tbaa !15
  call void %68(ptr noundef %71, ptr noundef %73)
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %74, i32 0, i32 0
  store ptr null, ptr %75, align 8, !tbaa !11
  %76 = load i32, ptr %7, align 4, !tbaa !21
  store i32 %76, ptr %4, align 4
  store i32 1, ptr %8, align 4
  br label %78

77:                                               ; preds = %44
  store i32 0, ptr %4, align 4
  store i32 1, ptr %8, align 4
  br label %78

78:                                               ; preds = %77, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %79

79:                                               ; preds = %78, %43, %28, %23, %14
  %80 = load i32, ptr %4, align 4
  ret i32 %80
}

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

declare zeroext i1 @rcutils_allocator_is_valid(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @rcutils_string_map_reserve(ptr noundef, i64 noundef) #1

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"rcutils_string_map_s", !6, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"rcutils_allocator_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!14, !6, i64 32}
!16 = !{!17, !6, i64 0}
!17 = !{!"rcutils_string_map_impl_s", !6, i64 0, !10, i64 8, !10, i64 16, !14, i64 24}
!18 = !{!17, !10, i64 8}
!19 = !{!17, !10, i64 16}
!20 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5}
!21 = !{!22, !22, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!14, !6, 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"

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

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @rcutils_string_map_init(ptr noundef %0, i64 noundef %1, ptr noundef byval(%struct.rcutils_allocator_s) align 8 %2) local_unnamed_addr #1 {
  %4 = icmp eq ptr %0, null
  br i1 %4, label %5, label %6

5:                                                ; preds = %3
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 59) #4
  br label %27

6:                                                ; preds = %3
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %9, label %8

8:                                                ; preds = %6
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 61) #4
  br label %27

9:                                                ; preds = %6
  %10 = call zeroext i1 @rcutils_allocator_is_valid(ptr noundef nonnull %2) #4
  br i1 %10, label %12, label %11

11:                                               ; preds = %9
  call void @rcutils_set_error_state(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i64 noundef 65) #4
  br label %27

12:                                               ; preds = %9
  %13 = load ptr, ptr %2, align 8, !tbaa !10
  %14 = getelementptr inbounds i8, ptr %2, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = call ptr %13(i64 noundef 64, ptr noundef %15) #4
  store ptr %16, ptr %0, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %12
  call void @rcutils_set_error_state(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i64 noundef 68) #4
  br label %27

19:                                               ; preds = %12
  %20 = getelementptr inbounds i8, ptr %16, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %16, i8 0, i64 24, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %20, ptr noundef nonnull align 8 dereferenceable(40) %2, i64 40, i1 false), !tbaa.struct !13
  %21 = call i32 @rcutils_string_map_reserve(ptr noundef nonnull %0, i64 noundef %1)
  %.not17 = icmp eq i32 %21, 0
  br i1 %.not17, label %27, label %22

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %2, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = load ptr, ptr %0, align 8, !tbaa !5
  %26 = load ptr, ptr %14, align 8, !tbaa !12
  call void %24(ptr noundef %25, ptr noundef %26) #4
  store ptr null, ptr %0, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %22, %19, %18, %11, %8, %5
  %.1 = phi i32 [ 11, %5 ], [ 30, %8 ], [ 10, %18 ], [ 11, %11 ], [ %21, %22 ], [ 0, %19 ]
  ret i32 %.1
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @rcutils_string_map_reserve(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !7, i64 0}
!6 = !{!"rcutils_string_map_s", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"rcutils_allocator_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!12 = !{!11, !7, i64 32}
!13 = !{i64 0, i64 8, !14, i64 8, i64 8, !14, i64 16, i64 8, !14, i64 24, i64 8, !14, i64 32, i64 8, !14}
!14 = !{!7, !7, i64 0}
!15 = !{!11, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass