; LLVM IR from Zhefan-Xu/Intent-MPC :: trajectory_planner/include/trajectory_planner/mpc_solver (printDifferentialVariables)

; 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.ACADOvariables_ = type { i32, [248 x double], [150 x double], [5611 x double], [240 x double], [3 x double], [8 x double], [150 x double], [150 x double], [1230 x double], [1230 x double] }

@acadoVariables = external global %struct.ACADOvariables_, align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @acado_printDifferentialVariables() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  %3 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %25, %0
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 31
  br i1 %6, label %7, label %28

7:                                                ; preds = %4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %20, %7
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 8
  br i1 %10, label %11, label %23

11:                                               ; preds = %8
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = mul nsw i32 %12, 8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = add nsw i32 %13, %14
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (%struct.ACADOvariables_, ptr @acadoVariables, i32 0, i32 1), i64 0, i64 %16
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %18)
  br label %20

20:                                               ; preds = %11
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !11

23:                                               ; preds = %8
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %25

25:                                               ; preds = %23
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %1, align 4, !tbaa !5
  br label %4, !llvm.loop !13

28:                                               ; preds = %4
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

%struct.ACADOvariables_ = type { i32, [248 x double], [150 x double], [5611 x double], [240 x double], [3 x double], [8 x double], [150 x double], [150 x double], [1230 x double], [1230 x double] }

@acadoVariables = external local_unnamed_addr global %struct.ACADOvariables_, align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @acado_printDifferentialVariables() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %.preheader

.preheader:                                       ; preds = %0, %.preheader
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %.preheader ]
  %2 = shl nuw nsw i64 %indvars.iv, 3
  %3 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 0, i64 %2
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %4)
  %6 = or disjoint i64 %2, 1
  %7 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 0, i64 %6
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %8)
  %10 = or disjoint i64 %2, 2
  %11 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 0, i64 %10
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %12)
  %14 = or disjoint i64 %2, 3
  %15 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 0, i64 %14
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %16)
  %18 = or disjoint i64 %2, 4
  %19 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 0, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %20)
  %22 = or disjoint i64 %2, 5
  %23 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 0, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %24)
  %26 = or disjoint i64 %2, 6
  %27 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 0, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %28)
  %30 = or disjoint i64 %2, 7
  %31 = getelementptr inbounds [248 x double], ptr getelementptr inbounds (i8, ptr @acadoVariables, i64 8), i64 0, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %32)
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 31
  br i1 %exitcond.not, label %35, label %.preheader, !llvm.loop !9

35:                                               ; preds = %.preheader
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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 = { 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" }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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