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

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

@.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.8 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 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

; Function Attrs: nounwind
declare ptr @dlerror() #2

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 uwtable
define dso_local ptr @rcutils_get_symbol(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [1024 x i8], align 16
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca [1024 x i8], align 16
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %23

15:                                               ; preds = %2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.rcutils_shared_library_s, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %23

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

23:                                               ; preds = %20, %15, %2
  br label %24

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

25:                                               ; preds = %24
  store ptr null, ptr %3, align 8
  br label %87

26:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.rcutils_shared_library_s, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call ptr @dlsym(ptr noundef %29, ptr noundef %30) #4
  store ptr %31, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %32 = call ptr @dlerror() #4
  store ptr %32, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %57

35:                                               ; preds = %26
  br label %36

36:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 1024, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %37 = getelementptr inbounds [1024 x i8], ptr %8, i64 0, i64 0
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef %37, i64 noundef 1024, ptr noundef @.str.9, ptr noundef %38, ptr noundef %39)
  store i32 %40, ptr %9, align 4, !tbaa !12
  %41 = load i32, ptr %9, align 4, !tbaa !12
  %42 = icmp slt i32 %41, 0
  br i1 %42, label %43, label %49

43:                                               ; preds = %36
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = call i64 @fwrite(ptr noundef @.str.5, i64 noundef 1, i64 noundef 53, ptr noundef %45)
  br label %47

47:                                               ; preds = %44
  br label %48

48:                                               ; preds = %47
  br label %54

49:                                               ; preds = %36
  br label %50

50:                                               ; preds = %49
  %51 = getelementptr inbounds [1024 x i8], ptr %8, i64 0, i64 0
  call void @rcutils_set_error_state(ptr noundef %51, ptr noundef @.str.1, i64 noundef 211)
  br label %52

52:                                               ; preds = %50
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %8) #4
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %86

57:                                               ; preds = %26
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = icmp ne ptr %58, null
  br i1 %59, label %84, label %60

60:                                               ; preds = %57
  br label %61

61:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 1024, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %62 = getelementptr inbounds [1024 x i8], ptr %11, i64 0, i64 0
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.rcutils_shared_library_s, ptr %64, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef %62, i64 noundef 1024, ptr noundef @.str.10, ptr noundef %63, ptr noundef %66)
  store i32 %67, ptr %12, align 4, !tbaa !12
  %68 = load i32, ptr %12, align 4, !tbaa !12
  %69 = icmp slt i32 %68, 0
  br i1 %69, label %70, label %76

70:                                               ; preds = %61
  br label %71

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

74:                                               ; preds = %71
  br label %75

75:                                               ; preds = %74
  br label %81

76:                                               ; preds = %61
  br label %77

77:                                               ; preds = %76
  %78 = getelementptr inbounds [1024 x i8], ptr %11, i64 0, i64 0
  call void @rcutils_set_error_state(ptr noundef %78, ptr noundef @.str.1, i64 noundef 226)
  br label %79

79:                                               ; preds = %77
  br label %80

80:                                               ; preds = %79
  br label %81

81:                                               ; preds = %80, %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %11) #4
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %86

84:                                               ; preds = %57
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %85, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %86

86:                                               ; preds = %84, %83, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %87

87:                                               ; preds = %86, %25
  %88 = load ptr, ptr %3, align 8
  ret ptr %88
}

; Function Attrs: nounwind
declare ptr @dlsym(ptr noundef, ptr noundef) #2

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

!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_shared_library_s", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"rcutils_allocator_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !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"

@.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.8 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 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: nounwind
declare ptr @dlerror() local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

; 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
define dso_local ptr @rcutils_get_symbol(ptr noundef readonly %0, ptr noundef %1) local_unnamed_addr #4 {
  %3 = alloca [1024 x i8], align 16
  %4 = alloca [1024 x i8], align 16
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %9, label %5

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

9:                                                ; preds = %2, %5
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i64 noundef 201) #5
  br label %32

10:                                               ; preds = %5
  %11 = tail call ptr @dlsym(ptr noundef nonnull %6, ptr noundef nonnull %1) #5
  %12 = tail call ptr @dlerror() #5
  %.not20 = icmp eq ptr %12, null
  br i1 %.not20, label %21, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %3) #5
  %14 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef nonnull %3, i64 noundef 1024, ptr noundef nonnull @.str.9, ptr noundef nonnull %1, ptr noundef nonnull %12) #5
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %16, label %19

16:                                               ; preds = %13
  %17 = load ptr, ptr @stderr, align 8, !tbaa !11
  %18 = call i64 @fwrite(ptr noundef nonnull @.str.5, i64 noundef 1, i64 noundef 53, ptr noundef %17) #6
  br label %20

19:                                               ; preds = %13
  call void @rcutils_set_error_state(ptr noundef nonnull %3, ptr noundef nonnull @.str.1, i64 noundef 211) #5
  br label %20

20:                                               ; preds = %19, %16
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #5
  br label %32

21:                                               ; preds = %10
  %.not21 = icmp eq ptr %11, null
  br i1 %.not21, label %22, label %32

22:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %4) #5
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  %25 = call i32 (ptr, i64, ptr, ...) @rcutils_snprintf(ptr noundef nonnull %4, i64 noundef 1024, ptr noundef nonnull @.str.10, ptr noundef nonnull %1, ptr noundef %24) #5
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %22
  %28 = load ptr, ptr @stderr, align 8, !tbaa !11
  %29 = call i64 @fwrite(ptr noundef nonnull @.str.5, i64 noundef 1, i64 noundef 53, ptr noundef %28) #6
  br label %31

30:                                               ; preds = %22
  call void @rcutils_set_error_state(ptr noundef nonnull %4, ptr noundef nonnull @.str.1, i64 noundef 226) #5
  br label %31

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

32:                                               ; preds = %20, %31, %21, %9
  %.1 = phi ptr [ null, %9 ], [ null, %20 ], [ null, %31 ], [ %11, %21 ]
  ret ptr %.1
}

; Function Attrs: nounwind
declare ptr @dlsym(ptr noundef, ptr noundef) local_unnamed_addr #2

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 "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 = { 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 #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 = { 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_shared_library_s", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"rcutils_allocator_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 8}


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