long double testdec(_Atomic long double *addr) { return (*addr)--; }


x86 assembly (clang, -O0):
<testdec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    %rsi,-0x60(%rbp)
mov    $0x10,%edi
lea    -0x20(%rbp),%rdx
mov    $0x5,%ecx
call   1040 <__atomic_load@plt>
fldt   -0x20(%rbp)
fld    %st(0)
fstpt  -0x58(%rbp)
fstpt  -0x4c(%rbp)
fldt   -0x4c(%rbp)
mov    -0x60(%rbp),%rsi
fld1
fchs
fadd   %st(1),%st
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
fxch   %st(1)
fstpt  -0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
fstpt  -0x40(%rbp)
mov    $0x10,%edi
lea    -0x30(%rbp),%rdx
lea    -0x40(%rbp),%rcx
mov    $0x5,%r9d
mov    %r9d,%r8d
call   1030 <__atomic_compare_exchange@plt>
fldt   -0x30(%rbp)
test   $0x1,%al
fstpt  -0x4c(%rbp)
jne    11a0 <testdec+0x80>
jmp    1152 <testdec+0x32>
fldt   -0x58(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testdec>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdi,%rbx
lea    0x40(%rsp),%rdx
mov    $0x10,%edi
mov    %rbx,%rsi
mov    $0x5,%ecx
call   1040 <__atomic_load@plt>
fldt   0x40(%rsp)
fld1
fchs
fstpt  0x24(%rsp)
mov    %rsp,%r14
lea    0x30(%rsp),%r15
fld    %st(0)
fstpt  0x18(%rsp)
nopl   (%rax)
fldt   0x24(%rsp)
fadd   %st(1),%st
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
fxch   %st(1)
fstpt  (%rsp)
movaps %xmm0,0x30(%rsp)
fstpt  0x30(%rsp)
mov    $0x10,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    $0x5,%r8d
mov    $0x5,%r9d
call   1030 <__atomic_compare_exchange@plt>
fldt   (%rsp)
test   %al,%al
je     1160 <testdec+0x40>
fstp   %st(0)
fldt   0x18(%rsp)
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define x86_fp80 @testdec(x86_fp80* %0) {
%2 = alloca x86_fp80*
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
store x86_fp80* %0, x86_fp80** %2
%6 = load x86_fp80*, x86_fp80** %2
%7 = bitcast x86_fp80* %6 to i8*
%8 = bitcast x86_fp80* %3 to i8*
%9 = load x86_fp80, x86_fp80* %3
br label %10
10: ; preds = %10, %1
%11 = phi x86_fp80 [ %9, %1 ], [ %19, %10 ]
%12 = fadd x86_fp80 %11, 0xKBFFF8000000000000000
%13 = bitcast x86_fp80* %4 to i8*
store x86_fp80 %11, x86_fp80* %4
%14 = bitcast x86_fp80* %5 to i8*
store x86_fp80 %12, x86_fp80* %5
%15 = bitcast x86_fp80* %6 to i8*
%16 = bitcast x86_fp80* %4 to i8*
%17 = bitcast x86_fp80* %5 to i8*
%18 = call zeroext i1 @__atomic_compare_exchange(i64 16, i8* %15, i8* %16, i8* %17, i32 5, i32 5)
%19 = load x86_fp80, x86_fp80* %4
br i1 %18, label %20, label %10
20: ; preds = %10
ret x86_fp80 %9
}

LLVM IR (-O2):
define x86_fp80 @testdec(x86_fp80* %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = bitcast x86_fp80* %0 to i8*
%6 = bitcast x86_fp80* %2 to i8*
%7 = load x86_fp80, x86_fp80* %2
%8 = bitcast x86_fp80* %3 to i8*
%9 = bitcast x86_fp80* %4 to i8*
br label %10
10: ; preds = %10, %1
%11 = phi x86_fp80 [ %7, %1 ], [ %14, %10 ]
%12 = fadd x86_fp80 %11, 0xKBFFF8000000000000000
store x86_fp80 %11, x86_fp80* %3
store x86_fp80 %12, x86_fp80* %4
%13 = call zeroext i1 @__atomic_compare_exchange(i64 16, i8* %5, i8* %8, i8* %9, i32 5, i32 5)
%14 = load x86_fp80, x86_fp80* %3
br i1 %13, label %15, label %10
15: ; preds = %10
ret x86_fp80 %7
}