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

; 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.snoptProblem = type { [30 x i8], i32, i32, i32, i32, i32, ptr, ptr, i32, i32, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [112 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__._ZN13snoptProblemC12setWorkspaceEiiiiiii = external hidden unnamed_addr constant [68 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12snoptProblem8reallocIEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12snoptProblem8reallocREi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13snoptProblemC12setWorkspaceEiiiiiii(ptr noundef nonnull align 8 dereferenceable(128) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) #1 align 2 {
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store i32 %4, ptr %13, align 4, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !9
  store i32 %6, ptr %15, align 4, !tbaa !9
  store i32 %7, ptr %16, align 4, !tbaa !9
  %20 = load ptr, ptr %9, align 8
  %21 = getelementptr inbounds %class.snoptProblem, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = icmp eq i32 %22, 1
  br i1 %23, label %24, label %25

24:                                               ; preds = %8
  br label %27

25:                                               ; preds = %8
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 453, ptr noundef @__PRETTY_FUNCTION__._ZN13snoptProblemC12setWorkspaceEiiiiiii) #4
  unreachable

26:                                               ; No predecessors!
  br label %27

27:                                               ; preds = %26, %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %28 = load i32, ptr %13, align 4, !tbaa !9
  %29 = icmp slt i32 %28, 0
  br i1 %29, label %30, label %34

30:                                               ; preds = %27
  %31 = load i32, ptr %14, align 4, !tbaa !9
  %32 = load i32, ptr %16, align 4, !tbaa !9
  %33 = mul nsw i32 %31, %32
  store i32 %33, ptr %13, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %30, %27
  %35 = load i32, ptr %10, align 4, !tbaa !9
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = load i32, ptr %12, align 4, !tbaa !9
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = load i32, ptr %14, align 4, !tbaa !9
  %40 = load i32, ptr %15, align 4, !tbaa !9
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = getelementptr inbounds %class.snoptProblem, ptr %20, i32 0, i32 7
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = getelementptr inbounds %class.snoptProblem, ptr %20, i32 0, i32 4
  %45 = load i32, ptr %44, align 4, !tbaa !14
  %46 = getelementptr inbounds %class.snoptProblem, ptr %20, i32 0, i32 6
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = getelementptr inbounds %class.snoptProblem, ptr %20, i32 0, i32 5
  %49 = load i32, ptr %48, align 8, !tbaa !16
  call void @f_snmem(ptr noundef %17, i32 noundef %35, i32 noundef %36, i32 noundef %37, i32 noundef %38, i32 noundef %39, i32 noundef %40, i32 noundef %41, ptr noundef %18, ptr noundef %19, ptr noundef %43, i32 noundef %45, ptr noundef %47, i32 noundef %49)
  %50 = load i32, ptr %18, align 4, !tbaa !9
  %51 = getelementptr inbounds %class.snoptProblem, ptr %20, i32 0, i32 4
  %52 = load i32, ptr %51, align 4, !tbaa !14
  %53 = icmp sgt i32 %50, %52
  br i1 %53, label %54, label %56

54:                                               ; preds = %34
  %55 = load i32, ptr %18, align 4, !tbaa !9
  call void @_ZN12snoptProblem8reallocIEi(ptr noundef nonnull align 8 dereferenceable(96) %20, i32 noundef %55)
  br label %56

56:                                               ; preds = %54, %34
  %57 = load i32, ptr %19, align 4, !tbaa !9
  %58 = getelementptr inbounds %class.snoptProblem, ptr %20, i32 0, i32 5
  %59 = load i32, ptr %58, align 8, !tbaa !16
  %60 = icmp sgt i32 %57, %59
  br i1 %60, label %61, label %63

61:                                               ; preds = %56
  %62 = load i32, ptr %19, align 4, !tbaa !9
  call void @_ZN12snoptProblem8reallocREi(ptr noundef nonnull align 8 dereferenceable(96) %20, i32 noundef %62)
  br label %63

63:                                               ; preds = %61, %56
  %64 = getelementptr inbounds %class.snoptProblem, ptr %20, i32 0, i32 2
  store i32 1, ptr %64, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  ret void
}

declare void @f_snmem(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

attributes #0 = { noreturn 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 #1 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { noreturn nounwind }
attributes #5 = { 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 32}
!12 = !{!"_ZTS12snoptProblem", !7, i64 0, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !6, i64 80, !6, i64 88}
!13 = !{!12, !6, i64 64}
!14 = !{!12, !10, i64 44}
!15 = !{!12, !6, i64 56}
!16 = !{!12, !10, i64 48}
!17 = !{!12, !10, i64 36}


; 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 [112 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__._ZN13snoptProblemC12setWorkspaceEiiiiiii = external hidden unnamed_addr constant [68 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12snoptProblem8reallocIEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12snoptProblem8reallocREi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13snoptProblemC12setWorkspaceEiiiiiii(ptr noundef nonnull align 8 dereferenceable(128) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7) local_unnamed_addr #1 align 2 {
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load i32, ptr %12, align 8, !tbaa !5
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %16, label %15

15:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 453, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN13snoptProblemC12setWorkspaceEiiiiiii) #4
  unreachable

16:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #5
  %17 = icmp slt i32 %4, 0
  %18 = mul nsw i32 %7, %5
  %spec.select = select i1 %17, i32 %18, i32 %4
  %19 = getelementptr inbounds i8, ptr %0, i64 64
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %0, i64 44
  %22 = load i32, ptr %21, align 4, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %0, i64 48
  %26 = load i32, ptr %25, align 8, !tbaa !14
  call void @f_snmem(ptr noundef nonnull %9, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %spec.select, i32 noundef %5, i32 noundef %6, i32 noundef %7, ptr noundef nonnull %10, ptr noundef nonnull %11, ptr noundef %20, i32 noundef %22, ptr noundef %24, i32 noundef %26)
  %27 = load i32, ptr %10, align 4, !tbaa !15
  %28 = load i32, ptr %21, align 4, !tbaa !12
  %29 = icmp sgt i32 %27, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %16
  call void @_ZN12snoptProblem8reallocIEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %27)
  br label %31

31:                                               ; preds = %30, %16
  %32 = load i32, ptr %11, align 4, !tbaa !15
  %33 = load i32, ptr %25, align 8, !tbaa !14
  %34 = icmp sgt i32 %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  call void @_ZN12snoptProblem8reallocREi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %32)
  br label %36

36:                                               ; preds = %35, %31
  %37 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 1, ptr %37, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #5
  ret void
}

declare void @f_snmem(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { noreturn 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 #1 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { noreturn nounwind }
attributes #5 = { 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, !9, i64 32}
!6 = !{!"_ZTS12snoptProblem", !7, i64 0, !9, i64 32, !9, i64 36, !9, i64 40, !9, i64 44, !9, i64 48, !10, i64 56, !10, i64 64, !9, i64 72, !9, i64 76, !10, i64 80, !10, i64 88}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !10, i64 64}
!12 = !{!6, !9, i64 44}
!13 = !{!6, !10, i64 56}
!14 = !{!6, !9, i64 48}
!15 = !{!9, !9, i64 0}
!16 = !{!6, !9, i64 36}


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