; LLVM IR from opensim-org/opensim-moco :: tropter/external/snopt-interface/src (snopt_cwrap)

; 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.snProblem = type { ptr, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, i32, i32, ptr, ptr }

; 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
declare dso_local void @setWorkspaceA(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @snJac(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13) #1 {
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca i32, align 4
  %32 = alloca i32, align 4
  %33 = alloca i32, align 4
  %34 = alloca i32, align 4
  store ptr %0, ptr %15, align 8, !tbaa !5
  store i32 %1, ptr %16, align 4, !tbaa !9
  store i32 %2, ptr %17, align 4, !tbaa !9
  store ptr %3, ptr %18, align 8, !tbaa !5
  store ptr %4, ptr %19, align 8, !tbaa !5
  store ptr %5, ptr %20, align 8, !tbaa !5
  store ptr %6, ptr %21, align 8, !tbaa !5
  store ptr %7, ptr %22, align 8, !tbaa !5
  store ptr %8, ptr %23, align 8, !tbaa !5
  store ptr %9, ptr %24, align 8, !tbaa !5
  store ptr %10, ptr %25, align 8, !tbaa !5
  store ptr %11, ptr %26, align 8, !tbaa !5
  store ptr %12, ptr %27, align 8, !tbaa !5
  store ptr %13, ptr %28, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %31) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %33) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %34) #3
  %35 = load i32, ptr %17, align 4, !tbaa !9
  %36 = load i32, ptr %16, align 4, !tbaa !9
  %37 = mul nsw i32 %35, %36
  store i32 %37, ptr %31, align 4, !tbaa !9
  %38 = load i32, ptr %17, align 4, !tbaa !9
  %39 = load i32, ptr %16, align 4, !tbaa !9
  %40 = mul nsw i32 %38, %39
  store i32 %40, ptr %32, align 4, !tbaa !9
  %41 = load ptr, ptr %15, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.snProblem, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 8, !tbaa !11
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %51

45:                                               ; preds = %14
  %46 = load ptr, ptr %15, align 8, !tbaa !5
  %47 = load i32, ptr %16, align 4, !tbaa !9
  %48 = load i32, ptr %17, align 4, !tbaa !9
  %49 = load i32, ptr %31, align 4, !tbaa !9
  %50 = load i32, ptr %32, align 4, !tbaa !9
  call void @setWorkspaceA(ptr noundef %46, i32 noundef %47, i32 noundef %48, i32 noundef %49, i32 noundef %50)
  br label %51

