Question: I am going to migrate onto Google Workspace. I will create several TeamDrives under there, where my contractors (photographer etc.) will upload the files they created.

1. They will use their own gmail account, not with an email of my company's domain.
2. In personal Google Drive, when someone shares a folder/file with me, those are still owned by them. Therefore, when they delete on their own personal account, those files are also removed from my side. **As per my understanding, TeamDrive sorts out this issue. When they upload a file/folder into a TeamDrive using their own gmail account, the ownership of these are taken by the TeamDrive and protected from deletion in the future.**

Can someone help me to clarify these questions?

Thanks

Answer: 
Depending on how we interpret your lax rounding requirements, the following may be acceptable:

```
sar rdi, 1
sar rsi, 1
adc rdi, rsi

```

[Try on godbolt](https://godbolt.org/z/c98YeGrcr)

This effectively divides both inputs by 2, adds the results, and adds 1 more if `rsi` was odd. (Remember that `sar` sets the carry flag according to the last bit shifted out.)

Since `sar` rounds to minus infinity, the result of this algorithm is:

* exactly correct if rdi, rsi are both even or both odd
* rounded down (toward minus infinity) if rdi is odd and rsi is even
* rounded up (toward plus infinity) if rdi is even and rsi is odd

As a bonus, for random inputs, the average rounding error is zero.

It should be 3 uops on a typical CPU, with a latency of 2 cycles since the two `sar` are independent.
As an outside answer, consider the [`pavg` family of instructions](https://www.felixcloutier.com/x86/pavgb:pavgw).

I say "outside", since this is likely not acceptable to you. It assumes the value is unsigned 8-bit or 16-bit and in an SSE register, which of course also requires SSE. I mention it mainly since it is x86's anointed equivalent to averaging instructions in other ISAs.

In its defense, SSE is ubiquitous by now, even guaranteed on x86-64. Also, this instruction is 1 cycle, and actually can do 4 at once if you like. Best of all, unlike your original solutions, it also correctly handles overflow issues.

Note that it's possible to use an unsigned routine to implement a signed routine, though in general correctly accounting for overflow issues is [a nightmare](https://www.youtube.com/watch?v=sBtAGxBh-XI). Your current solution appears to already be broken in that regard, though.