; LLVM IR from aap/librw :: src/plg.ll (ZN2rw10PluginList14registerPluginEijPFPvS1_iiES3_PFS1_S1_S1_iiE)

; 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.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::Plugin" = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"struct.rw::LLLink", %"struct.rw::LLLink" }

@_ZN2rwL10allPluginsE = external hidden global %"struct.rw::LinkList", align 8
@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2rw10PluginList14registerPluginEijPFPvS1_iiES3_PFS1_S1_S1_iiE(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %16 = call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef 120, i32 noundef 262144, ptr noundef @.str.2)
  store ptr %16, ptr %13, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.rw::PluginList", ptr %15, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %13, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.rw::Plugin", ptr %19, i32 0, i32 0
  store i32 %18, ptr %20, align 8, !tbaa !15
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = getelementptr inbounds %"struct.rw::PluginList", ptr %15, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = add nsw i32 %23, %21
  store i32 %24, ptr %22, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 7, ptr %14, align 4, !tbaa !9
  %25 = getelementptr inbounds %"struct.rw::PluginList", ptr %15, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !11
  %27 = load i32, ptr %14, align 4, !tbaa !9
  %28 = add nsw i32 %26, %27
  %29 = load i32, ptr %14, align 4, !tbaa !9
  %30 = xor i32 %29, -1
  %31 = and i32 %28, %30
  %32 = getelementptr inbounds %"struct.rw::PluginList", ptr %15, i32 0, i32 0
  store i32 %31, ptr %32, align 8, !tbaa !11
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.rw::Plugin", ptr %34, i32 0, i32 1
  store i32 %33, ptr %35, align 4, !tbaa !17
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %13, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.rw::Plugin", ptr %37, i32 0, i32 2
  store i32 %36, ptr %38, align 8, !tbaa !18
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %43

41:                                               ; preds = %6
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  br label %44

43:                                               ; preds = %6
  br label %44

44:                                               ; preds = %43, %41
  %45 = phi ptr [ %42, %41 ], [ @_ZN2rwL7defCtorEPvii, %43 ]
  %46 = load ptr, ptr %13, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.rw::Plugin", ptr %46, i32 0, i32 3
  store ptr %45, ptr %47, align 8, !tbaa !19
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %52

50:                                               ; preds = %44
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  br label %53

52:                                               ; preds = %44
  br label %53

53:                                               ; preds = %52, %50
  %54 = phi ptr [ %51, %50 ], [ @_ZN2rwL7defDtorEPvii, %52 ]
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.rw::Plugin", ptr %55, i32 0, i32 4
  store ptr %54, ptr %56, align 8, !tbaa !20
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %61

59:                                               ; preds = %53
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  br label %62

61:                                               ; preds = %53
  br label %62

62:                                               ; preds = %61, %59
  %63 = phi ptr [ %60, %59 ], [ @_ZN2rwL7defCopyEPvS0_ii, %61 ]
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.rw::Plugin", ptr %64, i32 0, i32 5
  store ptr %63, ptr %65, align 8, !tbaa !21
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.rw::Plugin", ptr %66, i32 0, i32 6
  store ptr null, ptr %67, align 8, !tbaa !22
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.rw::Plugin", ptr %68, i32 0, i32 7
  store ptr null, ptr %69, align 8, !tbaa !23
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.rw::Plugin", ptr %70, i32 0, i32 8
  store ptr null, ptr %71, align 8, !tbaa !24
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = getelementptr inbounds %"struct.rw::Plugin", ptr %72, i32 0, i32 9
  store ptr null, ptr %73, align 8, !tbaa !25
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.rw::Plugin", ptr %74, i32 0, i32 10
  store ptr null, ptr %75, align 8, !tbaa !26
  %76 = load ptr, ptr %13, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.rw::Plugin", ptr %76, i32 0, i32 11
  store ptr %15, ptr %77, align 8, !tbaa !27
  %78 = getelementptr inbounds %"struct.rw::PluginList", ptr %15, i32 0, i32 2
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  %80 = getelementptr inbounds %"struct.rw::Plugin", ptr %79, i32 0, i32 12
  call void @_ZN2rw8LinkList6appendEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16) %78, ptr noundef %80)
  %81 = load ptr, ptr %13, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::Plugin", ptr %81, i32 0, i32 13
  call void @_ZN2rw8LinkList6appendEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16) @_ZN2rwL10allPluginsE, ptr noundef %82)
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = getelementptr inbounds %"struct.rw::Plugin", ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret i32 %85
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL7defCtorEPvii(ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL7defDtorEPvii(ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL7defCopyEPvS0_ii(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw8LinkList6appendEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN2rw10PluginListE", !10, i64 0, !10, i64 4, !13, i64 8}
!13 = !{!"_ZTSN2rw8LinkListE", !14, i64 0}
!14 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTSN2rw6PluginE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !14, i64 88, !14, i64 104}
!17 = !{!16, !10, i64 4}
!18 = !{!16, !10, i64 8}
!19 = !{!16, !6, i64 16}
!20 = !{!16, !6, i64 24}
!21 = !{!16, !6, i64 32}
!22 = !{!16, !6, i64 40}
!23 = !{!16, !6, i64 48}
!24 = !{!16, !6, i64 56}
!25 = !{!16, !6, i64 64}
!26 = !{!16, !6, i64 72}
!27 = !{!16, !6, i64 80}


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

%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }

@_ZN2rwL10allPluginsE = external hidden global %"struct.rw::LinkList", align 8
@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2rw10PluginList14registerPluginEijPFPvS1_iiES3_PFS1_S1_S1_iiE(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #0 align 2 {
  %7 = tail call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef 120, i32 noundef 262144, ptr noundef nonnull @.str.2)
  %8 = load i32, ptr %0, align 8, !tbaa !5
  store i32 %8, ptr %7, align 8, !tbaa !13
  %9 = add i32 %1, 7
  %10 = add i32 %9, %8
  %11 = and i32 %10, -8
  store i32 %11, ptr %0, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 %1, ptr %12, align 4, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %2, ptr %13, align 8, !tbaa !16
  %14 = insertelement <2 x ptr> poison, ptr %3, i64 0
  %15 = insertelement <2 x ptr> %14, ptr %4, i64 1
  %16 = icmp eq <2 x ptr> %15, zeroinitializer
  %17 = getelementptr inbounds i8, ptr %7, i64 16
  %18 = select <2 x i1> %16, <2 x ptr> <ptr @_ZN2rwL7defCtorEPvii, ptr @_ZN2rwL7defDtorEPvii>, <2 x ptr> %15
  store <2 x ptr> %18, ptr %17, align 8, !tbaa !17
  %.not27 = icmp eq ptr %5, null
  %19 = select i1 %.not27, ptr @_ZN2rwL7defCopyEPvS0_ii, ptr %5
  %20 = getelementptr inbounds i8, ptr %7, i64 32
  store ptr %19, ptr %20, align 8, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %7, i64 40
  %22 = getelementptr inbounds i8, ptr %7, i64 80
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %21, i8 0, i64 40, i1 false)
  store ptr %0, ptr %22, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  %24 = getelementptr inbounds i8, ptr %7, i64 88
  tail call void @_ZN2rw8LinkList6appendEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull %24)
  %25 = getelementptr inbounds i8, ptr %7, i64 104
  tail call void @_ZN2rw8LinkList6appendEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16) @_ZN2rwL10allPluginsE, ptr noundef nonnull %25)
  %26 = load i32, ptr %7, align 8, !tbaa !13
  ret i32 %26
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL7defCtorEPvii(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL7defDtorEPvii(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL7defCopyEPvS0_ii(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw8LinkList6appendEPNS_6LLLinkE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress 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 #1 = { inlinehint mustprogress 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 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!"_ZTSN2rw10PluginListE", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN2rw8LinkListE", !11, i64 0}
!11 = !{!"_ZTSN2rw6LLLinkE", !12, i64 0, !12, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"_ZTSN2rw6PluginE", !7, i64 0, !7, i64 4, !7, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !11, i64 88, !11, i64 104}
!15 = !{!14, !7, i64 4}
!16 = !{!14, !7, i64 8}
!17 = !{!12, !12, i64 0}
!18 = !{!14, !12, i64 32}
!19 = !{!14, !12, i64 80}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass