; 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_string_map_s = type { ptr }

@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [53 x i8], align 1

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 uwtable
declare dso_local i32 @rcutils_string_map_set(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @rcutils_string_map_get(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @rcutils_string_map_get_next_key(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @rcutils_string_map_copy(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp eq ptr null, %11
  br i1 %12, label %13, label %16

13:                                               ; preds = %10
  br label %14

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

15:                                               ; preds = %14
  store i32 11, ptr %3, align 4
  br label %80

16:                                               ; preds = %10
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp eq ptr null, %19
  br i1 %20, label %21, label %24

21:                                               ; preds = %18
  br label %22

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

23:                                               ; preds = %22
  store i32 11, ptr %3, align 4
  br label %80

24:                                               ; preds = %18
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = icmp eq ptr null, %29
  br i1 %30, label %31, label %34

31:                                               ; preds = %26
  br label %32

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

33:                                               ; preds = %32
  store i32 31, ptr %3, align 4
  br label %80

34:                                               ; preds = %26
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %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 !9
  %40 = icmp eq ptr null, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %36
  br label %42

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

43:                                               ; preds = %42
  store i32 31, ptr %3, align 4
  br label %80

44:                                               ; preds = %36
  br label %45

45:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = call ptr @rcutils_string_map_get_next_key(ptr noundef %46, ptr noundef null)
  store ptr %47, ptr %6, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %77, %45
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %51, label %78

51:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = call ptr @rcutils_string_map_get(ptr noundef %52, ptr noundef %53)
  store ptr %54, ptr %7, align 8, !tbaa !5
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = icmp eq ptr null, %55
  br i1 %56, label %57, label %61

57:                                               ; preds = %51
  br label %58

58:                                               ; preds = %57
  call void @rcutils_set_error_state(ptr noundef @.str.23, ptr noundef @.str.1, i64 noundef 449)
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  store i32 2, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %75

61:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = call i32 @rcutils_string_map_set(ptr noundef %62, ptr noundef %63, ptr noundef %64)
  store i32 %65, ptr %9, align 4, !tbaa !11
  %66 = load i32, ptr %9, align 4, !tbaa !11
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %61
  %69 = load i32, ptr %9, align 4, !tbaa !11
  store i32 %69, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %74

70:                                               ; preds = %61
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = call ptr @rcutils_string_map_get_next_key(ptr noundef %71, ptr noundef %72)
  store ptr %73, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %8, align 4
  br label %74

74:                                               ; preds = %70, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %75

75:                                               ; preds = %74, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %76 = load i32, ptr %8, align 4
  switch i32 %76, label %79 [
    i32 0, label %77
  ]

77:                                               ; preds = %75
  br label %48, !llvm.loop !13

78:                                               ; preds = %48
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %79

79:                                               ; preds = %78, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %80

80:                                               ; preds = %79, %43, %33, %23, %15
  %81 = load i32, ptr %3, align 4
  ret i32 %81
}

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


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

@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [53 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @rcutils_string_map_copy(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %4, label %5

4:                                                ; preds = %2
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, i64 noundef 438) #2
  br label %.thread

5:                                                ; preds = %2
  %6 = icmp eq ptr %1, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %5
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.1, i64 noundef 439) #2
  br label %.thread

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

11:                                               ; preds = %8
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.1, i64 noundef 441) #2
  br label %.thread

12:                                               ; preds = %8
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, i64 noundef 444) #2
  br label %.thread

16:                                               ; preds = %12
  %17 = tail call ptr @rcutils_string_map_get_next_key(ptr noundef nonnull %0, ptr noundef null)
  %.not31 = icmp eq ptr %17, null
  br i1 %.not31, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %16, %23
  %.01932 = phi ptr [ %24, %23 ], [ %17, %16 ]
  %18 = tail call ptr @rcutils_string_map_get(ptr noundef nonnull %0, ptr noundef nonnull %.01932)
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %.lr.ph
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.1, i64 noundef 449) #2
  br label %.thread

21:                                               ; preds = %.lr.ph
  %22 = tail call i32 @rcutils_string_map_set(ptr noundef nonnull %1, ptr noundef nonnull %.01932, ptr noundef nonnull %18)
  %.not26 = icmp eq i32 %22, 0
  br i1 %.not26, label %23, label %.thread

23:                                               ; preds = %21
  %24 = tail call ptr @rcutils_string_map_get_next_key(ptr noundef nonnull %0, ptr noundef nonnull %.01932)
  %.not = icmp eq ptr %24, null
  br i1 %.not, label %.thread, label %.lr.ph, !llvm.loop !10

.thread:                                          ; preds = %23, %21, %16, %20, %15, %11, %7, %4
  %.4 = phi i32 [ 11, %4 ], [ 11, %7 ], [ 31, %11 ], [ 31, %15 ], [ 2, %20 ], [ 0, %16 ], [ 0, %23 ], [ %22, %21 ]
  ret i32 %.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 = { 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 = { 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 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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