; 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 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [54 x i8], align 1
@stderr = external global ptr, align 8

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 hidden void @__remove_key_and_value_at_index(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @__get_index_of_key_if_exists(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @rcutils_string_map_unset(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca [1024 x i8], align 16
  %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, ptr noundef @.str.1, i64 noundef 332)
  br label %15

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

16:                                               ; preds = %10
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = icmp eq ptr null, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %18
  br label %24

24:                                               ; preds = %23
  call void @rcutils_set_error_state(ptr noundef @.str.6, ptr noundef @.str.1, i64 noundef 334)
  br label %25

25:                                               ; preds = %24
  store i32 31, ptr %3, align 4
  br label %70

26:                                               ; preds = %18
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %5, 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.11, ptr noundef @.str.1, i64 noundef 335)
  br label %33

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

34:                                               ; preds = %28
  br label %35

35:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = call i64 @strlen(ptr noundef %40) #5
  %42 = call zeroext i1 @__get_index_of_key_if_exists(ptr noundef %38, ptr noundef %39, i64 noundef %41, ptr noundef %6)
  br i1 %42, label %64, label %43

43:                                               ; preds = %35
  br label %44

44:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 1024, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %45 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef %45, i64 noundef 1024, ptr noundef @.str.17, ptr noundef %46)
  store i32 %47, ptr %8, align 4, !tbaa !11
  %48 = load i32, ptr %8, align 4, !tbaa !11
  %49 = icmp slt i32 %48, 0
  br i1 %49, label %50, label %56

50:                                               ; preds = %44
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = call i64 @fwrite(ptr noundef @.str.18, i64 noundef 1, i64 noundef 53, ptr noundef %52)
  br label %54

54:                                               ; preds = %51
  br label %55

55:                                               ; preds = %54
  br label %61

56:                                               ; preds = %44
  br label %57

57:                                               ; preds = %56
  %58 = getelementptr inbounds [1024 x i8], ptr %7, i64 0, i64 0
  call void @rcutils_set_error_state(ptr noundef %58, ptr noundef @.str.1, i64 noundef 338)
  br label %59

59:                                               ; preds = %57
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %7) #4
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  store i32 32, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %69

64:                                               ; preds = %35
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.rcutils_string_map_s, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !9
  %68 = load i64, ptr %6, align 8, !tbaa !13
  call void @__remove_key_and_value_at_index(ptr noundef %67, i64 noundef %68)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %69

69:                                               ; preds = %64, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %70

70:                                               ; preds = %69, %33, %25, %15
  %71 = load i32, ptr %3, align 4
  ret i32 %71
}

declare i32 @rcutils_snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #0

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #0

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 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 #4 = { nounwind }
attributes #5 = { 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, !6, i64 0}
!10 = !{!"rcutils_string_map_s", !6, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}


; 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 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [54 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @__remove_key_and_value_at_index(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @__get_index_of_key_if_exists(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 33) i32 @rcutils_string_map_unset(ptr noundef readonly %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca i64, align 8
  %4 = alloca [1024 x i8], align 16
  %5 = icmp eq ptr %0, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 332) #5
  br label %29

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

10:                                               ; preds = %7
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i64 noundef 334) #5
  br label %29

11:                                               ; preds = %7
  %12 = icmp eq ptr %1, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %11
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i64 noundef 335) #5
  br label %29

14:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %15 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #6
  %16 = call zeroext i1 @__get_index_of_key_if_exists(ptr noundef nonnull %8, ptr noundef nonnull %1, i64 noundef %15, ptr noundef nonnull %3)
  br i1 %16, label %25, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %4) #5
  %18 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef nonnull %4, i64 noundef 1024, ptr noundef nonnull @.str.17, ptr noundef nonnull %1) #5
  %19 = icmp slt i32 %18, 0
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load ptr, ptr @stderr, align 8, !tbaa !10
  %22 = call i64 @fwrite(ptr noundef nonnull @.str.18, i64 noundef 1, i64 noundef 53, ptr noundef %21) #7
  br label %24

23:                                               ; preds = %17
  call void @rcutils_set_error_state(ptr noundef nonnull %4, ptr noundef nonnull @.str.1, i64 noundef 338) #5
  br label %24

24:                                               ; preds = %23, %20
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %4) #5
  br label %28

25:                                               ; preds = %14
  %26 = load ptr, ptr %0, align 8, !tbaa !5
  %27 = load i64, ptr %3, align 8, !tbaa !11
  call void @__remove_key_and_value_at_index(ptr noundef %26, i64 noundef %27)
  br label %28

28:                                               ; preds = %25, %24
  %.0 = phi i32 [ 0, %25 ], [ 32, %24 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br label %29

29:                                               ; preds = %28, %13, %10, %6
  %.1 = phi i32 [ 11, %6 ], [ 31, %10 ], [ 11, %13 ], [ %.0, %28 ]
  ret i32 %.1
}

declare i32 @rcutils_snprintf(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #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 = { mustprogress 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 = { 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 #4 = { nofree nounwind "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(read) }
attributes #7 = { cold }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass