; LLVM IR from simbody/simbody :: SimTKmath/Optimizers/src/IpOpt (IpStdInterfaceTNLP)

; 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.SimTKIpopt::StdInterfaceTNLP" = type { %"class.SimTKIpopt::TNLP.base", %"class.SimTKIpopt::SmartPtr", i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.SimTKIpopt::TNLP.base" = type { %"class.SimTKIpopt::ReferencedObject.base" }
%"class.SimTKIpopt::ReferencedObject.base" = type <{ ptr, i32 }>
%"class.SimTKIpopt::SmartPtr" = type { 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10SimTKIpopt16StdInterfaceTNLP11apply_new_xEbiPKd(ptr noundef nonnull align 8 dereferenceable(216), i1 noundef zeroext, i32 noundef, ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN10SimTKIpopt16StdInterfaceTNLP6eval_hEiPKdbdiS2_biPiS3_Pd(ptr noundef nonnull align 8 dereferenceable(216) %0, i32 noundef %1, ptr noundef %2, i1 noundef zeroext %3, double noundef %4, i32 noundef %5, ptr noundef %6, i1 noundef zeroext %7, i32 noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11) unnamed_addr #2 align 2 {
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i8, align 1
  %17 = alloca double, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i8, align 1
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca i32, align 4
  %26 = alloca ptr, align 8
  %27 = alloca i32, align 4
  store ptr %0, ptr %13, align 8, !tbaa !5
  store i32 %1, ptr %14, align 4, !tbaa !9
  store ptr %2, ptr %15, align 8, !tbaa !5
  %28 = zext i1 %3 to i8
  store i8 %28, ptr %16, align 1, !tbaa !11
  store double %4, ptr %17, align 8, !tbaa !13
  store i32 %5, ptr %18, align 4, !tbaa !9
  store ptr %6, ptr %19, align 8, !tbaa !5
  %29 = zext i1 %7 to i8
  store i8 %29, ptr %20, align 1, !tbaa !11
  store i32 %8, ptr %21, align 4, !tbaa !9
  store ptr %9, ptr %22, align 8, !tbaa !5
  store ptr %10, ptr %23, align 8, !tbaa !5
  store ptr %11, ptr %24, align 8, !tbaa !5
  %30 = load ptr, ptr %13, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #5
  store i32 1, ptr %25, align 4, !tbaa !9
  %31 = load ptr, ptr %22, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %39

33:                                               ; preds = %12
  %34 = load ptr, ptr %23, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %39

36:                                               ; preds = %33
  %37 = load ptr, ptr %24, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %48

39:                                               ; preds = %36, %33, %12
  %40 = load ptr, ptr %22, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %108, label %42

42:                                               ; preds = %39
  %43 = load ptr, ptr %23, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %108, label %45

45:                                               ; preds = %42
  %46 = load ptr, ptr %24, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %108

48:                                               ; preds = %45, %36
  %49 = load i8, ptr %16, align 1, !tbaa !11, !range !15, !noundef !16
  %50 = trunc i8 %49 to i1
  %51 = load i32, ptr %14, align 4, !tbaa !9
  %52 = load ptr, ptr %15, align 8, !tbaa !5
  call void @_ZN10SimTKIpopt16StdInterfaceTNLP11apply_new_xEbiPKd(ptr noundef nonnull align 8 dereferenceable(216) %30, i1 noundef zeroext %50, i32 noundef %51, ptr noundef %52)
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #5
  %53 = load i32, ptr %18, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %54, i64 8)
  %56 = extractvalue { i64, i1 } %55, 1
  %57 = extractvalue { i64, i1 } %55, 0
  %58 = select i1 %56, i64 -1, i64 %57
  %59 = call noalias noundef nonnull ptr @_Znam(i64 noundef %58) #6
  store ptr %59, ptr %26, align 8, !tbaa !5
  %60 = load ptr, ptr %19, align 8, !tbaa !5
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %82

62:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #5
  store i32 0, ptr %27, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %78, %62
  %64 = load i32, ptr %27, align 4, !tbaa !9
  %65 = load i32, ptr %18, align 4, !tbaa !9
  %66 = icmp slt i32 %64, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #5
  br label %81

68:                                               ; preds = %63
  %69 = load ptr, ptr %19, align 8, !tbaa !5
  %70 = load i32, ptr %27, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds double, ptr %69, i64 %71
  %73 = load double, ptr %72, align 8, !tbaa !13
  %74 = load ptr, ptr %26, align 8, !tbaa !5
  %75 = load i32, ptr %27, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds double, ptr %74, i64 %76
  store double %73, ptr %77, align 8, !tbaa !13
  br label %78

78:                                               ; preds = %68
  %79 = load i32, ptr %27, align 4, !tbaa !9
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %27, align 4, !tbaa !9
  br label %63, !llvm.loop !17

81:                                               ; preds = %67
  br label %82

82:                                               ; preds = %81, %48
  %83 = getelementptr inbounds %"class.SimTKIpopt::StdInterfaceTNLP", ptr %30, i32 0, i32 19
  %84 = load ptr, ptr %83, align 8, !tbaa !19
  %85 = load i32, ptr %14, align 4, !tbaa !9
  %86 = getelementptr inbounds %"class.SimTKIpopt::StdInterfaceTNLP", ptr %30, i32 0, i32 21
  %87 = load ptr, ptr %86, align 8, !tbaa !24
  %88 = load i8, ptr %16, align 1, !tbaa !11, !range !15, !noundef !16
  %89 = trunc i8 %88 to i1
  %90 = zext i1 %89 to i32
  %91 = load double, ptr %17, align 8, !tbaa !13
  %92 = load i32, ptr %18, align 4, !tbaa !9
  %93 = load ptr, ptr %26, align 8, !tbaa !5
  %94 = load i8, ptr %20, align 1, !tbaa !11, !range !15, !noundef !16
  %95 = trunc i8 %94 to i1
  %96 = zext i1 %95 to i32
  %97 = load i32, ptr %21, align 4, !tbaa !9
  %98 = load ptr, ptr %22, align 8, !tbaa !5
  %99 = load ptr, ptr %23, align 8, !tbaa !5
  %100 = load ptr, ptr %24, align 8, !tbaa !5
  %101 = getelementptr inbounds %"class.SimTKIpopt::StdInterfaceTNLP", ptr %30, i32 0, i32 20
  %102 = load ptr, ptr %101, align 8, !tbaa !25
  %103 = call noundef i32 %84(i32 noundef %85, ptr noundef %87, i32 noundef %90, double noundef %91, i32 noundef %92, ptr noundef %93, i32 noundef %96, i32 noundef %97, ptr noundef %98, ptr noundef %99, ptr noundef %100, ptr noundef %102)
  store i32 %103, ptr %25, align 4, !tbaa !9
  %104 = load ptr, ptr %26, align 8, !tbaa !5
  %105 = icmp eq ptr %104, null
  br i1 %105, label %107, label %106

106:                                              ; preds = %82
  call void @_ZdaPv(ptr noundef %104) #7
  br label %107

107:                                              ; preds = %106, %82
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #5
  br label %109

108:                                              ; preds = %45, %42, %39
  br label %109

109:                                              ; preds = %108, %107
  %110 = load i32, ptr %25, align 4, !tbaa !9
  %111 = icmp ne i32 %110, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #5
  ret i1 %111
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin 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 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nobuiltin allocsize(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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !6, i64 144}
!20 = !{!"_ZTSN10SimTKIpopt16StdInterfaceTNLPE", !21, i64 0, !23, i64 16, !10, i64 24, !10, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208}
!21 = !{!"_ZTSN10SimTKIpopt4TNLPE", !22, i64 0}
!22 = !{!"_ZTSN10SimTKIpopt16ReferencedObjectE", !10, i64 8}
!23 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_10JournalistEEE", !6, i64 0}
!24 = !{!20, !6, i64 160}
!25 = !{!20, !6, i64 152}


; 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN10SimTKIpopt16StdInterfaceTNLP6eval_hEiPKdbdiS2_biPiS3_Pd(ptr noundef nonnull align 8 dereferenceable(216) %0, i32 noundef %1, ptr noundef %2, i1 noundef zeroext %3, double noundef %4, i32 noundef %5, ptr noundef readonly %6, i1 noundef zeroext %7, i32 noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11) unnamed_addr #1 align 2 {
  %13 = icmp ne ptr %9, null
  %14 = icmp ne ptr %10, null
  %or.cond = and i1 %13, %14
  %or.cond.not = xor i1 %or.cond, true
  %15 = icmp ne ptr %11, null
  %or.cond3 = or i1 %15, %or.cond.not
  br i1 %or.cond3, label %16, label %17

16:                                               ; preds = %12
  %or.cond5 = or i1 %13, %14
  %or.cond5.not = xor i1 %or.cond5, true
  %or.cond7 = and i1 %15, %or.cond5.not
  br i1 %or.cond7, label %17, label %34

17:                                               ; preds = %16, %12
  tail call void @_ZN10SimTKIpopt16StdInterfaceTNLP11apply_new_xEbiPKd(ptr noundef nonnull align 8 dereferenceable(216) %0, i1 noundef zeroext %3, i32 noundef %1, ptr noundef %2)
  %18 = zext i32 %5 to i64
  %19 = icmp slt i32 %5, 0
  %20 = shl nuw nsw i64 %18, 3
  %21 = select i1 %19, i64 -1, i64 %20
  %22 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %21) #4
  %.not = icmp ne ptr %6, null
  %23 = icmp sgt i32 %5, 0
  %or.cond40 = and i1 %.not, %23
  br i1 %or.cond40, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %17
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %22, ptr nonnull align 8 %6, i64 %20, i1 false), !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.preheader, %17
  %24 = getelementptr inbounds i8, ptr %0, i64 144
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %0, i64 160
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = zext i1 %3 to i32
  %29 = zext i1 %7 to i32
  %30 = getelementptr inbounds i8, ptr %0, i64 152
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = tail call noundef i32 %25(i32 noundef %1, ptr noundef %27, i32 noundef %28, double noundef %4, i32 noundef %5, ptr noundef nonnull %22, i32 noundef %29, i32 noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11, ptr noundef %31)
  tail call void @_ZdaPv(ptr noundef nonnull %22) #5
  %33 = icmp ne i32 %32, 0
  br label %34

34:                                               ; preds = %16, %.loopexit
  %.037 = phi i1 [ %33, %.loopexit ], [ true, %16 ]
  ret i1 %.037
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { nobuiltin 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 = { nobuiltin allocsize(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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { builtin allocsize(0) }
attributes #5 = { builtin 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !15, i64 144}
!10 = !{!"_ZTSN10SimTKIpopt16StdInterfaceTNLPE", !11, i64 0, !14, i64 16, !13, i64 24, !13, i64 28, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !13, i64 64, !13, i64 68, !13, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112, !15, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !15, i64 152, !15, i64 160, !15, i64 168, !15, i64 176, !15, i64 184, !15, i64 192, !15, i64 200, !15, i64 208}
!11 = !{!"_ZTSN10SimTKIpopt4TNLPE", !12, i64 0}
!12 = !{!"_ZTSN10SimTKIpopt16ReferencedObjectE", !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN10SimTKIpopt8SmartPtrIKNS_10JournalistEEE", !15, i64 0}
!15 = !{!"any pointer", !7, i64 0}
!16 = !{!10, !15, i64 160}
!17 = !{!10, !15, i64 152}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass