void gnu_builtins() {
  int _i;
  int i = 0;
  _i = __atomic_fetch_add(&i, 1, 5);
  _i = __atomic_fetch_sub(&i, 1, 5);
  _i = __atomic_fetch_and(&i, 1, 5);
  _i = __atomic_fetch_or(&i, 1, 5);
  _i = __atomic_fetch_xor(&i, 1, 5);
  _i = __atomic_add_fetch(&i, 1, 5);
  _i = __atomic_sub_fetch(&i, 1, 5);
  _i = __atomic_and_fetch(&i, 1, 5);
  _i = __atomic_or_fetch(&i, 1, 5);
  _i = __atomic_xor_fetch(&i, 1, 5);
}


x86 assembly (clang, -O0):
<gnu_builtins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
lock xadd %eax,-0x8(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
neg    %eax
lock xadd %eax,-0x8(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    -0x60(%rbp),%edx
mov    %eax,%ecx
and    %edx,%ecx
lock cmpxchg %ecx,-0x8(%rbp)
sete   %cl
mov    %eax,-0x64(%rbp)
test   $0x1,%cl
mov    %eax,-0x5c(%rbp)
jne    117a <gnu_builtins+0x7a>
jmp    1154 <gnu_builtins+0x54>
mov    -0x64(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    -0x6c(%rbp),%edx
mov    %eax,%ecx
or     %edx,%ecx
lock cmpxchg %ecx,-0x8(%rbp)
sete   %cl
mov    %eax,-0x70(%rbp)
test   $0x1,%cl
mov    %eax,-0x68(%rbp)
jne    11bf <gnu_builtins+0xbf>
jmp    1199 <gnu_builtins+0x99>
mov    -0x70(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    -0x78(%rbp),%edx
mov    %eax,%ecx
xor    %edx,%ecx
lock cmpxchg %ecx,-0x8(%rbp)
sete   %cl
mov    %eax,-0x7c(%rbp)
test   $0x1,%cl
mov    %eax,-0x74(%rbp)
jne    1204 <gnu_builtins+0x104>
jmp    11de <gnu_builtins+0xde>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
mov    %ecx,%eax
lock xadd %eax,-0x8(%rbp)
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%ecx
mov    %ecx,%eax
neg    %eax
lock xadd %eax,-0x8(%rbp)
sub    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    -0x84(%rbp),%edx
mov    %eax,%ecx
and    %edx,%ecx
lock cmpxchg %ecx,-0x8(%rbp)
sete   %cl
mov    %eax,-0x88(%rbp)
test   $0x1,%cl
mov    %eax,-0x80(%rbp)
jne    128c <gnu_builtins+0x18c>
jmp    1260 <gnu_builtins+0x160>
mov    -0x84(%rbp),%ecx
mov    -0x88(%rbp),%eax
and    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    -0x90(%rbp),%edx
mov    %eax,%ecx
or     %edx,%ecx
lock cmpxchg %ecx,-0x8(%rbp)
sete   %cl
mov    %eax,-0x94(%rbp)
test   $0x1,%cl
mov    %eax,-0x8c(%rbp)
jne    12ee <gnu_builtins+0x1ee>
jmp    12bc <gnu_builtins+0x1bc>
mov    -0x90(%rbp),%ecx
mov    -0x94(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%eax
mov    -0x9c(%rbp),%edx
mov    %eax,%ecx
xor    %edx,%ecx
lock cmpxchg %ecx,-0x8(%rbp)
sete   %cl
mov    %eax,-0xa0(%rbp)
test   $0x1,%cl
mov    %eax,-0x98(%rbp)
jne    1350 <gnu_builtins+0x250>
jmp    131e <gnu_builtins+0x21e>
mov    -0x9c(%rbp),%ecx
mov    -0xa0(%rbp),%eax
xor    %ecx,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gnu_builtins>:
movl   $0x0,-0x4(%rsp)
lock addl $0x1,-0x4(%rsp)
lock subl $0x1,-0x4(%rsp)
lock andl $0x1,-0x4(%rsp)
lock orl $0x1,-0x4(%rsp)
lock xorl $0x1,-0x4(%rsp)
lock addl $0x1,-0x4(%rsp)
lock subl $0x1,-0x4(%rsp)
lock andl $0x1,-0x4(%rsp)
lock orl $0x1,-0x4(%rsp)
lock xorl $0x1,-0x4(%rsp)
ret

LLVM IR (-O0):
define void @gnu_builtins() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %2
store i32 1, i32* %3
%23 = load i32, i32* %3
%24 = atomicrmw add i32* %2, i32 %23 seq_cst
store i32 %24, i32* %4
%25 = load i32, i32* %4
store i32 %25, i32* %1
store i32 1, i32* %5
%26 = load i32, i32* %5
%27 = atomicrmw sub i32* %2, i32 %26 seq_cst
store i32 %27, i32* %6
%28 = load i32, i32* %6
store i32 %28, i32* %1
store i32 1, i32* %7
%29 = load i32, i32* %7
%30 = atomicrmw and i32* %2, i32 %29 seq_cst
store i32 %30, i32* %8
%31 = load i32, i32* %8
store i32 %31, i32* %1
store i32 1, i32* %9
%32 = load i32, i32* %9
%33 = atomicrmw or i32* %2, i32 %32 seq_cst
store i32 %33, i32* %10
%34 = load i32, i32* %10
store i32 %34, i32* %1
store i32 1, i32* %11
%35 = load i32, i32* %11
%36 = atomicrmw xor i32* %2, i32 %35 seq_cst
store i32 %36, i32* %12
%37 = load i32, i32* %12
store i32 %37, i32* %1
store i32 1, i32* %13
%38 = load i32, i32* %13
%39 = atomicrmw add i32* %2, i32 %38 seq_cst
%40 = add i32 %39, %38
store i32 %40, i32* %14
%41 = load i32, i32* %14
store i32 %41, i32* %1
store i32 1, i32* %15
%42 = load i32, i32* %15
%43 = atomicrmw sub i32* %2, i32 %42 seq_cst
%44 = sub i32 %43, %42
store i32 %44, i32* %16
%45 = load i32, i32* %16
store i32 %45, i32* %1
store i32 1, i32* %17
%46 = load i32, i32* %17
%47 = atomicrmw and i32* %2, i32 %46 seq_cst
%48 = and i32 %47, %46
store i32 %48, i32* %18
%49 = load i32, i32* %18
store i32 %49, i32* %1
store i32 1, i32* %19
%50 = load i32, i32* %19
%51 = atomicrmw or i32* %2, i32 %50 seq_cst
%52 = or i32 %51, %50
store i32 %52, i32* %20
%53 = load i32, i32* %20
store i32 %53, i32* %1
store i32 1, i32* %21
%54 = load i32, i32* %21
%55 = atomicrmw xor i32* %2, i32 %54 seq_cst
%56 = xor i32 %55, %54
store i32 %56, i32* %22
%57 = load i32, i32* %22
store i32 %57, i32* %1
ret void
}

LLVM IR (-O2):
define void @gnu_builtins() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = atomicrmw add i32* %1, i32 1 seq_cst
%4 = atomicrmw sub i32* %1, i32 1 seq_cst
%5 = atomicrmw and i32* %1, i32 1 seq_cst
%6 = atomicrmw or i32* %1, i32 1 seq_cst
%7 = atomicrmw xor i32* %1, i32 1 seq_cst
%8 = atomicrmw add i32* %1, i32 1 seq_cst
%9 = atomicrmw sub i32* %1, i32 1 seq_cst
%10 = atomicrmw and i32* %1, i32 1 seq_cst
%11 = atomicrmw or i32* %1, i32 1 seq_cst
%12 = atomicrmw xor i32* %1, i32 1 seq_cst
ret void
}