; LLVM IR from jordan4ibanez/tinyphysicsengine :: old (test)

; 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_Vec4 = type { i32, i32, i32, i32 }
%struct.TPE_Body = type { i8, [3 x i32], [2 x ptr], i8, i32, %struct.TPE_Vec4, %struct.TPE_Vec4, %struct.TPE_RotationState, i32, i8 }
%struct.TPE_RotationState = type { %struct.TPE_Vec4, %struct.TPE_Vec4, 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: 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) #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @TPE_vec3Cross(i64, i64, i64, i64) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_vec3Len(i64, i64) #2

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @TPE_vec3Minus(i64, i64, i64, i64) #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @TPE_vec3Plus(i64, i64, i64, i64) #2

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @TPE_vec3Times(i64, i64, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local { i64, i64 } @TPE_bodyGetPointVelocity(ptr noundef %0, i64 %1, i64 %2) #2 {
  %4 = alloca %struct.TPE_Vec4, align 4
  %5 = alloca %struct.TPE_Vec4, align 4
  %6 = alloca ptr, align 8
  %7 = alloca %struct.TPE_Vec4, align 4
  %8 = alloca %struct.TPE_Vec4, align 4
  %9 = alloca %struct.TPE_Vec4, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.TPE_Vec4, align 4
  %13 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 0
  store i64 %1, ptr %13, align 4
  %14 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 1
  store i64 %2, ptr %14, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.TPE_Body, ptr %15, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 8 %16, i64 16, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.TPE_Body, ptr %17, i32 0, i32 7
  %19 = getelementptr inbounds %struct.TPE_RotationState, ptr %18, i32 0, i32 1
  %20 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 0
  %21 = load i64, ptr %20, align 4
  %22 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 1
  %23 = load i64, ptr %22, align 4
  %24 = getelementptr inbounds { i64, i64 }, ptr %19, i32 0, i32 0
  %25 = load i64, ptr %24, align 8
  %26 = getelementptr inbounds { i64, i64 }, ptr %19, i32 0, i32 1
  %27 = load i64, ptr %26, align 8
  %28 = call { i64, i64 } @TPE_vec3Minus(i64 %21, i64 %23, i64 %25, i64 %27)
  %29 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  %30 = extractvalue { i64, i64 } %28, 0
  store i64 %30, ptr %29, align 4
  %31 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  %32 = extractvalue { i64, i64 } %28, 1
  store i64 %32, ptr %31, align 4
  %33 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 0
  %34 = load i64, ptr %33, align 4
  %35 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 1
  %36 = load i64, ptr %35, align 4
  %37 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  %38 = load i64, ptr %37, align 4
  %39 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  %40 = load i64, ptr %39, align 4
  %41 = call { i64, i64 } @TPE_vec3Cross(i64 %34, i64 %36, i64 %38, i64 %40)
  %42 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %43 = extractvalue { i64, i64 } %41, 0
  store i64 %43, ptr %42, align 4
  %44 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %45 = extractvalue { i64, i64 } %41, 1
  store i64 %45, ptr %44, align 4
  %46 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %47 = load i64, ptr %46, align 4
  %48 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %49 = load i64, ptr %48, align 4
  call void @TPE_vec3MultiplyPlain(i64 %47, i64 %49, i32 noundef -1, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %50 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %51 = load i64, ptr %50, align 4
  %52 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %53 = load i64, ptr %52, align 4
  %54 = call i32 @TPE_vec3Len(i64 %51, i64 %53)
  store i32 %54, ptr %10, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.TPE_Body, ptr %55, i32 0, i32 7
  %57 = getelementptr inbounds %struct.TPE_RotationState, ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds %struct.TPE_Vec4, ptr %57, i32 0, i32 3
  %59 = load i32, ptr %58, align 4, !tbaa !12
  %60 = load i32, ptr %10, align 4, !tbaa !10
  %61 = call i32 @TPE_angularVelocityToLinear(i32 noundef %59, i32 noundef %60)
  store i32 %61, ptr %11, align 4, !tbaa !10
  call void @TPE_vec3Normalize(ptr noundef %8)
  %62 = load i32, ptr %11, align 4, !tbaa !10
  %63 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %64 = load i64, ptr %63, align 4
  %65 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %66 = load i64, ptr %65, align 4
  %67 = call { i64, i64 } @TPE_vec3Times(i64 %64, i64 %66, i32 noundef %62)
  %68 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 0
  %69 = extractvalue { i64, i64 } %67, 0
  store i64 %69, ptr %68, align 4
  %70 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 1
  %71 = extractvalue { i64, i64 } %67, 1
  store i64 %71, ptr %70, align 4
  %72 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  %73 = load i64, ptr %72, align 4
  %74 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  %75 = load i64, ptr %74, align 4
  %76 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 0
  %77 = load i64, ptr %76, align 4
  %78 = getelementptr inbounds { i64, i64 }, ptr %12, i32 0, i32 1
  %79 = load i64, ptr %78, align 4
  %80 = call { i64, i64 } @TPE_vec3Plus(i64 %73, i64 %75, i64 %77, i64 %79)
  %81 = getelementptr inbounds { i64, i64 }, ptr %4, i32 0, i32 0
  %82 = extractvalue { i64, i64 } %80, 0
  store i64 %82, ptr %81, align 4
  %83 = getelementptr inbounds { i64, i64 }, ptr %4, i32 0, i32 1
  %84 = extractvalue { i64, i64 } %80, 1
  store i64 %84, ptr %83, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  %85 = load { i64, i64 }, ptr %4, align 4
  ret { i64, i64 } %85
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10, i64 12, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 100}
!13 = !{!"", !7, i64 0, !7, i64 4, !7, i64 16, !7, i64 32, !11, i64 36, !14, i64 40, !14, i64 56, !15, i64 72, !11, i64 108, !7, i64 112}
!14 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!15 = !{!"", !14, i64 0, !14, i64 16, !11, i64 32}


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

%struct.TPE_Vec4 = type { i32, i32, i32, i32 }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @TPE_vec3Cross(i64, i64, i64, i64) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_vec3Len(i64, i64) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @TPE_vec3Minus(i64, i64, i64, i64) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @TPE_vec3Plus(i64, i64, i64, i64) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i64 } @TPE_vec3Times(i64, i64, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local { i64, i64 } @TPE_bodyGetPointVelocity(ptr nocapture noundef readonly %0, i64 %1, i64 %2) local_unnamed_addr #1 {
  %4 = alloca %struct.TPE_Vec4, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %.sroa.04.0.copyload = load i64, ptr %5, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 64
  %.sroa.4.0.copyload = load i64, ptr %.sroa.4.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  %7 = load i64, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 96
  %9 = load i64, ptr %8, align 8
  %10 = tail call { i64, i64 } @TPE_vec3Minus(i64 %1, i64 %2, i64 %7, i64 %9)
  %11 = extractvalue { i64, i64 } %10, 0
  %12 = extractvalue { i64, i64 } %10, 1
  %13 = tail call { i64, i64 } @TPE_vec3Cross(i64 %1, i64 %2, i64 %11, i64 %12)
  %14 = extractvalue { i64, i64 } %13, 0
  store i64 %14, ptr %4, align 8
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  %16 = extractvalue { i64, i64 } %13, 1
  store i64 %16, ptr %15, align 8
  call void @TPE_vec3MultiplyPlain(i64 %14, i64 %16, i32 noundef -1, ptr noundef nonnull %4)
  %17 = load i64, ptr %4, align 8
  %18 = load i64, ptr %15, align 8
  %19 = call i32 @TPE_vec3Len(i64 %17, i64 %18)
  %20 = getelementptr inbounds i8, ptr %0, i64 100
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = call i32 @TPE_angularVelocityToLinear(i32 noundef %21, i32 noundef %19)
  call void @TPE_vec3Normalize(ptr noundef nonnull %4)
  %23 = load i64, ptr %4, align 8
  %24 = load i64, ptr %15, align 8
  %25 = call { i64, i64 } @TPE_vec3Times(i64 %23, i64 %24, i32 noundef %22)
  %26 = extractvalue { i64, i64 } %25, 0
  %27 = extractvalue { i64, i64 } %25, 1
  %28 = call { i64, i64 } @TPE_vec3Plus(i64 %.sroa.04.0.copyload, i64 %.sroa.4.0.copyload, i64 %26, i64 %27)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #2
  ret { i64, i64 } %28
}

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

attributes #0 = { mustprogress 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, !9, i64 100}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 16, !7, i64 32, !9, i64 36, !10, i64 40, !10, i64 56, !11, i64 72, !9, i64 108, !7, i64 112}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12}
!11 = !{!"", !10, i64 0, !10, i64 16, !9, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass