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

; 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_array_list_s = type { ptr }
%struct.rcutils_allocator_s = type { ptr, ptr, ptr, ptr, ptr }
%struct.rcutils_array_list_impl_s = type { i64, i64, ptr, 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 [34 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [46 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_array_list_init(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %4
  %11 = load ptr, ptr %6, 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 58)
  br label %15

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

16:                                               ; preds = %10
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = call zeroext i1 @rcutils_allocator_is_valid(ptr noundef %18)
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %17
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = icmp ne ptr null, %24
  br i1 %25, label %26, label %29

26:                                               ; preds = %21
  br label %27

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

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

29:                                               ; preds = %21
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = icmp ugt i64 1, %30
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  br label %33

33:                                               ; preds = %32
  call void @rcutils_set_error_state(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 64)
  br label %34

34:                                               ; preds = %33
  store i32 11, ptr %5, align 4
  br label %115

35:                                               ; preds = %29
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = icmp ugt i64 1, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  br label %39

39:                                               ; preds = %38
  call void @rcutils_set_error_state(ptr noundef @.str.4, ptr noundef @.str.1, i64 noundef 67)
  br label %40

40:                                               ; preds = %39
  store i32 11, ptr %5, align 4
  br label %115

41:                                               ; preds = %35
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = call ptr %46(i64 noundef 72, ptr noundef %49)
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %51, i32 0, i32 0
  store ptr %50, ptr %52, align 8, !tbaa !11
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = icmp eq ptr null, %55
  br i1 %56, label %57, label %60

57:                                               ; preds = %43
  br label %58

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

59:                                               ; preds = %58
  store i32 10, ptr %5, align 4
  br label %115

60:                                               ; preds = %43
  %61 = load i64, ptr %7, align 8, !tbaa !9
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  %65 = getelementptr inbounds %struct.rcutils_array_list_impl_s, ptr %64, i32 0, i32 1
  store i64 %61, ptr %65, align 8, !tbaa !16
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !11
  %69 = getelementptr inbounds %struct.rcutils_array_list_impl_s, ptr %68, i32 0, i32 0
  store i64 0, ptr %69, align 8, !tbaa !18
  %70 = load i64, ptr %8, align 8, !tbaa !9
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !11
  %74 = getelementptr inbounds %struct.rcutils_array_list_impl_s, ptr %73, i32 0, i32 3
  store i64 %70, ptr %74, align 8, !tbaa !19
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %76, align 8, !tbaa !13
  %78 = load i64, ptr %7, align 8, !tbaa !9
  %79 = load i64, ptr %8, align 8, !tbaa !9
  %80 = mul i64 %78, %79
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %81, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !15
  %84 = call ptr %77(i64 noundef %80, ptr noundef %83)
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct.rcutils_array_list_impl_s, ptr %87, i32 0, i32 2
  store ptr %84, ptr %88, align 8, !tbaa !20
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !11
  %92 = getelementptr inbounds %struct.rcutils_array_list_impl_s, ptr %91, i32 0, i32 2
  %93 = load ptr, ptr %92, align 8, !tbaa !20
  %94 = icmp eq ptr null, %93
  br i1 %94, label %95, label %109

95:                                               ; preds = %60
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %96, i32 0, i32 1
  %98 = load ptr, ptr %97, align 8, !tbaa !21
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !11
  %102 = load ptr, ptr %9, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.rcutils_allocator_s, ptr %102, i32 0, i32 4
  %104 = load ptr, ptr %103, align 8, !tbaa !15
  call void %98(ptr noundef %101, ptr noundef %104)
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %105, i32 0, i32 0
  store ptr null, ptr %106, align 8, !tbaa !11
  br label %107

107:                                              ; preds = %95
  call void @rcutils_set_error_state(ptr noundef @.str.6, ptr noundef @.str.1, i64 noundef 84)
  br label %108

108:                                              ; preds = %107
  store i32 10, ptr %5, align 4
  br label %115

109:                                              ; preds = %60
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.rcutils_array_list_s, ptr %110, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8, !tbaa !11
  %113 = getelementptr inbounds %struct.rcutils_array_list_impl_s, ptr %112, i32 0, i32 4
  %114 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %113, ptr align 8 %114, i64 40, i1 false), !tbaa.struct !22
  store i32 0, ptr %5, align 4
  br label %115

115:                                              ; preds = %109, %108, %59, %40, %34, %28, %20, %15
  %116 = load i32, ptr %5, align 4
  ret i32 %116
}

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

declare zeroext i1 @rcutils_allocator_is_valid(ptr noundef) #2

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

!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_array_list_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, !10, i64 8}
!17 = !{!"rcutils_array_list_impl_s", !10, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !14, i64 32}
!18 = !{!17, !10, i64 0}
!19 = !{!17, !10, i64 24}
!20 = !{!17, !6, i64 16}
!21 = !{!14, !6, i64 8}
!22 = !{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}


