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

; 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 @save_warmstart(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.DAQPWorkspace, ptr %7, i32 0, i32 29
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.DAQPBnB, ptr %9, i32 0, i32 6
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.DAQPNode, ptr %12, i32 0, i32 2
  store i32 %11, ptr %13, align 4, !tbaa !15
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.DAQPWorkspace, ptr %14, i32 0, i32 29
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.DAQPBnB, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 4, !tbaa !17
  store i32 %18, ptr %6, align 4, !tbaa !18
  br label %19

19:                                               ; preds = %80, %2
  %20 = load i32, ptr %6, align 4, !tbaa !18
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.DAQPWorkspace, ptr %21, i32 0, i32 24
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %24 = icmp slt i32 %20, %23
  br i1 %24, label %25, label %83

25:                                               ; preds = %19
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.DAQPWorkspace, ptr %26, i32 0, i32 23
  %28 = load ptr, ptr %27, align 8, !tbaa !20
  %29 = load i32, ptr %6, align 4, !tbaa !18
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i32, ptr %28, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !18
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.DAQPWorkspace, ptr %33, i32 0, i32 9
  %35 = load ptr, ptr %34, align 8, !tbaa !21
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.DAQPWorkspace, ptr %36, i32 0, i32 23
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = load i32, ptr %6, align 4, !tbaa !18
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !18
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr %35, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !18
  %46 = and i32 %45, 2
  %47 = shl i32 %46, 15
  %48 = add nsw i32 %32, %47
  store i32 %48, ptr %5, align 4, !tbaa !18
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.DAQPWorkspace, ptr %49, i32 0, i32 9
  %51 = load ptr, ptr %50, align 8, !tbaa !21
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.DAQPWorkspace, ptr %52, i32 0, i32 23
  %54 = load ptr, ptr %53, align 8, !tbaa !20
  %55 = load i32, ptr %6, align 4, !tbaa !18
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr %54, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !18
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr %51, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !18
  %62 = and i32 %61, 20
  %63 = icmp ne i32 %62, 20
  br i1 %63, label %64, label %79

64:                                               ; preds = %25
  %65 = load i32, ptr %5, align 4, !tbaa !18
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.DAQPWorkspace, ptr %66, i32 0, i32 29
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.DAQPBnB, ptr %68, i32 0, i32 5
  %70 = load ptr, ptr %69, align 8, !tbaa !22
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.DAQPWorkspace, ptr %71, i32 0, i32 29
  %73 = load ptr, ptr %72, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.DAQPBnB, ptr %73, i32 0, i32 6
  %75 = load i32, ptr %74, align 8, !tbaa !13
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %74, align 8, !tbaa !13
  %77 = sext i32 %75 to i64
  %78 = getelementptr inbounds i32, ptr %70, i64 %77
  store i32 %65, ptr %78, align 4, !tbaa !18
  br label %79

79:                                               ; preds = %64, %25
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %6, align 4, !tbaa !18
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %6, align 4, !tbaa !18
  br label %19, !llvm.loop !23

83:                                               ; preds = %19
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.DAQPWorkspace, ptr %84, i32 0, i32 29
  %86 = load ptr, ptr %85, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.DAQPBnB, ptr %86, i32 0, i32 6
  %88 = load i32, ptr %87, align 8, !tbaa !13
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.DAQPNode, ptr %89, i32 0, i32 3
  store i32 %88, ptr %90, align 4, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 216}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 12, !11, 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, !12, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !11, i64 168, !6, i64 176, !11, i64 184, !11, i64 188, !11, i64 192, !12, i64 200, !6, i64 208, !6, i64 216, !11, i64 224, !6, i64 232}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !11, i64 40}
!14 = !{!"", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !11, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !6, i64 48, !11, i64 56, !11, i64 60}
!15 = !{!16, !11, i64 8}
!16 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!17 = !{!14, !11, i64 12}
!18 = !{!11, !11, i64 0}
!19 = !{!10, !11, i64 184}
!20 = !{!10, !6, i64 176}
!21 = !{!10, !6, i64 64}
!22 = !{!14, !6, i64 32}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!16, !11, i64 12}


; 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 @save_warmstart(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 216
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 40
  %6 = load i32, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %6, ptr %7, align 4, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %4, i64 12
  %9 = load i32, ptr %8, align 4, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %1, i64 184
  %11 = load i32, ptr %10, align 8, !tbaa !17
  %12 = icmp slt i32 %9, %11
  br i1 %12, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %13 = getelementptr inbounds i8, ptr %1, i64 176
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  %15 = getelementptr inbounds i8, ptr %1, i64 64
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %4, i64 32
  %18 = sext i32 %9 to i64
  br label %19

19:                                               ; preds = %.lr.ph, %36
  %20 = phi i32 [ %11, %.lr.ph ], [ %37, %36 ]
  %indvars.iv = phi i64 [ %18, %.lr.ph ], [ %indvars.iv.next, %36 ]
  %21 = getelementptr inbounds i32, ptr %14, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !20
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %16, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !20
  %26 = and i32 %25, 20
  %.not = icmp eq i32 %26, 20
  br i1 %.not, label %36, label %27

27:                                               ; preds = %19
  %28 = shl i32 %25, 15
  %29 = and i32 %28, 65536
  %30 = add nsw i32 %29, %22
  %31 = load ptr, ptr %17, align 8, !tbaa !21
  %32 = load i32, ptr %5, align 8, !tbaa !12
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %5, align 8, !tbaa !12
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds i32, ptr %31, i64 %34
  store i32 %30, ptr %35, align 4, !tbaa !20
  %.pre = load i32, ptr %10, align 8, !tbaa !17
  br label %36

36:                                               ; preds = %19, %27
  %37 = phi i32 [ %20, %19 ], [ %.pre, %27 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %38 = sext i32 %37 to i64
  %39 = icmp slt i64 %indvars.iv.next, %38
  br i1 %39, label %19, label %._crit_edge.loopexit, !llvm.loop !22

._crit_edge.loopexit:                             ; preds = %36
  %.pre20 = load i32, ptr %5, align 8, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %40 = phi i32 [ %.pre20, %._crit_edge.loopexit ], [ %6, %2 ]
  %41 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %40, ptr %41, align 4, !tbaa !24
  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, !7, i64 216}
!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 = !{!13, !10, i64 40}
!13 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !7, i64 48, !10, i64 56, !10, i64 60}
!14 = !{!15, !10, i64 8}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!16 = !{!13, !10, i64 12}
!17 = !{!6, !10, i64 184}
!18 = !{!6, !7, i64 176}
!19 = !{!6, !7, i64 64}
!20 = !{!10, !10, i64 0}
!21 = !{!13, !7, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!15, !10, i64 12}


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