; 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_Vec3 = type { i32, i32, i32 }

; 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) #0

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

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

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

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

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

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

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

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

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

attributes #0 = { nocallback nofree 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}


; 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_Vec3 = type { i32, i32, i32 }

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_rotationFromVecs(i64, i32, i64, i32) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_pointRotate(i64, i32, i64, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @TPE_rotationRotateByAxis(i64 %0, i32 %1, i64 %2, i32 %3) local_unnamed_addr #0 {
  %5 = alloca %struct.TPE_Vec3, align 8
  store i64 %2, ptr %5, align 8
  %.sroa.265.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %3, ptr %.sroa.265.0..sroa_idx, align 8
  %6 = tail call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef 512)
  %.fca.0.extract54 = extractvalue { i64, i32 } %6, 0
  %.fca.1.extract55 = extractvalue { i64, i32 } %6, 1
  %7 = tail call { i64, i32 } @TPE_pointRotate(i64 %.fca.0.extract54, i32 %.fca.1.extract55, i64 %0, i32 %1)
  %.fca.0.extract46 = extractvalue { i64, i32 } %7, 0
  %.fca.1.extract47 = extractvalue { i64, i32 } %7, 1
  %8 = tail call { i64, i32 } @TPE_vec3(i32 noundef 512, i32 noundef 0, i32 noundef 0)
  %.fca.0.extract37 = extractvalue { i64, i32 } %8, 0
  %.fca.1.extract38 = extractvalue { i64, i32 } %8, 1
  %9 = tail call { i64, i32 } @TPE_pointRotate(i64 %.fca.0.extract37, i32 %.fca.1.extract38, i64 %0, i32 %1)
  %.fca.0.extract29 = extractvalue { i64, i32 } %9, 0
  %.fca.1.extract30 = extractvalue { i64, i32 } %9, 1
  %10 = tail call i32 @TPE_vec3Len(i64 %2, i32 %3)
  call void @TPE_vec3Normalize(ptr noundef nonnull %5)
  %.sroa.020.0.copyload = load i64, ptr %5, align 8
  %.sroa.221.0.copyload = load i32, ptr %.sroa.265.0..sroa_idx, align 8
  %11 = call { i64, i32 } @_TPE_rotateByAxis(i64 %.fca.0.extract46, i32 %.fca.1.extract47, i64 %.sroa.020.0.copyload, i32 %.sroa.221.0.copyload, i32 noundef %10)
  %.fca.0.extract16 = extractvalue { i64, i32 } %11, 0
  %.fca.1.extract17 = extractvalue { i64, i32 } %11, 1
  %.sroa.011.0.copyload = load i64, ptr %5, align 8
  %.sroa.212.0.copyload = load i32, ptr %.sroa.265.0..sroa_idx, align 8
  %12 = call { i64, i32 } @_TPE_rotateByAxis(i64 %.fca.0.extract29, i32 %.fca.1.extract30, i64 %.sroa.011.0.copyload, i32 %.sroa.212.0.copyload, i32 noundef %10)
  %.fca.0.extract7 = extractvalue { i64, i32 } %12, 0
  %.fca.1.extract8 = extractvalue { i64, i32 } %12, 1
  %13 = call { i64, i32 } @TPE_rotationFromVecs(i64 %.fca.0.extract16, i32 %.fca.1.extract17, i64 %.fca.0.extract7, i32 %.fca.1.extract8)
  ret { i64, i32 } %13
}

attributes #0 = { 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: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass