; LLVM IR from Tencent-RoboticsX/jbdl :: src/jbdl/experimental/qpoases/src (Matrices)

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

%"class.qpOASES::SparseMatrix" = type { ptr, i32, i32, ptr, ptr, ptr, ptr, %"class.qpOASES::Matrix.base" }
%"class.qpOASES::Matrix.base" = type <{ ptr, i32 }>

@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK7qpOASES12SparseMatrix11writeToFileEP8_IO_FILEPKc(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %28, %3
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = getelementptr inbounds %"class.qpOASES::SparseMatrix", ptr %10, i32 0, i32 2
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp sle i32 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %31

17:                                               ; preds = %11
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = getelementptr inbounds %"class.qpOASES::SparseMatrix", ptr %10, i32 0, i32 4
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i32, ptr %22, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef @.str.4, ptr noundef %19, i32 noundef %20, i32 noundef %26) #3
  br label %28

28:                                               ; preds = %17
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %7, align 4, !tbaa !9
  br label %11, !llvm.loop !14

31:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %54, %31
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = getelementptr inbounds %"class.qpOASES::SparseMatrix", ptr %10, i32 0, i32 4
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = getelementptr inbounds %"class.qpOASES::SparseMatrix", ptr %10, i32 0, i32 2
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %35, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = icmp slt i32 %33, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %57

43:                                               ; preds = %32
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = getelementptr inbounds %"class.qpOASES::SparseMatrix", ptr %10, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i32, ptr %48, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef @.str.5, ptr noundef %45, i32 noundef %46, i32 noundef %52) #3
  br label %54

54:                                               ; preds = %43
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %8, align 4, !tbaa !9
  br label %32, !llvm.loop !17

57:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %80, %57
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = getelementptr inbounds %"class.qpOASES::SparseMatrix", ptr %10, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  %62 = getelementptr inbounds %"class.qpOASES::SparseMatrix", ptr %10, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i32, ptr %61, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = icmp slt i32 %59, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %83

69:                                               ; preds = %58
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = getelementptr inbounds %"class.qpOASES::SparseMatrix", ptr %10, i32 0, i32 6
  %74 = load ptr, ptr %73, align 8, !tbaa !18
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds double, ptr %74, i64 %76
  %78 = load double, ptr %77, align 8, !tbaa !19
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef @.str.6, ptr noundef %71, i32 noundef %72, double noundef %78) #3
  br label %80

80:                                               ; preds = %69
  %81 = load i32, ptr %9, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %9, align 4, !tbaa !9
  br label %58, !llvm.loop !21

83:                                               ; preds = %68
  ret i32 0
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 "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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_ZTSN7qpOASES12SparseMatrixE", !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!13 = !{!12, !6, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!12, !6, i64 16}
!17 = distinct !{!17, !15}
!18 = !{!12, !6, i64 40}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = distinct !{!21, !15}


; 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.4 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local noundef i32 @_ZNK7qpOASES12SparseMatrix11writeToFileEP8_IO_FILEPKc(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0, ptr nocapture noundef %1, ptr noundef %2) unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not22 = icmp slt i32 %5, 0
  br i1 %.not22, label %..preheader20_crit_edge, label %.lr.ph

..preheader20_crit_edge:                          ; preds = %3
  %.pre = sext i32 %5 to i64
  br label %.preheader20

.lr.ph:                                           ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  br label %13

.preheader20:                                     ; preds = %13, %..preheader20_crit_edge
  %.pre-phi35 = phi i64 [ %.pre, %..preheader20_crit_edge ], [ %20, %13 ]
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i32, ptr %8, i64 %.pre-phi35
  %10 = load i32, ptr %9, align 4, !tbaa !12
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph25, label %._crit_edge

.lr.ph25:                                         ; preds = %.preheader20
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  br label %23

13:                                               ; preds = %.lr.ph, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %13 ]
  %14 = load ptr, ptr %6, align 8, !tbaa !11
  %15 = getelementptr inbounds i32, ptr %14, i64 %indvars.iv
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = trunc nuw nsw i64 %indvars.iv to i32
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.4, ptr noundef %2, i32 noundef %17, i32 noundef %16) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %.not.not = icmp slt i64 %indvars.iv, %20
  br i1 %.not.not, label %13, label %.preheader20, !llvm.loop !13

.preheader:                                       ; preds = %23
  %21 = icmp sgt i32 %33, 0
  br i1 %21, label %.lr.ph27, label %._crit_edge

.lr.ph27:                                         ; preds = %.preheader
  %22 = getelementptr inbounds i8, ptr %0, i64 40
  br label %36

23:                                               ; preds = %.lr.ph25, %23
  %indvars.iv29 = phi i64 [ 0, %.lr.ph25 ], [ %indvars.iv.next30, %23 ]
  %24 = load ptr, ptr %12, align 8, !tbaa !15
  %25 = getelementptr inbounds i32, ptr %24, i64 %indvars.iv29
  %26 = load i32, ptr %25, align 4, !tbaa !12
  %27 = trunc nuw nsw i64 %indvars.iv29 to i32
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.5, ptr noundef %2, i32 noundef %27, i32 noundef %26) #2
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %29 = load ptr, ptr %7, align 8, !tbaa !11
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i32, ptr %29, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next30, %34
  br i1 %35, label %23, label %.preheader, !llvm.loop !16

._crit_edge:                                      ; preds = %36, %.preheader20, %.preheader
  ret i32 0

36:                                               ; preds = %.lr.ph27, %36
  %indvars.iv32 = phi i64 [ 0, %.lr.ph27 ], [ %indvars.iv.next33, %36 ]
  %37 = load ptr, ptr %22, align 8, !tbaa !17
  %38 = getelementptr inbounds double, ptr %37, i64 %indvars.iv32
  %39 = load double, ptr %38, align 8, !tbaa !18
  %40 = trunc nuw nsw i64 %indvars.iv32 to i32
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %1, ptr noundef nonnull @.str.6, ptr noundef %2, i32 noundef %40, double noundef %39) #2
  %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
  %42 = load ptr, ptr %7, align 8, !tbaa !11
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %42, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !12
  %47 = sext i32 %46 to i64
  %48 = icmp slt i64 %indvars.iv.next33, %47
  br i1 %48, label %36, label %._crit_edge, !llvm.loop !20
}

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

attributes #0 = { mustprogress 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 = { 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 = { 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, !7, i64 12}
!6 = !{!"_ZTSN7qpOASES12SparseMatrixE", !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !10, i64 16}
!16 = distinct !{!16, !14}
!17 = !{!6, !10, i64 40}
!18 = !{!19, !19, i64 0}
!19 = !{!"double", !8, i64 0}
!20 = distinct !{!20, !14}


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