#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ atomic_int;

/* Variables and functions */
int atomic_compare_exchange_strong(int /*<<< orphan*/ *, int *,
                                   int /*<<< orphan*/);
int atomic_compare_exchange_weak(int /*<<< orphan*/ *, int *,
                                 int /*<<< orphan*/);
int atomic_exchange(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ atomic_init(int /*<<< orphan*/ *, int /*<<< orphan*/);
int atomic_load(int /*<<< orphan*/ *);
int /*<<< orphan*/ atomic_store(int /*<<< orphan*/ *, int);
void c11_builtins() {
  bool b;
  int _a;
  atomic_int a;
  atomic_init(&a, 0);
  _a = atomic_load(&a);
  atomic_store(&a, 1);
  _a = atomic_exchange(&a, 2);
  b = atomic_compare_exchange_strong(&a, &_a, 0);
  b = atomic_compare_exchange_weak(&a, &_a, 0);
}


x86 assembly (clang, -O0):
<c11_builtins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
call   1080 <atomic_init@plt>
lea    -0xc(%rbp),%rdi
call   1050 <atomic_load@plt>
mov    %eax,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x1,%esi
call   1040 <atomic_store@plt>
lea    -0xc(%rbp),%rdi
mov    $0x2,%esi
call   1060 <atomic_exchange@plt>
mov    %eax,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1070 <atomic_compare_exchange_strong@plt>
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1030 <atomic_compare_exchange_weak@plt>
mov    %eax,-0x4(%rbp)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c11_builtins>:
push   %r14
push   %rbx
push   %rax
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <atomic_init@plt>
mov    %rbx,%rdi
call   1050 <atomic_load@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <atomic_store@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1060 <atomic_exchange@plt>
mov    %eax,(%rsp)
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1070 <atomic_compare_exchange_strong@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <atomic_compare_exchange_weak@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @c11_builtins() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @atomic_init(i32* %3, i32 0)
%5 = call i32 @atomic_load(i32* %3)
store i32 %5, i32* %2
%6 = call i32 @atomic_store(i32* %3, i32 1)
%7 = call i32 @atomic_exchange(i32* %3, i32 2)
store i32 %7, i32* %2
%8 = call i32 @atomic_compare_exchange_strong(i32* %3, i32* %2, i32 0)
store i32 %8, i32* %1
%9 = call i32 @atomic_compare_exchange_weak(i32* %3, i32* %2, i32 0)
store i32 %9, i32* %1
ret void
}

LLVM IR (-O2):
define void @c11_builtins() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @atomic_init(i32* %2, i32 0)
%6 = call i32 @atomic_load(i32* %2)
%7 = call i32 @atomic_store(i32* %2, i32 1)
%8 = call i32 @atomic_exchange(i32* %2, i32 2)
store i32 %8, i32* %1
%9 = call i32 @atomic_compare_exchange_strong(i32* %2, i32* %1, i32 0)
%10 = call i32 @atomic_compare_exchange_weak(i32* %2, i32* %1, i32 0)
ret void
}