51:                                               ; preds = %45, %14
  %52 = load i32, ptr %16, align 4, !tbaa !9
  %53 = load i32, ptr %17, align 4, !tbaa !9
  %54 = load ptr, ptr %18, align 8, !tbaa !5
  %55 = load ptr, ptr %19, align 8, !tbaa !5
  %56 = load ptr, ptr %20, align 8, !tbaa !5
  %57 = load ptr, ptr %21, align 8, !tbaa !5
  %58 = load ptr, ptr %23, align 8, !tbaa !5
  %59 = load ptr, ptr %24, align 8, !tbaa !5
  %60 = load i32, ptr %31, align 4, !tbaa !9
  %61 = load ptr, ptr %22, align 8, !tbaa !5
  %62 = load ptr, ptr %25, align 8, !tbaa !5
  %63 = load ptr, ptr %27, align 8, !tbaa !5
  %64 = load ptr, ptr %28, align 8, !tbaa !5
  %65 = load i32, ptr %32, align 4, !tbaa !9
  %66 = load ptr, ptr %26, align 8, !tbaa !5
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.snProblem, ptr %67, i32 0, i32 14
  %69 = load ptr, ptr %68, align 8, !tbaa !13
  %70 = load ptr, ptr %15, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.snProblem, ptr %70, i32 0, i32 13
  %72 = load i32, ptr %71, align 4, !tbaa !14
  %73 = load ptr, ptr %15, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.snProblem, ptr %73, i32 0, i32 15
  %75 = load ptr, ptr %74, align 8, !tbaa !15
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.snProblem, ptr %76, i32 0, i32 12
  %78 = load i32, ptr %77, align 8, !tbaa !16
  %79 = load ptr, ptr %15, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.snProblem, ptr %79, i32 0, i32 10
  %81 = load ptr, ptr %80, align 8, !tbaa !17
  %82 = load ptr, ptr %15, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.snProblem, ptr %82, i32 0, i32 9
  %84 = load i32, ptr %83, align 4, !tbaa !18
  %85 = load ptr, ptr %15, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.snProblem, ptr %85, i32 0, i32 11
  %87 = load ptr, ptr %86, align 8, !tbaa !19
  %88 = load ptr, ptr %15, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.snProblem, ptr %88, i32 0, i32 8
  %90 = load i32, ptr %89, align 8, !tbaa !20
  call void @f_snjac(ptr noundef %30, i32 noundef %52, i32 noundef %53, ptr noundef %54, ptr noundef %55, ptr noundef %56, ptr noundef %57, ptr noundef %58, ptr noundef %59, i32 noundef %60, ptr noundef %61, ptr noundef %62, ptr noundef %63, ptr noundef %64, i32 noundef %65, ptr noundef %66, ptr noundef %33, ptr noundef %34, ptr noundef %69, i32 noundef %72, ptr noundef %75, i32 noundef %78, ptr noundef %81, i32 noundef %84, ptr noundef %87, i32 noundef %90)
  store i32 0, ptr %29, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %109, %51
  %92 = load i32, ptr %29, align 4, !tbaa !9
  %93 = load ptr, ptr %22, align 8, !tbaa !5
  %94 = load i32, ptr %93, align 4, !tbaa !9
  %95 = icmp slt i32 %92, %94
  br i1 %95, label %96, label %112

96:                                               ; preds = %91
  %97 = load ptr, ptr %23, align 8, !tbaa !5
  %98 = load i32, ptr %29, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i32, ptr %97, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !9
  %102 = add nsw i32 %101, -1
  store i32 %102, ptr %100, align 4, !tbaa !9
  %103 = load ptr, ptr %24, align 8, !tbaa !5
  %104 = load i32, ptr %29, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds i32, ptr %103, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !9
  %108 = add nsw i32 %107, -1
  store i32 %108, ptr %106, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %96
  %110 = load i32, ptr %29, align 4, !tbaa !9
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %29, align 4, !tbaa !9
  br label %91, !llvm.loop !21

112:                                              ; preds = %91
  store i32 0, ptr %29, align 4, !tbaa !9
  br label %113

113:                                              ; preds = %131, %112
  %114 = load i32, ptr %29, align 4, !tbaa !9
  %115 = load ptr, ptr %26, align 8, !tbaa !5
  %116 = load i32, ptr %115, align 4, !tbaa !9
  %117 = icmp slt i32 %114, %116
  br i1 %117, label %118, label %134

118:                                              ; preds = %113
  %119 = load ptr, ptr %27, align 8, !tbaa !5
  %120 = load i32, ptr %29, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i32, ptr %119, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !9
  %124 = add nsw i32 %123, -1
  store i32 %124, ptr %122, align 4, !tbaa !9
  %125 = load ptr, ptr %28, align 8, !tbaa !5
  %126 = load i32, ptr %29, align 4, !tbaa !9
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds i32, ptr %125, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !9
  %130 = add nsw i32 %129, -1
  store i32 %130, ptr %128, align 4, !tbaa !9
  br label %131

131:                                              ; preds = %118
  %132 = load i32, ptr %29, align 4, !tbaa !9
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %29, align 4, !tbaa !9
  br label %113, !llvm.loop !23

134:                                              ; preds = %113
  %135 = load i32, ptr %30, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %34) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %31) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #3
  ret i32 %135
}

declare void @f_snjac(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 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 = { "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/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, !10, i64 56, !10, i64 60, !6, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96}
!13 = !{!12, !6, i64 88}
!14 = !{!12, !10, i64 84}
!15 = !{!12, !6, i64 96}
!16 = !{!12, !10, i64 80}
!17 = !{!12, !6, i64 64}
!18 = !{!12, !10, i64 60}
!19 = !{!12, !6, i64 72}
!20 = !{!12, !10, i64 56}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


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

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

; Function Attrs: nounwind uwtable
declare dso_local void @setWorkspaceA(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @snJac(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11, ptr noundef %12, ptr noundef %13) local_unnamed_addr #1 {
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %17) #3
  %18 = mul nsw i32 %2, %1
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load i32, ptr %19, align 8, !tbaa !5
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %14
  tail call void @setWorkspaceA(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef %18, i32 noundef %18)
  br label %23

23:                                               ; preds = %22, %14
  %24 = getelementptr inbounds i8, ptr %0, i64 88
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %0, i64 84
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %0, i64 96
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %0, i64 80
  %31 = load i32, ptr %30, align 8, !tbaa !14
  %32 = getelementptr inbounds i8, ptr %0, i64 64
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = getelementptr inbounds i8, ptr %0, i64 60
  %35 = load i32, ptr %34, align 4, !tbaa !16
  %36 = getelementptr inbounds i8, ptr %0, i64 72
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = getelementptr inbounds i8, ptr %0, i64 56
  %39 = load i32, ptr %38, align 8, !tbaa !18
  call void @f_snjac(ptr noundef nonnull %15, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %8, ptr noundef %9, i32 noundef %18, ptr noundef %7, ptr noundef %10, ptr noundef %12, ptr noundef %13, i32 noundef %18, ptr noundef %11, ptr noundef nonnull %16, ptr noundef nonnull %17, ptr noundef %25, i32 noundef %27, ptr noundef %29, i32 noundef %31, ptr noundef %33, i32 noundef %35, ptr noundef %37, i32 noundef %39) #3
  %40 = load i32, ptr %7, align 4, !tbaa !19
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %23
  %42 = load i32, ptr %11, align 4, !tbaa !19
  %43 = icmp sgt i32 %42, 0
  br i1 %43, label %.lr.ph48, label %._crit_edge

.lr.ph:                                           ; preds = %23, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %23 ]
  %44 = getelementptr inbounds i32, ptr %8, i64 %indvars.iv
  %45 = load i32, ptr %44, align 4, !tbaa !19
  %46 = add nsw i32 %45, -1
  store i32 %46, ptr %44, align 4, !tbaa !19
  %47 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  %48 = load i32, ptr %47, align 4, !tbaa !19
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %47, align 4, !tbaa !19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %50 = load i32, ptr %7, align 4, !tbaa !19
  %51 = sext i32 %50 to i64
  %52 = icmp slt i64 %indvars.iv.next, %51
  br i1 %52, label %.lr.ph, label %.preheader, !llvm.loop !20

.lr.ph48:                                         ; preds = %.preheader, %.lr.ph48
  %indvars.iv50 = phi i64 [ %indvars.iv.next51, %.lr.ph48 ], [ 0, %.preheader ]
  %53 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv50
  %54 = load i32, ptr %53, align 4, !tbaa !19
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr %53, align 4, !tbaa !19
  %56 = getelementptr inbounds i32, ptr %13, i64 %indvars.iv50
  %57 = load i32, ptr %56, align 4, !tbaa !19
  %58 = add nsw i32 %57, -1
  store i32 %58, ptr %56, align 4, !tbaa !19
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %59 = load i32, ptr %11, align 4, !tbaa !19
  %60 = sext i32 %59 to i64
  %61 = icmp slt i64 %indvars.iv.next51, %60
  br i1 %61, label %.lr.ph48, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph48, %.preheader
  %62 = load i32, ptr %15, align 4, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #3
  ret i32 %62
}

declare void @f_snjac(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 }

!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, !10, i64 56, !10, i64 60, !7, i64 64, !7, i64 72, !10, i64 80, !10, i64 84, !7, i64 88, !7, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 88}
!12 = !{!6, !10, i64 84}
!13 = !{!6, !7, i64 96}
!14 = !{!6, !10, i64 80}
!15 = !{!6, !7, i64 64}
!16 = !{!6, !10, i64 60}
!17 = !{!6, !7, i64 72}
!18 = !{!6, !10, i64 56}
!19 = !{!10, !10, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass