; 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 { i64, i32 } @TPE_rotationFromVecs(i64, i32, i64, i32) #1

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

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @TPE_rotationInverse(i64 %0, i32 %1) #1 {
  %3 = alloca %struct.TPE_Vec3, align 4
  %4 = alloca %struct.TPE_Vec3, align 4
  %5 = alloca { i64, i32 }, align 4
  %6 = alloca %struct.TPE_Vec3, align 4
  %7 = alloca { i64, i32 }, align 8
  %8 = alloca %struct.TPE_Vec3, align 4
  %9 = alloca { i64, i32 }, align 8
  %10 = alloca { i64, i32 }, align 4
  %11 = alloca { i64, i32 }, align 4
  %12 = alloca { i64, i32 }, align 8
  %13 = alloca { i64, i32 }, align 8
  %14 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 0
  store i64 %0, ptr %14, align 4
  %15 = getelementptr inbounds { i64, i32 }, ptr %5, i32 0, i32 1
  store i32 %1, ptr %15, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %5, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #3
  %16 = call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef 512)
  store { i64, i32 } %16, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %7, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #3
  %17 = call { i64, i32 } @TPE_vec3(i32 noundef 512, i32 noundef 0, i32 noundef 0)
  store { i64, i32 } %17, ptr %9, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 8 %9, i64 12, i1 false)
  %18 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = mul nsw i32 %19, -1
  store i32 %20, ptr %18, align 4, !tbaa !5
  %21 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 1
  %22 = load i32, ptr %21, align 4, !tbaa !10
  %23 = mul nsw i32 %22, -1
  store i32 %23, ptr %21, align 4, !tbaa !10
  %24 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = mul nsw i32 %25, -1
  store i32 %26, ptr %24, align 4, !tbaa !11
  %27 = getelementptr inbounds %struct.TPE_Vec3, ptr %6, i32 0, i32 0
  %28 = getelementptr inbounds %struct.TPE_Vec3, ptr %6, i32 0, i32 2
  %29 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !10
  call void @_TPE_vec2Rotate(ptr noundef %27, ptr noundef %28, i32 noundef %30)
  %31 = getelementptr inbounds %struct.TPE_Vec3, ptr %6, i32 0, i32 2
  %32 = getelementptr inbounds %struct.TPE_Vec3, ptr %6, i32 0, i32 1
  %33 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 0
  %34 = load i32, ptr %33, align 4, !tbaa !5
  call void @_TPE_vec2Rotate(ptr noundef %31, ptr noundef %32, i32 noundef %34)
  %35 = getelementptr inbounds %struct.TPE_Vec3, ptr %6, i32 0, i32 1
  %36 = getelementptr inbounds %struct.TPE_Vec3, ptr %6, i32 0, i32 0
  %37 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !11
  call void @_TPE_vec2Rotate(ptr noundef %35, ptr noundef %36, i32 noundef %38)
  %39 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 0
  %40 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 2
  %41 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !10
  call void @_TPE_vec2Rotate(ptr noundef %39, ptr noundef %40, i32 noundef %42)
  %43 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 2
  %44 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 1
  %45 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 0
  %46 = load i32, ptr %45, align 4, !tbaa !5
  call void @_TPE_vec2Rotate(ptr noundef %43, ptr noundef %44, i32 noundef %46)
  %47 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 1
  %48 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 0
  %49 = getelementptr inbounds %struct.TPE_Vec3, ptr %4, i32 0, i32 2
  %50 = load i32, ptr %49, align 4, !tbaa !11
  call void @_TPE_vec2Rotate(ptr noundef %47, ptr noundef %48, i32 noundef %50)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %6, i64 12, i1 false)
  %51 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 0
  %52 = load i64, ptr %51, align 4
  %53 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 1
  %54 = load i32, ptr %53, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %8, i64 12, i1 false)
  %55 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 0
  %56 = load i64, ptr %55, align 4
  %57 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 1
  %58 = load i32, ptr %57, align 4
  %59 = call { i64, i32 } @TPE_rotationFromVecs(i64 %52, i32 %54, i64 %56, i32 %58)
  store { i64, i32 } %59, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 8 %12, i64 12, i1 false)
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 4 %3, i64 12, i1 false)
  %60 = load { i64, i32 }, ptr %13, align 8
  ret { i64, i32 } %60
}

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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 8}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; 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 void @_TPE_vec2Rotate(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @TPE_rotationInverse(i64 %0, i32 %1) local_unnamed_addr #0 {
  %3 = alloca %struct.TPE_Vec3, align 8
  %4 = alloca %struct.TPE_Vec3, align 8
  %.sroa.017.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.5.0.extract.shift = lshr i64 %0, 32
  %.sroa.5.0.extract.trunc = trunc nuw i64 %.sroa.5.0.extract.shift to i32
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #2
  %5 = tail call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef 512)
  %.fca.0.extract11 = extractvalue { i64, i32 } %5, 0
  %.fca.1.extract12 = extractvalue { i64, i32 } %5, 1
  store i64 %.fca.0.extract11, ptr %3, align 8
  %.sroa.214.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %.fca.1.extract12, ptr %.sroa.214.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #2
  %6 = tail call { i64, i32 } @TPE_vec3(i32 noundef 512, i32 noundef 0, i32 noundef 0)
  %.fca.0.extract7 = extractvalue { i64, i32 } %6, 0
  %.fca.1.extract8 = extractvalue { i64, i32 } %6, 1
  store i64 %.fca.0.extract7, ptr %4, align 8
  %.sroa.210.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %.fca.1.extract8, ptr %.sroa.210.0..sroa_idx, align 8
  %7 = sub nsw i32 0, %.sroa.017.0.extract.trunc
  %8 = sub nsw i32 0, %.sroa.5.0.extract.trunc
  %9 = sub nsw i32 0, %1
  call void @_TPE_vec2Rotate(ptr noundef nonnull %3, ptr noundef nonnull %.sroa.214.0..sroa_idx, i32 noundef %8)
  %10 = getelementptr inbounds i8, ptr %3, i64 4
  call void @_TPE_vec2Rotate(ptr noundef nonnull %.sroa.214.0..sroa_idx, ptr noundef nonnull %10, i32 noundef %7)
  call void @_TPE_vec2Rotate(ptr noundef nonnull %10, ptr noundef nonnull %3, i32 noundef %9)
  call void @_TPE_vec2Rotate(ptr noundef nonnull %4, ptr noundef nonnull %.sroa.210.0..sroa_idx, i32 noundef %8)
  %11 = getelementptr inbounds i8, ptr %4, i64 4
  call void @_TPE_vec2Rotate(ptr noundef nonnull %.sroa.210.0..sroa_idx, ptr noundef nonnull %11, i32 noundef %7)
  call void @_TPE_vec2Rotate(ptr noundef nonnull %11, ptr noundef nonnull %4, i32 noundef %9)
  %.sroa.05.0.copyload = load i64, ptr %3, align 8
  %.sroa.26.0.copyload = load i32, ptr %.sroa.214.0..sroa_idx, align 8
  %.sroa.03.0.copyload = load i64, ptr %4, align 8
  %.sroa.24.0.copyload = load i32, ptr %.sroa.210.0..sroa_idx, align 8
  %12 = call { i64, i32 } @TPE_rotationFromVecs(i64 %.sroa.05.0.copyload, i32 %.sroa.26.0.copyload, i64 %.sroa.03.0.copyload, i32 %.sroa.24.0.copyload)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #2
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #2
  ret { i64, i32 } %12
}

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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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)"}


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