; 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.2 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [46 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 range(i32 0, 12) i32 @rcutils_array_list_init(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = icmp eq ptr %0, null
  br i1 %5, label %6, label %7

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

7:                                                ; preds = %4
  %8 = tail call zeroext i1 @rcutils_allocator_is_valid(ptr noundef %3) #3
  br i1 %8, label %9, label %41

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

11:                                               ; preds = %9
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i64 noundef 61) #3
  br label %41

12:                                               ; preds = %9
  %13 = icmp eq i64 %1, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %12
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i64 noundef 64) #3
  br label %41

15:                                               ; preds = %12
  %16 = icmp eq i64 %2, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %15
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i64 noundef 67) #3
  br label %41

18:                                               ; preds = %15
  %19 = load ptr, ptr %3, align 8, !tbaa !10
  %20 = getelementptr inbounds i8, ptr %3, i64 32
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = tail call ptr %19(i64 noundef 72, ptr noundef %21) #3
  store ptr %22, ptr %0, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %18
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i64 noundef 73) #3
  br label %41

25:                                               ; preds = %18
  %26 = getelementptr inbounds i8, ptr %22, i64 8
  store i64 %1, ptr %26, align 8, !tbaa !13
  store i64 0, ptr %22, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %22, i64 24
  store i64 %2, ptr %27, align 8, !tbaa !17
  %28 = load ptr, ptr %3, align 8, !tbaa !10
  %29 = mul i64 %2, %1
  %30 = load ptr, ptr %20, align 8, !tbaa !12
  %31 = tail call ptr %28(i64 noundef %29, ptr noundef %30) #3
  %32 = load ptr, ptr %0, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  store ptr %31, ptr %33, align 8, !tbaa !18
  %34 = icmp eq ptr %31, null
  br i1 %34, label %35, label %39

35:                                               ; preds = %25
  %36 = getelementptr inbounds i8, ptr %3, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = load ptr, ptr %20, align 8, !tbaa !12
  tail call void %37(ptr noundef nonnull %32, ptr noundef %38) #3
  store ptr null, ptr %0, align 8, !tbaa !5
  tail call void @rcutils_set_error_state(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i64 noundef 84) #3
  br label %41

39:                                               ; preds = %25
  %40 = getelementptr inbounds i8, ptr %32, i64 32
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %40, ptr noundef nonnull align 8 dereferenceable(40) %3, i64 40, i1 false), !tbaa.struct !20
  br label %41

41:                                               ; preds = %7, %39, %35, %24, %17, %14, %11, %6
  %.0 = phi i32 [ 11, %6 ], [ 11, %11 ], [ 11, %14 ], [ 11, %17 ], [ 10, %24 ], [ 10, %35 ], [ 0, %39 ], [ 11, %7 ]
  ret i32 %.0
}

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

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 = { 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_array_list_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 = !{!14, !15, i64 8}
!14 = !{!"rcutils_array_list_impl_s", !15, i64 0, !15, i64 8, !7, i64 16, !15, i64 24, !11, i64 32}
!15 = !{!"long", !8, i64 0}
!16 = !{!14, !15, i64 0}
!17 = !{!14, !15, i64 24}
!18 = !{!14, !7, i64 16}
!19 = !{!11, !7, i64 8}
!20 = !{i64 0, i64 8, !21, i64 8, i64 8, !21, i64 16, i64 8, !21, i64 24, i64 8, !21, i64 32, i64 8, !21}
!21 = !{!7, !7, i64 0}


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