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

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

16:                                               ; preds = %3
  store i32 -6, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %121

17:                                               ; preds = %3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.DAQPWorkspace, ptr %18, i32 0, i32 29
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %120

22:                                               ; preds = %17
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %25, label %120

25:                                               ; preds = %22
  %26 = call noalias ptr @malloc(i64 noundef 64) #4
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.DAQPWorkspace, ptr %27, i32 0, i32 29
  store ptr %26, ptr %28, align 8, !tbaa !14
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.DAQPWorkspace, ptr %30, i32 0, i32 29
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = getelementptr inbounds %struct.DAQPBnB, ptr %32, i32 0, i32 1
  store i32 %29, ptr %33, align 8, !tbaa !15
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = mul i64 %35, 4
  %37 = call noalias ptr @malloc(i64 noundef %36) #4
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.DAQPWorkspace, ptr %38, i32 0, i32 29
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct.DAQPBnB, ptr %40, i32 0, i32 0
  store ptr %37, ptr %41, align 8, !tbaa !17
  store i32 0, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %70, %25
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %46, label %73

46:                                               ; preds = %42
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.DAQPWorkspace, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = getelementptr inbounds %struct.DAQPProblem, ptr %49, i32 0, i32 8
  %51 = load ptr, ptr %50, align 8, !tbaa !19
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = and i32 %55, 16
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %69

58:                                               ; preds = %46
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.DAQPWorkspace, ptr %60, i32 0, i32 29
  %62 = load ptr, ptr %61, align 8, !tbaa !14
  %63 = getelementptr inbounds %struct.DAQPBnB, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %9, align 4, !tbaa !9
  %67 = sext i32 %65 to i64
  %68 = getelementptr inbounds i32, ptr %64, i64 %67
  store i32 %59, ptr %68, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %58, %46
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %8, align 4, !tbaa !9
  br label %42, !llvm.loop !21

73:                                               ; preds = %42
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.DAQPWorkspace, ptr %74, i32 0, i32 29
  %76 = load ptr, ptr %75, align 8, !tbaa !14
  %77 = getelementptr inbounds %struct.DAQPBnB, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 8, !tbaa !15
  %79 = add nsw i32 %78, 1
  %80 = sext i32 %79 to i64
  %81 = mul i64 %80, 16
  %82 = call noalias ptr @malloc(i64 noundef %81) #4
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.DAQPWorkspace, ptr %83, i32 0, i32 29
  %85 = load ptr, ptr %84, align 8, !tbaa !14
  %86 = getelementptr inbounds %struct.DAQPBnB, ptr %85, i32 0, i32 3
  store ptr %82, ptr %86, align 8, !tbaa !23
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.DAQPWorkspace, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 8, !tbaa !11
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = add nsw i32 %89, %90
  %92 = add nsw i32 %91, 1
  %93 = load i32, ptr %6, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  %95 = mul nsw i32 %92, %94
  %96 = sext i32 %95 to i64
  %97 = mul i64 %96, 4
  %98 = call noalias ptr @malloc(i64 noundef %97) #4
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.DAQPWorkspace, ptr %99, i32 0, i32 29
  %101 = load ptr, ptr %100, align 8, !tbaa !14
  %102 = getelementptr inbounds %struct.DAQPBnB, ptr %101, i32 0, i32 5
  store ptr %98, ptr %102, align 8, !tbaa !24
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.DAQPWorkspace, ptr %103, i32 0, i32 29
  %105 = load ptr, ptr %104, align 8, !tbaa !14
  %106 = getelementptr inbounds %struct.DAQPBnB, ptr %105, i32 0, i32 4
  store i32 0, ptr %106, align 8, !tbaa !25
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.DAQPWorkspace, ptr %107, i32 0, i32 29
  %109 = load ptr, ptr %108, align 8, !tbaa !14
  %110 = getelementptr inbounds %struct.DAQPBnB, ptr %109, i32 0, i32 6
  store i32 0, ptr %110, align 8, !tbaa !26
  %111 = load i32, ptr %6, align 4, !tbaa !9
  %112 = add nsw i32 %111, 1
  %113 = sext i32 %112 to i64
  %114 = mul i64 %113, 4
  %115 = call noalias ptr @malloc(i64 noundef %114) #4
  %116 = load ptr, ptr %5, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.DAQPWorkspace, ptr %116, i32 0, i32 29
  %118 = load ptr, ptr %117, align 8, !tbaa !14
  %119 = getelementptr inbounds %struct.DAQPBnB, ptr %118, i32 0, i32 8
  store ptr %115, ptr %119, align 8, !tbaa !27
  br label %120

120:                                              ; preds = %73, %22, %17
  store i32 1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %121

121:                                              ; preds = %120, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %122 = load i32, ptr %4, align 4
  ret i32 %122
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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 allocsize(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 = { nounwind }
attributes #4 = { nounwind allocsize(0) }

!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 8}
!12 = !{!"", !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, !13, 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, !13, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !6, i64 232}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !6, i64 216}
!15 = !{!16, !10, i64 8}
!16 = !{!"", !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}
!17 = !{!16, !6, i64 0}
!18 = !{!12, !6, i64 0}
!19 = !{!20, !6, i64 56}
!20 = !{!"", !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, !10, i64 72}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!16, !6, i64 16}
!24 = !{!16, !6, i64 32}
!25 = !{!16, !10, i64 24}
!26 = !{!16, !10, i64 40}
!27 = !{!16, !6, i64 48}


; 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 nounwind uwtable
define dso_local range(i32 -6, 2) i32 @setup_daqp_bnb(ptr nocapture noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp slt i32 %5, %1
  br i1 %6, label %50, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 216
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = icmp eq ptr %9, null
  %11 = icmp sgt i32 %1, 0
  %or.cond = and i1 %11, %10
  br i1 %or.cond, label %12, label %50

12:                                               ; preds = %7
  %13 = tail call noalias dereferenceable_or_null(64) ptr @malloc(i64 noundef 64) #2
  store ptr %13, ptr %8, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  store i32 %1, ptr %14, align 8, !tbaa !13
  %15 = zext nneg i32 %1 to i64
  %16 = shl nuw nsw i64 %15, 2
  %17 = tail call noalias ptr @malloc(i64 noundef %16) #2
  store ptr %17, ptr %13, align 8, !tbaa !15
  %18 = load ptr, ptr %0, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %18, i64 56
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  br label %21

21:                                               ; preds = %12, %30
  %indvars.iv = phi i64 [ 0, %12 ], [ %indvars.iv.next, %30 ]
  %.032 = phi i32 [ 0, %12 ], [ %.1, %30 ]
  %22 = getelementptr inbounds i32, ptr %20, i64 %indvars.iv
  %23 = load i32, ptr %22, align 4, !tbaa !19
  %24 = and i32 %23, 16
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %30, label %25

25:                                               ; preds = %21
  %26 = add nsw i32 %.032, 1
  %27 = sext i32 %.032 to i64
  %28 = getelementptr inbounds i32, ptr %17, i64 %27
  %29 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %29, ptr %28, align 4, !tbaa !19
  br label %30

30:                                               ; preds = %21, %25
  %.1 = phi i32 [ %26, %25 ], [ %.032, %21 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %31 = icmp slt i32 %.1, %1
  br i1 %31, label %21, label %32, !llvm.loop !20

32:                                               ; preds = %30
  %33 = add nuw nsw i32 %1, 1
  %34 = zext nneg i32 %33 to i64
  %35 = shl nuw nsw i64 %34, 4
  %36 = tail call noalias ptr @malloc(i64 noundef %35) #2
  %37 = getelementptr inbounds i8, ptr %13, i64 16
  store ptr %36, ptr %37, align 8, !tbaa !22
  %38 = add i32 %2, 1
  %39 = add i32 %38, %5
  %40 = mul nsw i32 %39, %33
  %41 = sext i32 %40 to i64
  %42 = shl nsw i64 %41, 2
  %43 = tail call noalias ptr @malloc(i64 noundef %42) #2
  %44 = getelementptr inbounds i8, ptr %13, i64 32
  store ptr %43, ptr %44, align 8, !tbaa !23
  %45 = getelementptr inbounds i8, ptr %13, i64 24
  store i32 0, ptr %45, align 8, !tbaa !24
  %46 = getelementptr inbounds i8, ptr %13, i64 40
  store i32 0, ptr %46, align 8, !tbaa !25
  %47 = shl nuw nsw i64 %34, 2
  %48 = tail call noalias ptr @malloc(i64 noundef %47) #2
  %49 = getelementptr inbounds i8, ptr %13, i64 48
  store ptr %48, ptr %49, align 8, !tbaa !26
  br label %50

50:                                               ; preds = %7, %32, %3
  %.029 = phi i32 [ -6, %3 ], [ 1, %32 ], [ 1, %7 ]
  ret i32 %.029
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

attributes #0 = { nofree 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }

!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 8}
!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 216}
!13 = !{!14, !10, i64 8}
!14 = !{!"", !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}
!15 = !{!14, !7, i64 0}
!16 = !{!6, !7, i64 0}
!17 = !{!18, !7, i64 56}
!18 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 72}
!19 = !{!10, !10, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!14, !7, i64 16}
!23 = !{!14, !7, i64 32}
!24 = !{!14, !10, i64 24}
!25 = !{!14, !10, i64 40}
!26 = !{!14, !7, i64 48}


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