; LLVM IR from BehaviorTree/BehaviorTree.CPP :: src (action_node)

; 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.mco_desc = type { ptr, ptr, ptr, ptr, ptr, i64, i64, i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @mco_desc_init(ptr dead_on_unwind noalias writable sret(%struct.mco_desc) align 8 %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i64 %2, ptr %5, align 8, !tbaa !9
  %6 = load i64, ptr %5, align 8, !tbaa !9
  %7 = icmp ne i64 %6, 0
  br i1 %7, label %8, label %13

8:                                                ; preds = %3
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = icmp ult i64 %9, 32768
  br i1 %10, label %11, label %12

11:                                               ; preds = %8
  store i64 32768, ptr %5, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %11, %8
  br label %14

13:                                               ; preds = %3
  store i64 57344, ptr %5, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %13, %12
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = call noundef i64 @_ZL18_mco_align_forwardmm(i64 noundef %15, i64 noundef 16)
  store i64 %16, ptr %5, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 64, i1 false)
  %17 = getelementptr inbounds %struct.mco_desc, ptr %0, i32 0, i32 2
  store ptr @_ZL10mco_mallocmPv, ptr %17, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct.mco_desc, ptr %0, i32 0, i32 3
  store ptr @_ZL8mco_freePvS_, ptr %18, align 8, !tbaa !13
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.mco_desc, ptr %0, i32 0, i32 0
  store ptr %19, ptr %20, align 8, !tbaa !14
  %21 = getelementptr inbounds %struct.mco_desc, ptr %0, i32 0, i32 5
  store i64 1024, ptr %21, align 8, !tbaa !15
  %22 = load i64, ptr %5, align 8, !tbaa !9
  call void @_ZL20_mco_init_desc_sizesP8mco_descm(ptr noundef %0, i64 noundef %22)
  ret void
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL18_mco_align_forwardmm(i64 noundef, i64 noundef) #1

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

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden void @_ZL20_mco_init_desc_sizesP8mco_descm(ptr noundef, i64 noundef) #1

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 = { alwaysinline 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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" }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTS8mco_desc", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!13 = !{!12, !6, i64 24}
!14 = !{!12, !6, i64 0}
!15 = !{!12, !10, i64 40}


; 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.mco_desc = type { ptr, ptr, ptr, ptr, ptr, i64, i64, i64 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @mco_desc_init(ptr dead_on_unwind noalias writable sret(%struct.mco_desc) align 8 %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %.not = icmp eq i64 %2, 0
  %spec.store.select = tail call i64 @llvm.umax.i64(i64 %2, i64 32768)
  %.0 = select i1 %.not, i64 57344, i64 %spec.store.select
  %4 = tail call noundef i64 @_ZL18_mco_align_forwardmm(i64 noundef %.0, i64 noundef 16)
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %5, i8 0, i64 56, i1 false)
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr @_ZL10mco_mallocmPv, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr @_ZL8mco_freePvS_, ptr %7, align 8, !tbaa !11
  store ptr %1, ptr %0, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  store i64 1024, ptr %8, align 8, !tbaa !13
  tail call void @_ZL20_mco_init_desc_sizesP8mco_descm(ptr noundef nonnull %0, i64 noundef %4)
  ret void
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL18_mco_align_forwardmm(i64 noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL10mco_mallocmPv(i64 noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8mco_freePvS_(ptr noundef, ptr noundef) #0

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden void @_ZL20_mco_init_desc_sizesP8mco_descm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #3

attributes #0 = { 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 #1 = { alwaysinline 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 16}
!6 = !{!"_ZTS8mco_desc", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 40}


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