int main() {
  unsigned long long a = ~0;
  unsigned b = 0xa;
  __atomic_fetch_add(&a, b, 0);
  __atomic_fetch_and(&a, b, 0);
  __atomic_fetch_or(&a, b, 0);
  __atomic_fetch_xor(&a, b, 0);
  return a;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
movl   $0xa,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
lock xadd %rax,-0x10(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
and    %rdx,%rcx
lock cmpxchg %rcx,-0x10(%rbp)
sete   %cl
mov    %rax,-0x70(%rbp)
test   $0x1,%cl
mov    %rax,-0x60(%rbp)
jne    1177 <main+0x77>
jmp    114a <main+0x4a>
mov    -0x70(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    -0x80(%rbp),%rdx
mov    %rax,%rcx
or     %rdx,%rcx
lock cmpxchg %rcx,-0x10(%rbp)
sete   %cl
mov    %rax,-0x88(%rbp)
test   $0x1,%cl
mov    %rax,-0x78(%rbp)
jne    11c6 <main+0xc6>
jmp    1196 <main+0x96>
mov    -0x88(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    -0x98(%rbp),%rdx
mov    %rax,%rcx
xor    %rdx,%rcx
lock cmpxchg %rcx,-0x10(%rbp)
sete   %cl
mov    %rax,-0xa0(%rbp)
test   $0x1,%cl
mov    %rax,-0x90(%rbp)
jne    1227 <main+0x127>
jmp    11ee <main+0xee>
mov    -0xa0(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movq   $0xffffffffffffffff,-0x8(%rsp)
ff ff
lock addq $0xa,-0x8(%rsp)
lock andq $0xa,-0x8(%rsp)
lock orq $0xa,-0x8(%rsp)
lock xorq $0xa,-0x8(%rsp)
mov    -0x8(%rsp),%eax
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %1
store i64 -1, i64* %2
store i32 10, i32* %3
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
store i64 %13, i64* %4
%14 = load i64, i64* %4
%15 = atomicrmw add i64* %2, i64 %14 monotonic
store i64 %15, i64* %5
%16 = load i64, i64* %5
%17 = load i32, i32* %3
%18 = zext i32 %17 to i64
store i64 %18, i64* %6
%19 = load i64, i64* %6
%20 = atomicrmw and i64* %2, i64 %19 monotonic
store i64 %20, i64* %7
%21 = load i64, i64* %7
%22 = load i32, i32* %3
%23 = zext i32 %22 to i64
store i64 %23, i64* %8
%24 = load i64, i64* %8
%25 = atomicrmw or i64* %2, i64 %24 monotonic
store i64 %25, i64* %9
%26 = load i64, i64* %9
%27 = load i32, i32* %3
%28 = zext i32 %27 to i64
store i64 %28, i64* %10
%29 = load i64, i64* %10
%30 = atomicrmw xor i64* %2, i64 %29 monotonic
store i64 %30, i64* %11
%31 = load i64, i64* %11
%32 = load i64, i64* %2
%33 = trunc i64 %32 to i32
ret i32 %33
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 -1, i64* %1
%3 = atomicrmw add i64* %1, i64 10 monotonic
%4 = atomicrmw and i64* %1, i64 10 monotonic
%5 = atomicrmw or i64* %1, i64 10 monotonic
%6 = atomicrmw xor i64* %1, i64 10 monotonic
%7 = load i64, i64* %1
%8 = trunc i64 %7 to i32
ret i32 %8
}