; LLVM IR from simbody/simbody :: SimTKcommon/src/Parallel2DExecutor.ll (ZNK5SimTK22Parallel2DExecutorImpl5cloneEv)

; 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.SimTK::Parallel2DExecutorImpl" = type <{ %"class.SimTK::PIMPLImplementation.base", i32, %"class.SimTK::Array_", %"class.SimTK::Array_.0", ptr, i8, [7 x i8] }>
%"class.SimTK::PIMPLImplementation.base" = type <{ ptr, i32 }>
%"class.SimTK::Array_" = type { %"class.SimTK::ArrayView_" }
%"class.SimTK::ArrayView_" = type { %"class.SimTK::ArrayViewConst_" }
%"class.SimTK::ArrayViewConst_" = type { ptr, i32, i32 }
%"class.SimTK::Array_.0" = type { %"class.SimTK::ArrayView_.1" }
%"class.SimTK::ArrayView_.1" = type { %"class.SimTK::ArrayViewConst_.2" }
%"class.SimTK::ArrayViewConst_.2" = type { ptr, i32, i32 }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #1

declare noundef i32 @_ZN5SimTK16ParallelExecutor16getNumProcessorsEv() #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZNK5SimTK22Parallel2DExecutorImpl5cloneEv(ptr noundef nonnull align 8 dereferenceable(57) %0) #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %"class.SimTK::Parallel2DExecutorImpl", ptr %6, i32 0, i32 5
  %8 = load i8, ptr %7, align 8, !tbaa !9, !range !20, !noundef !21
  %9 = trunc i8 %8 to i1
  br i1 %9, label %10, label %23

10:                                               ; preds = %1
  %11 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 64) #4
  %12 = getelementptr inbounds %"class.SimTK::Parallel2DExecutorImpl", ptr %6, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !22
  %14 = getelementptr inbounds %"class.SimTK::Parallel2DExecutorImpl", ptr %6, i32 0, i32 4
  %15 = load ptr, ptr %14, align 8, !tbaa !23
  %16 = invoke noundef i32 @_ZN5SimTK16ParallelExecutor16getNumProcessorsEv()
          to label %17 unwind label %19

17:                                               ; preds = %10
  invoke void @_ZN5SimTK22Parallel2DExecutorImplC1Eii(ptr noundef nonnull align 8 dereferenceable(57) %11, i32 noundef %13, i32 noundef %16)
          to label %18 unwind label %19

18:                                               ; preds = %17
  store ptr %11, ptr %2, align 8
  br label %34

19:                                               ; preds = %17, %10
  %20 = landingpad { ptr, i32 }
          cleanup
  %21 = extractvalue { ptr, i32 } %20, 0
  store ptr %21, ptr %4, align 8
  %22 = extractvalue { ptr, i32 } %20, 1
  store i32 %22, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %11, i64 noundef 64) #5
  br label %36

23:                                               ; preds = %1
  %24 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 64) #4
  %25 = getelementptr inbounds %"class.SimTK::Parallel2DExecutorImpl", ptr %6, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !22
  %27 = getelementptr inbounds %"class.SimTK::Parallel2DExecutorImpl", ptr %6, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !23
  invoke void @_ZN5SimTK22Parallel2DExecutorImplC1EiRNS_16ParallelExecutorE(ptr noundef nonnull align 8 dereferenceable(57) %24, i32 noundef %26, ptr noundef nonnull align 8 dereferenceable(8) %28)
          to label %29 unwind label %30

29:                                               ; preds = %23
  store ptr %24, ptr %2, align 8
  br label %34

30:                                               ; preds = %23
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %4, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %24, i64 noundef 64) #5
  br label %36

34:                                               ; preds = %29, %18
  %35 = load ptr, ptr %2, align 8
  ret ptr %35

36:                                               ; preds = %30, %19
  %37 = load ptr, ptr %4, align 8
  %38 = load i32, ptr %5, align 4
  %39 = insertvalue { ptr, i32 } poison, ptr %37, 0
  %40 = insertvalue { ptr, i32 } %39, i32 %38, 1
  resume { ptr, i32 } %40
}

declare void @_ZN5SimTK22Parallel2DExecutorImplC1Eii(ptr, i32, i32)

declare void @_ZN5SimTK22Parallel2DExecutorImplC1EiRNS_16ParallelExecutorE(ptr, i32, ptr)

