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

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

@.str.1 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [54 x i8], align 1
@stderr = external global ptr, align 8
@.str.14 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [37 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

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

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

; 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 i64 @strlen(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @rcutils_get_platform_library_name(ptr noundef %0, ptr noundef %1, i32 noundef %2, i1 noundef zeroext %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca [1024 x i8], align 16
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  %14 = zext i1 %3 to i8
  store i8 %14, ptr %9, align 1, !tbaa !11
  br label %15

15:                                               ; preds = %4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp eq ptr null, %16
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  br label %19

19:                                               ; preds = %18
  call void @rcutils_set_error_state(ptr noundef @.str.14, ptr noundef @.str.1, i64 noundef 289)
  br label %20

20:                                               ; preds = %19
  store i32 11, ptr %5, align 4
  br label %89

21:                                               ; preds = %15
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = icmp eq ptr null, %24
  br i1 %25, label %26, label %29

26:                                               ; preds = %23
  br label %27

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

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

29:                                               ; preds = %23
  br label %30

30:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  %31 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %32 = trunc i8 %31 to i1
  br i1 %32, label %33, label %48

33:                                               ; preds = %30
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call i64 @strlen(ptr noundef %36) #5
  %38 = add i64 %37, 8
  %39 = icmp uge i64 %35, %38
  br i1 %39, label %40, label %47

40:                                               ; preds = %33
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = call i64 @strlen(ptr noundef %42) #5
  %44 = add i64 %43, 8
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef %41, i64 noundef %44, ptr noundef @.str.16, ptr noundef %45)
  store i32 %46, ptr %10, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %40, %33
  br label %63

48:                                               ; preds = %30
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = zext i32 %49 to i64
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = call i64 @strlen(ptr noundef %51) #5
  %53 = add i64 %52, 7
  %54 = icmp uge i64 %50, %53
  br i1 %54, label %55, label %62

55:                                               ; preds = %48
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = call i64 @strlen(ptr noundef %57) #5
  %59 = add i64 %58, 7
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef %56, i64 noundef %59, ptr noundef @.str.17, ptr noundef %60)
  store i32 %61, ptr %10, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %55, %48
  br label %63

63:                                               ; preds = %62, %47
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = icmp sle i32 %64, 0
  br i1 %65, label %66, label %87

66:                                               ; preds = %63
  br label %67

67:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 1024, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %68 = getelementptr inbounds [1024 x i8], ptr %11, i64 0, i64 0
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef %68, i64 noundef 1024, ptr noundef @.str.18, ptr noundef %69)
  store i32 %70, ptr %12, align 4, !tbaa !9
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = icmp slt i32 %71, 0
  br i1 %72, label %73, label %79

73:                                               ; preds = %67
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr @stderr, align 8, !tbaa !5
  %76 = call i64 @fwrite(ptr noundef @.str.5, i64 noundef 1, i64 noundef 53, ptr noundef %75)
  br label %77

77:                                               ; preds = %74
  br label %78

78:                                               ; preds = %77
  br label %84

79:                                               ; preds = %67
  br label %80

80:                                               ; preds = %79
  %81 = getelementptr inbounds [1024 x i8], ptr %11, i64 0, i64 0
  call void @rcutils_set_error_state(ptr noundef %81, ptr noundef @.str.1, i64 noundef 348)
  br label %82

82:                                               ; preds = %80
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %11) #4
  br label %85

85:                                               ; preds = %84
  br label %86

86:                                               ; preds = %85
  store i32 2, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %88

87:                                               ; preds = %63
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %88

88:                                               ; preds = %87, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %89

89:                                               ; preds = %88, %28, %20
  %90 = load i32, ptr %5, align 4
  ret i32 %90
}

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 }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


; 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 [67 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [54 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.14 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [37 x i8], align 1

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

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 #2

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

; 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, 12) i32 @rcutils_get_platform_library_name(ptr noundef %0, ptr noundef %1, i32 noundef %2, i1 noundef zeroext %3) local_unnamed_addr #4 {
  %5 = alloca [1024 x i8], align 16
  %6 = icmp eq ptr %0, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %4
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.1, i64 noundef 289) #5
  br label %31

8:                                                ; preds = %4
  %9 = icmp eq ptr %1, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %8
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.1, i64 noundef 290) #5
  br label %31

11:                                               ; preds = %8
  %12 = zext i32 %2 to i64
  %13 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #6
  br i1 %3, label %14, label %18

14:                                               ; preds = %11
  %15 = add i64 %13, 8
  %.not21 = icmp ugt i64 %15, %12
  br i1 %.not21, label %.thread, label %16

16:                                               ; preds = %14
  %17 = tail call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef nonnull %1, i64 noundef %15, ptr noundef nonnull @.str.16, ptr noundef nonnull %0) #5
  br label %22

18:                                               ; preds = %11
  %19 = add i64 %13, 7
  %.not = icmp ugt i64 %19, %12
  br i1 %.not, label %.thread, label %20

20:                                               ; preds = %18
  %21 = tail call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef nonnull %1, i64 noundef %19, ptr noundef nonnull @.str.17, ptr noundef nonnull %0) #5
  br label %22

22:                                               ; preds = %20, %16
  %.016 = phi i32 [ %17, %16 ], [ %21, %20 ]
  %23 = icmp slt i32 %.016, 1
  br i1 %23, label %.thread, label %31

.thread:                                          ; preds = %18, %14, %22
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %5) #5
  %24 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef nonnull %5, i64 noundef 1024, ptr noundef nonnull @.str.18, ptr noundef nonnull %0) #5
  %25 = icmp slt i32 %24, 0
  br i1 %25, label %26, label %29

26:                                               ; preds = %.thread
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i64 @fwrite(ptr noundef nonnull @.str.5, i64 noundef 1, i64 noundef 53, ptr noundef %27) #7
  br label %30

29:                                               ; preds = %.thread
  call void @rcutils_set_error_state(ptr noundef nonnull %5, ptr noundef nonnull @.str.1, i64 noundef 348) #5
  br label %30

30:                                               ; preds = %29, %26
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %5) #5
  br label %31

31:                                               ; preds = %30, %22, %10, %7
  %.1 = phi i32 [ 11, %7 ], [ 11, %10 ], [ 2, %30 ], [ 0, %22 ]
  ret i32 %.1
}

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 = { 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 #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 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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