; LLVM IR from darnstrom/daqp :: src (bnb)

; 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.DAQPNode = type { i32, i32, i32, i32 }
%struct.DAQPWorkspace = type { ptr, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, double, ptr, ptr, ptr, ptr, i32, ptr, i32, i32, i32, double, ptr, ptr, i32, ptr }
%struct.DAQPBnB = type { ptr, i32, i32, ptr, i32, ptr, i32, i32, ptr, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @spawn_children(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %6, align 8, !tbaa !5
  call void @save_warmstart(ptr noundef %7, ptr noundef %8)
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = xor i32 %9, 65536
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.DAQPNode, ptr %11, i32 0, i32 0
  store i32 %10, ptr %12, align 4, !tbaa !11
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.DAQPNode, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr %14, align 4, !tbaa !13
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.DAQPNode, ptr %18, i64 1
  %20 = getelementptr inbounds %struct.DAQPNode, ptr %19, i32 0, i32 0
  store i32 %17, ptr %20, align 4, !tbaa !11
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.DAQPNode, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.DAQPNode, ptr %24, i64 1
  %26 = getelementptr inbounds %struct.DAQPNode, ptr %25, i32 0, i32 1
  store i32 %23, ptr %26, align 4, !tbaa !13
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.DAQPNode, ptr %27, i32 0, i32 2
  %29 = load i32, ptr %28, align 4, !tbaa !14
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.DAQPNode, ptr %30, i64 1
  %32 = getelementptr inbounds %struct.DAQPNode, ptr %31, i32 0, i32 2
  store i32 %29, ptr %32, align 4, !tbaa !14
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.DAQPNode, ptr %33, i32 0, i32 3
  %35 = load i32, ptr %34, align 4, !tbaa !15
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.DAQPNode, ptr %36, i64 1
  %38 = getelementptr inbounds %struct.DAQPNode, ptr %37, i32 0, i32 3
  store i32 %35, ptr %38, align 4, !tbaa !15
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.DAQPWorkspace, ptr %39, i32 0, i32 29
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = getelementptr inbounds %struct.DAQPBnB, ptr %41, i32 0, i32 4
  %43 = load i32, ptr %42, align 8, !tbaa !19
  %44 = add nsw i32 %43, 2
  store i32 %44, ptr %42, align 8, !tbaa !19
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @save_warmstart(ptr noundef, ptr noundef) #0

attributes #0 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = !{!17, !6, i64 216}
!17 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12, !10, 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, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !18, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !10, i64 168, !6, i64 176, !10, i64 184, !10, i64 188, !10, i64 192, !18, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !6, i64 232}
!18 = !{!"double", !7, i64 0}
!19 = !{!20, !10, i64 24}
!20 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !6, i64 48, !10, i64 56, !10, i64 60}


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

; Function Attrs: nounwind uwtable
define dso_local void @spawn_children(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  tail call void @save_warmstart(ptr noundef %0, ptr noundef %2)
  %4 = xor i32 %1, 65536
  store i32 %4, ptr %0, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !10
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr %5, align 4, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %1, ptr %8, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %7, ptr %9, align 4, !tbaa !10
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load <2 x i32>, ptr %10, align 4, !tbaa !11
  store <2 x i32> %12, ptr %11, align 4, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %2, i64 216
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %14, i64 24
  %16 = load i32, ptr %15, align 8, !tbaa !16
  %17 = add nsw i32 %16, 2
  store i32 %17, ptr %15, align 8, !tbaa !16
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @save_warmstart(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 216}
!13 = !{!"", !14, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !15, i64 128, !14, i64 136, !14, i64 144, !14, i64 152, !14, i64 160, !7, i64 168, !14, i64 176, !7, i64 184, !7, i64 188, !7, i64 192, !15, i64 200, !14, i64 208, !14, i64 216, !7, i64 224, !14, i64 232}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = !{!17, !7, i64 24}
!17 = !{!"", !14, i64 0, !7, i64 8, !7, i64 12, !14, i64 16, !7, i64 24, !14, i64 32, !7, i64 40, !7, i64 44, !14, i64 48, !7, i64 56, !7, i64 60}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass