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

; 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: inlinehint nounwind uwtable
declare hidden i32 @TPE_nonZero(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_bodyGetAverageSpeed(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_bodyMultiplyNetSpeed(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @TPE_bodyLimitAverageSpeed(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !11
  br label %11

11:                                               ; preds = %41, %3
  %12 = load i8, ptr %7, align 1, !tbaa !11
  %13 = zext i8 %12 to i32
  %14 = icmp slt i32 %13, 16
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %8, align 4
  br label %44

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i32 @TPE_bodyGetAverageSpeed(ptr noundef %17)
  store i32 %18, ptr %9, align 4, !tbaa !9
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = icmp sge i32 %19, %20
  br i1 %21, label %22, label %27

22:                                               ; preds = %16
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp sle i32 %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %22
  store i32 1, ptr %8, align 4
  br label %38

27:                                               ; preds = %22, %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = add nsw i32 %28, %29
  %31 = sdiv i32 %30, 2
  %32 = mul nsw i32 %31, 512
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = call i32 @TPE_nonZero(i32 noundef %33)
  %35 = sdiv i32 %32, %34
  store i32 %35, ptr %10, align 4, !tbaa !9
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load i32, ptr %10, align 4, !tbaa !9
  call void @TPE_bodyMultiplyNetSpeed(ptr noundef %36, i32 noundef %37)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  store i32 0, ptr %8, align 4
  br label %38

38:                                               ; preds = %27, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %39 = load i32, ptr %8, align 4
  switch i32 %39, label %44 [
    i32 0, label %40
  ]

40:                                               ; preds = %38
  br label %41

41:                                               ; preds = %40
  %42 = load i8, ptr %7, align 1, !tbaa !11
  %43 = add i8 %42, 1
  store i8 %43, ptr %7, align 1, !tbaa !11
  br label %11, !llvm.loop !12

44:                                               ; preds = %38, %15
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  %45 = load i32, ptr %8, align 4
  switch i32 %45, label %47 [
    i32 2, label %46
    i32 1, label %46
  ]

46:                                               ; preds = %44, %44
  ret void

47:                                               ; preds = %44
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; 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: inlinehint nounwind uwtable
declare hidden i32 @TPE_nonZero(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_bodyGetAverageSpeed(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_bodyMultiplyNetSpeed(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @TPE_bodyLimitAverageSpeed(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = add nsw i32 %2, %1
  %5 = sdiv i32 %4, 2
  %6 = shl nsw i32 %5, 9
  %7 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not = icmp slt i32 %7, %1
  %.not14 = icmp sgt i32 %7, %2
  %or.cond = or i1 %.not, %.not14
  br i1 %or.cond, label %.critedge, label %55

.critedge:                                        ; preds = %3
  %8 = tail call i32 @TPE_nonZero(i32 noundef %7)
  %9 = sdiv i32 %6, %8
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %9)
  %10 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.1 = icmp slt i32 %10, %1
  %.not14.1 = icmp sgt i32 %10, %2
  %or.cond.1 = or i1 %.not.1, %.not14.1
  br i1 %or.cond.1, label %.critedge.1, label %55

.critedge.1:                                      ; preds = %.critedge
  %11 = tail call i32 @TPE_nonZero(i32 noundef %10)
  %12 = sdiv i32 %6, %11
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %12)
  %13 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.2 = icmp slt i32 %13, %1
  %.not14.2 = icmp sgt i32 %13, %2
  %or.cond.2 = or i1 %.not.2, %.not14.2
  br i1 %or.cond.2, label %.critedge.2, label %55

.critedge.2:                                      ; preds = %.critedge.1
  %14 = tail call i32 @TPE_nonZero(i32 noundef %13)
  %15 = sdiv i32 %6, %14
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %15)
  %16 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.3 = icmp slt i32 %16, %1
  %.not14.3 = icmp sgt i32 %16, %2
  %or.cond.3 = or i1 %.not.3, %.not14.3
  br i1 %or.cond.3, label %.critedge.3, label %55

.critedge.3:                                      ; preds = %.critedge.2
  %17 = tail call i32 @TPE_nonZero(i32 noundef %16)
  %18 = sdiv i32 %6, %17
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %18)
  %19 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.4 = icmp slt i32 %19, %1
  %.not14.4 = icmp sgt i32 %19, %2
  %or.cond.4 = or i1 %.not.4, %.not14.4
  br i1 %or.cond.4, label %.critedge.4, label %55

.critedge.4:                                      ; preds = %.critedge.3
  %20 = tail call i32 @TPE_nonZero(i32 noundef %19)
  %21 = sdiv i32 %6, %20
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %21)
  %22 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.5 = icmp slt i32 %22, %1
  %.not14.5 = icmp sgt i32 %22, %2
  %or.cond.5 = or i1 %.not.5, %.not14.5
  br i1 %or.cond.5, label %.critedge.5, label %55

.critedge.5:                                      ; preds = %.critedge.4
  %23 = tail call i32 @TPE_nonZero(i32 noundef %22)
  %24 = sdiv i32 %6, %23
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %24)
  %25 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.6 = icmp slt i32 %25, %1
  %.not14.6 = icmp sgt i32 %25, %2
  %or.cond.6 = or i1 %.not.6, %.not14.6
  br i1 %or.cond.6, label %.critedge.6, label %55

.critedge.6:                                      ; preds = %.critedge.5
  %26 = tail call i32 @TPE_nonZero(i32 noundef %25)
  %27 = sdiv i32 %6, %26
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %27)
  %28 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.7 = icmp slt i32 %28, %1
  %.not14.7 = icmp sgt i32 %28, %2
  %or.cond.7 = or i1 %.not.7, %.not14.7
  br i1 %or.cond.7, label %.critedge.7, label %55

.critedge.7:                                      ; preds = %.critedge.6
  %29 = tail call i32 @TPE_nonZero(i32 noundef %28)
  %30 = sdiv i32 %6, %29
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %30)
  %31 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.8 = icmp slt i32 %31, %1
  %.not14.8 = icmp sgt i32 %31, %2
  %or.cond.8 = or i1 %.not.8, %.not14.8
  br i1 %or.cond.8, label %.critedge.8, label %55

.critedge.8:                                      ; preds = %.critedge.7
  %32 = tail call i32 @TPE_nonZero(i32 noundef %31)
  %33 = sdiv i32 %6, %32
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %33)
  %34 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.9 = icmp slt i32 %34, %1
  %.not14.9 = icmp sgt i32 %34, %2
  %or.cond.9 = or i1 %.not.9, %.not14.9
  br i1 %or.cond.9, label %.critedge.9, label %55

.critedge.9:                                      ; preds = %.critedge.8
  %35 = tail call i32 @TPE_nonZero(i32 noundef %34)
  %36 = sdiv i32 %6, %35
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %36)
  %37 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.10 = icmp slt i32 %37, %1
  %.not14.10 = icmp sgt i32 %37, %2
  %or.cond.10 = or i1 %.not.10, %.not14.10
  br i1 %or.cond.10, label %.critedge.10, label %55

.critedge.10:                                     ; preds = %.critedge.9
  %38 = tail call i32 @TPE_nonZero(i32 noundef %37)
  %39 = sdiv i32 %6, %38
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %39)
  %40 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.11 = icmp slt i32 %40, %1
  %.not14.11 = icmp sgt i32 %40, %2
  %or.cond.11 = or i1 %.not.11, %.not14.11
  br i1 %or.cond.11, label %.critedge.11, label %55

.critedge.11:                                     ; preds = %.critedge.10
  %41 = tail call i32 @TPE_nonZero(i32 noundef %40)
  %42 = sdiv i32 %6, %41
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %42)
  %43 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.12 = icmp slt i32 %43, %1
  %.not14.12 = icmp sgt i32 %43, %2
  %or.cond.12 = or i1 %.not.12, %.not14.12
  br i1 %or.cond.12, label %.critedge.12, label %55

.critedge.12:                                     ; preds = %.critedge.11
  %44 = tail call i32 @TPE_nonZero(i32 noundef %43)
  %45 = sdiv i32 %6, %44
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %45)
  %46 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.13 = icmp slt i32 %46, %1
  %.not14.13 = icmp sgt i32 %46, %2
  %or.cond.13 = or i1 %.not.13, %.not14.13
  br i1 %or.cond.13, label %.critedge.13, label %55

.critedge.13:                                     ; preds = %.critedge.12
  %47 = tail call i32 @TPE_nonZero(i32 noundef %46)
  %48 = sdiv i32 %6, %47
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %48)
  %49 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.14 = icmp slt i32 %49, %1
  %.not14.14 = icmp sgt i32 %49, %2
  %or.cond.14 = or i1 %.not.14, %.not14.14
  br i1 %or.cond.14, label %.critedge.14, label %55

.critedge.14:                                     ; preds = %.critedge.13
  %50 = tail call i32 @TPE_nonZero(i32 noundef %49)
  %51 = sdiv i32 %6, %50
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %51)
  %52 = tail call i32 @TPE_bodyGetAverageSpeed(ptr noundef %0)
  %.not.15 = icmp slt i32 %52, %1
  %.not14.15 = icmp sgt i32 %52, %2
  %or.cond.15 = or i1 %.not.15, %.not14.15
  br i1 %or.cond.15, label %.critedge.15, label %55

.critedge.15:                                     ; preds = %.critedge.14
  %53 = tail call i32 @TPE_nonZero(i32 noundef %52)
  %54 = sdiv i32 %6, %53
  tail call void @TPE_bodyMultiplyNetSpeed(ptr noundef %0, i32 noundef %54)
  br label %55

55:                                               ; preds = %.critedge.15, %.critedge.14, %.critedge.13, %.critedge.12, %.critedge.11, %.critedge.10, %.critedge.9, %.critedge.8, %.critedge.7, %.critedge.6, %.critedge.5, %.critedge.4, %.critedge.3, %.critedge.2, %.critedge.1, %.critedge, %3
  ret void
}

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

!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: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass