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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5SimTK22Parallel2DExecutorImpl11addTriangleEiiii(ptr noundef nonnull align 8 dereferenceable(57) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %11 = load ptr, ptr %6, align 8
  %12 = load i32, ptr %10, align 4, !tbaa !9
  %13 = icmp sgt i32 %12, 1
  br i1 %13, label %14, label %41

14:                                               ; preds = %5
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = mul nsw i32 2, %15
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = mul nsw i32 2, %17
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = mul nsw i32 2, %19
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = sub nsw i32 %21, 1
  call void @_ZN5SimTK22Parallel2DExecutorImpl9addSquareEiiii(ptr noundef nonnull align 8 dereferenceable(57) %11, i32 noundef %16, i32 noundef %18, i32 noundef %20, i32 noundef %22)
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = mul nsw i32 2, %23
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = mul nsw i32 2, %25
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = mul nsw i32 2, %27
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = sub nsw i32 %29, 1
  call void @_ZN5SimTK22Parallel2DExecutorImpl11addTriangleEiiii(ptr noundef nonnull align 8 dereferenceable(57) %11, i32 noundef %24, i32 noundef %26, i32 noundef %28, i32 noundef %30)
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = mul nsw i32 2, %31
  %33 = add nsw i32 %32, 1
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = mul nsw i32 2, %34
  %36 = add nsw i32 %35, 1
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = mul nsw i32 2, %37
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = sub nsw i32 %39, 1
  call void @_ZN5SimTK22Parallel2DExecutorImpl11addTriangleEiiii(ptr noundef nonnull align 8 dereferenceable(57) %11, i32 noundef %33, i32 noundef %36, i32 noundef %38, i32 noundef %40)
  br label %41

41:                                               ; preds = %14, %5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5SimTK22Parallel2DExecutorImpl9addSquareEiiii(ptr noundef nonnull align 8 dereferenceable(57), i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0 align 2

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

!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}


; 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 uwtable
define dso_local void @_ZN5SimTK22Parallel2DExecutorImpl11addTriangleEiiii(ptr noundef nonnull align 8 dereferenceable(57) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = icmp sgt i32 %4, 1
  br i1 %6, label %tailrecurse, label %tailrecurse._crit_edge

tailrecurse:                                      ; preds = %5, %tailrecurse
  %.tr1620 = phi i32 [ %10, %tailrecurse ], [ %4, %5 ]
  %.tr1519 = phi i32 [ %9, %tailrecurse ], [ %3, %5 ]
  %.tr1418 = phi i32 [ %12, %tailrecurse ], [ %2, %5 ]
  %.tr1317 = phi i32 [ %11, %tailrecurse ], [ %1, %5 ]
  %7 = shl nsw i32 %.tr1317, 1
  %8 = shl nsw i32 %.tr1418, 1
  %9 = shl nsw i32 %.tr1519, 1
  %10 = add nsw i32 %.tr1620, -1
  tail call void @_ZN5SimTK22Parallel2DExecutorImpl9addSquareEiiii(ptr noundef nonnull align 8 dereferenceable(57) %0, i32 noundef %7, i32 noundef %8, i32 noundef %9, i32 noundef %10)
  tail call void @_ZN5SimTK22Parallel2DExecutorImpl11addTriangleEiiii(ptr noundef nonnull align 8 dereferenceable(57) %0, i32 noundef %7, i32 noundef %8, i32 noundef %9, i32 noundef %10)
  %11 = or disjoint i32 %7, 1
  %12 = or disjoint i32 %8, 1
  %13 = icmp ugt i32 %.tr1620, 2
  br i1 %13, label %tailrecurse, label %tailrecurse._crit_edge

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5SimTK22Parallel2DExecutorImpl9addSquareEiiii(ptr noundef nonnull align 8 dereferenceable(57), i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

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

!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)"}


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