attributes #0 = { 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 #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 = { "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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !19, i64 56}
!10 = !{!"_ZTSN5SimTK22Parallel2DExecutorImplE", !11, i64 0, !12, i64 12, !13, i64 16, !16, i64 32, !6, i64 48, !19, i64 56}
!11 = !{!"_ZTSN5SimTK19PIMPLImplementationINS_18Parallel2DExecutorENS_22Parallel2DExecutorImplEEE", !6, i64 0, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN5SimTK6Array_INS0_ISt4pairIiiEjEEjEE", !14, i64 0}
!14 = !{!"_ZTSN5SimTK10ArrayView_INS_6Array_ISt4pairIiiEjEEjEE", !15, i64 0}
!15 = !{!"_ZTSN5SimTK15ArrayViewConst_INS_6Array_ISt4pairIiiEjEEjEE", !6, i64 0, !12, i64 8, !12, i64 12}
!16 = !{!"_ZTSN5SimTK6Array_IijEE", !17, i64 0}
!17 = !{!"_ZTSN5SimTK10ArrayView_IijEE", !18, i64 0}
!18 = !{!"_ZTSN5SimTK15ArrayViewConst_IijEE", !6, i64 0, !12, i64 8, !12, i64 12}
!19 = !{!"bool", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!10, !12, i64 12}
!23 = !{!10, !6, i64 48}


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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

declare noundef i32 @_ZN5SimTK16ParallelExecutor16getNumProcessorsEv() local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZNK5SimTK22Parallel2DExecutorImpl5cloneEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(57) %0) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 56
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !19, !noundef !20
  %4 = trunc nuw i8 %3 to i1
  %5 = tail call noalias noundef nonnull dereferenceable(64) ptr @_Znwm(i64 noundef 64) #4
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !21
  br i1 %4, label %8, label %13

8:                                                ; preds = %1
  %9 = invoke noundef i32 @_ZN5SimTK16ParallelExecutor16getNumProcessorsEv()
          to label %10 unwind label %11

10:                                               ; preds = %8
  invoke void @_ZN5SimTK22Parallel2DExecutorImplC1Eii(ptr noundef nonnull align 8 dereferenceable(57) %5, i32 noundef %7, i32 noundef %9)
          to label %18 unwind label %11

11:                                               ; preds = %10, %8
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %19

13:                                               ; preds = %1
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %15 = load ptr, ptr %14, align 8, !tbaa !22
  invoke void @_ZN5SimTK22Parallel2DExecutorImplC1EiRNS_16ParallelExecutorE(ptr noundef nonnull align 8 dereferenceable(57) %5, i32 noundef %7, ptr noundef nonnull align 8 dereferenceable(8) %15)
          to label %18 unwind label %16

16:                                               ; preds = %13
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %19

18:                                               ; preds = %13, %10
  ret ptr %5

19:                                               ; preds = %16, %11
  %.pn = phi { ptr, i32 } [ %12, %11 ], [ %17, %16 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 64) #5
  resume { ptr, i32 } %.pn
}

declare void @_ZN5SimTK22Parallel2DExecutorImplC1Eii(ptr, i32, i32) local_unnamed_addr

declare void @_ZN5SimTK22Parallel2DExecutorImplC1EiRNS_16ParallelExecutorE(ptr, i32, ptr) local_unnamed_addr

attributes #0 = { 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 #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 = { "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 = { 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 #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, !18, i64 56}
!6 = !{!"_ZTSN5SimTK22Parallel2DExecutorImplE", !7, i64 0, !11, i64 12, !12, i64 16, !15, i64 32, !8, i64 48, !18, i64 56}
!7 = !{!"_ZTSN5SimTK19PIMPLImplementationINS_18Parallel2DExecutorENS_22Parallel2DExecutorImplEEE", !8, i64 0, !11, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTSN5SimTK6Array_INS0_ISt4pairIiiEjEEjEE", !13, i64 0}
!13 = !{!"_ZTSN5SimTK10ArrayView_INS_6Array_ISt4pairIiiEjEEjEE", !14, i64 0}
!14 = !{!"_ZTSN5SimTK15ArrayViewConst_INS_6Array_ISt4pairIiiEjEEjEE", !8, i64 0, !11, i64 8, !11, i64 12}
!15 = !{!"_ZTSN5SimTK6Array_IijEE", !16, i64 0}
!16 = !{!"_ZTSN5SimTK10ArrayView_IijEE", !17, i64 0}
!17 = !{!"_ZTSN5SimTK15ArrayViewConst_IijEE", !8, i64 0, !11, i64 8, !11, i64 12}
!18 = !{!"bool", !9, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!6, !11, i64 12}
!22 = !{!6, !8, i64 48}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass