; LLVM IR from ESPboy-edu/ESPboy_tinyphysicsengine :: programs (hello)

; 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.TPE_Body = type { ptr, i8, ptr, i8, i16, i16, i16, i8, i8 }
%struct.TPE_Joint = type { %struct.TPE_Vec3, [3 x i16], i8 }
%struct.TPE_Vec3 = type { i32, i32, i32 }

; 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
define dso_local void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.TPE_Body, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #2
  store i16 0, ptr %6, align 2, !tbaa !14
  br label %12

12:                                               ; preds = %50, %2
  %13 = load i16, ptr %6, align 2, !tbaa !14
  %14 = zext i16 %13 to i32
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.TPE_Body, ptr %15, i32 0, i32 1
  %17 = load i8, ptr %16, align 8, !tbaa !15
  %18 = zext i8 %17 to i32
  %19 = icmp slt i32 %14, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %12
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #2
  br label %53

21:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  store i8 0, ptr %8, align 1, !tbaa !16
  br label %22

22:                                               ; preds = %44, %21
  %23 = load i8, ptr %8, align 1, !tbaa !16
  %24 = zext i8 %23 to i32
  %25 = icmp slt i32 %24, 3
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  br label %47

27:                                               ; preds = %22
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.TPE_Joint, ptr %28, i32 0, i32 1
  %30 = load i8, ptr %8, align 1, !tbaa !16
  %31 = zext i8 %30 to i64
  %32 = getelementptr inbounds [3 x i16], ptr %29, i64 0, i64 %31
  %33 = load i16, ptr %32, align 2, !tbaa !14
  %34 = sext i16 %33 to i32
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = mul nsw i32 %34, %35
  %37 = sdiv i32 %36, 512
  %38 = trunc i32 %37 to i16
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.TPE_Joint, ptr %39, i32 0, i32 1
  %41 = load i8, ptr %8, align 1, !tbaa !16
  %42 = zext i8 %41 to i64
  %43 = getelementptr inbounds [3 x i16], ptr %40, i64 0, i64 %42
  store i16 %38, ptr %43, align 2, !tbaa !14
  br label %44

44:                                               ; preds = %27
  %45 = load i8, ptr %8, align 1, !tbaa !16
  %46 = add i8 %45, 1
  store i8 %46, ptr %8, align 1, !tbaa !16
  br label %22, !llvm.loop !17

47:                                               ; preds = %26
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TPE_Joint, ptr %48, i32 1
  store ptr %49, ptr %5, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %47
  %51 = load i16, ptr %6, align 2, !tbaa !14
  %52 = add i16 %51, 1
  store i16 %52, ptr %6, align 2, !tbaa !14
  br label %12, !llvm.loop !19

53:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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 = { 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, !6, i64 0}
!12 = !{!"", !6, i64 0, !7, i64 8, !6, i64 16, !7, i64 24, !13, i64 26, !13, i64 28, !13, i64 30, !7, i64 32, !7, i64 33}
!13 = !{!"short", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !7, i64 8}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @TPE_bodyMultiplyNetSpeed(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i8, ptr %3, align 8, !tbaa !5
  %5 = zext i8 %4 to i16
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %._crit_edge, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %6 = load ptr, ptr %0, align 8, !tbaa !11
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %.01115 = phi i16 [ %26, %.preheader ], [ 0, %.preheader.preheader ]
  %.01214 = phi ptr [ %25, %.preheader ], [ %6, %.preheader.preheader ]
  %7 = getelementptr inbounds i8, ptr %.01214, i64 12
  %8 = load i16, ptr %7, align 2, !tbaa !12
  %9 = sext i16 %8 to i32
  %10 = mul nsw i32 %9, %1
  %11 = sdiv i32 %10, 512
  %12 = trunc i32 %11 to i16
  store i16 %12, ptr %7, align 2, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %.01214, i64 14
  %14 = load i16, ptr %13, align 2, !tbaa !12
  %15 = sext i16 %14 to i32
  %16 = mul nsw i32 %15, %1
  %17 = sdiv i32 %16, 512
  %18 = trunc i32 %17 to i16
  store i16 %18, ptr %13, align 2, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %.01214, i64 16
  %20 = load i16, ptr %19, align 2, !tbaa !12
  %21 = sext i16 %20 to i32
  %22 = mul nsw i32 %21, %1
  %23 = sdiv i32 %22, 512
  %24 = trunc i32 %23 to i16
  store i16 %24, ptr %19, align 2, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %.01214, i64 20
  %26 = add nuw nsw i16 %.01115, 1
  %exitcond.not = icmp eq i16 %26, %5
  br i1 %exitcond.not, label %._crit_edge, label %.preheader, !llvm.loop !13

._crit_edge:                                      ; preds = %.preheader, %2
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !8, i64 8}
!6 = !{!"", !7, i64 0, !8, i64 8, !7, i64 16, !8, i64 24, !10, i64 26, !10, i64 28, !10, i64 30, !8, i64 32, !8, i64 33}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass