; LLVM IR from cvxgrp/scs :: linsys/cpu/direct (private)

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

@.str.2 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ldl_factor(ptr noundef, i32 noundef) #1

declare i32 @printf(ptr noundef, ...) #2

; 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 ptr @scs_init_lin_sys_work(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %13 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 120) #5
  store ptr %13, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ScsMatrix, ptr %14, i32 0, i32 4
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ScsMatrix, ptr %17, i32 0, i32 3
  %19 = load i32, ptr %18, align 8, !tbaa !12
  %20 = add nsw i32 %16, %19
  store i32 %20, ptr %9, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ScsMatrix, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 8, !tbaa !12
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %24, i32 0, i32 0
  store i32 %23, ptr %25, align 8, !tbaa !14
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ScsMatrix, ptr %26, i32 0, i32 4
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %29, i32 0, i32 1
  store i32 %28, ptr %30, align 4, !tbaa !16
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ScsMatrix, ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = call noalias ptr @calloc(i64 noundef %34, i64 noundef 8) #5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %36, i32 0, i32 15
  store ptr %35, ptr %37, align 8, !tbaa !17
  %38 = load i32, ptr %9, align 4, !tbaa !13
  %39 = sext i32 %38 to i64
  %40 = call noalias ptr @calloc(i64 noundef 4, i64 noundef %39) #5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %41, i32 0, i32 5
  store ptr %40, ptr %42, align 8, !tbaa !18
  %43 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 32) #5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %44, i32 0, i32 3
  store ptr %43, ptr %45, align 8, !tbaa !19
  %46 = load i32, ptr %9, align 4, !tbaa !13
  %47 = sext i32 %46 to i64
  %48 = call noalias ptr @calloc(i64 noundef %47, i64 noundef 8) #5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %49, i32 0, i32 6
  store ptr %48, ptr %50, align 8, !tbaa !20
  %51 = load i32, ptr %9, align 4, !tbaa !13
  %52 = sext i32 %51 to i64
  %53 = call noalias ptr @calloc(i64 noundef %52, i64 noundef 4) #5
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %54, i32 0, i32 7
  store ptr %53, ptr %55, align 8, !tbaa !21
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %56, i32 0, i32 8
  store i32 0, ptr %57, align 8, !tbaa !22
  %58 = load i32, ptr %9, align 4, !tbaa !13
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %59, i32 0, i32 3
  %61 = load ptr, ptr %60, align 8, !tbaa !19
  %62 = getelementptr inbounds %struct.ScsMatrix, ptr %61, i32 0, i32 3
  store i32 %58, ptr %62, align 8, !tbaa !12
  %63 = load i32, ptr %9, align 4, !tbaa !13
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %64, i32 0, i32 3
  %66 = load ptr, ptr %65, align 8, !tbaa !19
  %67 = getelementptr inbounds %struct.ScsMatrix, ptr %66, i32 0, i32 4
  store i32 %63, ptr %67, align 4, !tbaa !9
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = call ptr @permute_kkt(ptr noundef %68, ptr noundef %69, ptr noundef %70, ptr noundef %71)
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.SCS_LIN_SYS_WORK, ptr %73, i32 0, i32 2
  store ptr %72, ptr %74, align 8, !tbaa !23
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = call i32 @ldl_prepare(ptr noundef %75)
  store i32 %76, ptr %11, align 4, !tbaa !13
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ScsMatrix, ptr %78, i32 0, i32 4
  %80 = load i32, ptr %79, align 4, !tbaa !9
  %81 = call i32 @ldl_factor(ptr noundef %77, i32 noundef %80)
  store i32 %81, ptr %10, align 4, !tbaa !13
  %82 = load i32, ptr %11, align 4, !tbaa !13
  %83 = icmp slt i32 %82, 0
  br i1 %83, label %87, label %84

84:                                               ; preds = %3
  %85 = load i32, ptr %10, align 4, !tbaa !13
  %86 = icmp slt i32 %85, 0
  br i1 %86, label %87, label %89

87:                                               ; preds = %84, %3
  %88 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %91

89:                                               ; preds = %84
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %90, ptr %4, align 8
  store i32 1, ptr %12, align 4
  br label %91

91:                                               ; preds = %89, %87
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %92 = load ptr, ptr %4, align 8
  ret ptr %92
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden ptr @permute_kkt(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @ldl_prepare(ptr noundef) #1

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

!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, !11, i64 28}
!10 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 24}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !11, i64 0}
!15 = !{!"SCS_LIN_SYS_WORK", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112}
!16 = !{!15, !11, i64 4}
!17 = !{!15, !6, i64 112}
!18 = !{!15, !6, i64 32}
!19 = !{!15, !6, i64 16}
!20 = !{!15, !6, i64 40}
!21 = !{!15, !6, i64 48}
!22 = !{!15, !11, i64 56}
!23 = !{!15, !6, i64 8}


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

@.str.2 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden i32 @ldl_factor(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @scs_init_lin_sys_work(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = tail call noalias dereferenceable_or_null(120) ptr @calloc(i64 noundef 1, i64 noundef 120) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 28
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = add nsw i32 %8, %6
  store i32 %8, ptr %4, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 %6, ptr %10, align 4, !tbaa !14
  %11 = sext i32 %6 to i64
  %12 = tail call noalias ptr @calloc(i64 noundef %11, i64 noundef 8) #3
  %13 = getelementptr inbounds i8, ptr %4, i64 112
  store ptr %12, ptr %13, align 8, !tbaa !15
  %14 = sext i32 %9 to i64
  %15 = tail call noalias ptr @calloc(i64 noundef 4, i64 noundef %14) #3
  %16 = getelementptr inbounds i8, ptr %4, i64 32
  store ptr %15, ptr %16, align 8, !tbaa !16
  %17 = tail call noalias dereferenceable_or_null(32) ptr @calloc(i64 noundef 1, i64 noundef 32) #3
  %18 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %17, ptr %18, align 8, !tbaa !17
  %19 = tail call noalias ptr @calloc(i64 noundef %14, i64 noundef 8) #3
  %20 = getelementptr inbounds i8, ptr %4, i64 40
  store ptr %19, ptr %20, align 8, !tbaa !18
  %21 = tail call noalias ptr @calloc(i64 noundef %14, i64 noundef 4) #3
  %22 = getelementptr inbounds i8, ptr %4, i64 48
  store ptr %21, ptr %22, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %17, i64 24
  store i32 %9, ptr %23, align 8, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %17, i64 28
  store i32 %9, ptr %24, align 4, !tbaa !5
  %25 = tail call ptr @permute_kkt(ptr noundef %0, ptr noundef %1, ptr noundef nonnull %4, ptr noundef %2)
  %26 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %25, ptr %26, align 8, !tbaa !20
  %27 = tail call i32 @ldl_prepare(ptr noundef nonnull %4)
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = tail call i32 @ldl_factor(ptr noundef nonnull %4, i32 noundef %28)
  %30 = icmp slt i32 %27, 0
  %31 = icmp slt i32 %29, 0
  %or.cond = select i1 %30, i1 true, i1 %31
  br i1 %or.cond, label %32, label %34

32:                                               ; preds = %3
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %34

34:                                               ; preds = %3, %32
  %.0 = phi ptr [ null, %32 ], [ %4, %3 ]
  ret ptr %.0
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @permute_kkt(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ldl_prepare(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" }
attributes #1 = { nofree nounwind "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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #3 = { nounwind allocsize(0,1) }

!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 28}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!13, !10, i64 0}
!13 = !{!"SCS_LIN_SYS_WORK", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112}
!14 = !{!13, !10, i64 4}
!15 = !{!13, !7, i64 112}
!16 = !{!13, !7, i64 32}
!17 = !{!13, !7, i64 16}
!18 = !{!13, !7, i64 40}
!19 = !{!13, !7, i64 48}
!20 = !{!13, !7, i64 8}


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