; 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.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 }

; 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: nounwind uwtable
define dso_local void @node_cleanup_workspace(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %6 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %6, ptr %5, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %45, %2
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.DAQPWorkspace, ptr %9, i32 0, i32 24
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp slt i32 %8, %11
  br i1 %12, label %13, label %48

13:                                               ; preds = %7
  %14 = load ptr, ptr %4, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.DAQPWorkspace, ptr %14, i32 0, i32 9
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = load ptr, ptr %4, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.DAQPWorkspace, ptr %17, i32 0, i32 23
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr %19, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i32, ptr %16, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = and i32 %26, 16
  %28 = icmp ne i32 %27, 0
  %29 = zext i1 %28 to i64
  %30 = select i1 %28, i32 -6, i32 -2
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.DAQPWorkspace, ptr %31, i32 0, i32 9
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = load ptr, ptr %4, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct.DAQPWorkspace, ptr %34, i32 0, i32 23
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %36, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i32, ptr %33, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = and i32 %43, %30
  store i32 %44, ptr %42, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %13
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %5, align 4, !tbaa !5
  br label %7, !llvm.loop !16

48:                                               ; preds = %7
  %49 = load ptr, ptr %4, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.DAQPWorkspace, ptr %49, i32 0, i32 26
  store i32 -1, ptr %50, align 8, !tbaa !18
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.DAQPWorkspace, ptr %52, i32 0, i32 24
  store i32 %51, ptr %53, align 8, !tbaa !11
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = load ptr, ptr %4, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.DAQPWorkspace, ptr %55, i32 0, i32 22
  store i32 %54, ptr %56, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @node_cleanup_workspace(i32 noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 184
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp sgt i32 %4, %0
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 64
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %1, i64 176
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = sext i32 %0 to i64
  br label %11

11:                                               ; preds = %.lr.ph, %11
  %indvars.iv = phi i64 [ %10, %.lr.ph ], [ %indvars.iv.next, %11 ]
  %12 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  %13 = load i32, ptr %12, align 4, !tbaa !14
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr %7, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !14
  %17 = and i32 %16, 16
  %.not = icmp eq i32 %17, 0
  %18 = select i1 %.not, i32 -2, i32 -6
  %19 = and i32 %18, %16
  store i32 %19, ptr %15, align 4, !tbaa !14
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %20 = load i32, ptr %3, align 8, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = icmp slt i64 %indvars.iv.next, %21
  br i1 %22, label %11, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %11, %2
  %23 = getelementptr inbounds i8, ptr %1, i64 192
  store i32 -1, ptr %23, align 8, !tbaa !17
  store i32 %0, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %1, i64 168
  store i32 %0, ptr %24, align 8, !tbaa !18
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !10, i64 184}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !11, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !10, i64 168, !7, i64 176, !10, i64 184, !10, i64 188, !10, i64 192, !11, i64 200, !7, i64 208, !7, i64 216, !10, i64 224, !7, i64 232}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !7, i64 64}
!13 = !{!6, !7, i64 176}
!14 = !{!10, !10, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !10, i64 192}
!18 = !{!6, !10, i64 168}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass