#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*/ memory_order;
typedef int /*<<< orphan*/ atomic_flag;

/* Variables and functions */
int /*<<< orphan*/ atomic_flag_clear(int /*<<< orphan*/ volatile *);
int /*<<< orphan*/ atomic_flag_clear_explicit(int /*<<< orphan*/ volatile *,
                                              int /*<<< orphan*/);
int /*<<< orphan*/ atomic_flag_test_and_set(int /*<<< orphan*/ volatile *);
int /*<<< orphan*/
atomic_flag_test_and_set_explicit(int /*<<< orphan*/ volatile *,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ memory_order_relaxed;
int main() {
  volatile atomic_flag f;
  volatile atomic_flag *p = &f;
  memory_order m = memory_order_relaxed;
  atomic_flag_test_and_set(p);
  atomic_flag_test_and_set_explicit(p, m);
  atomic_flag_clear(p);
  atomic_flag_clear_explicit(p, m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <atomic_flag_test_and_set@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <atomic_flag_test_and_set_explicit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <atomic_flag_clear@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <atomic_flag_clear_explicit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e9d(%rip),%rax
mov    (%rax),%ebx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1040 <atomic_flag_test_and_set@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <atomic_flag_test_and_set_explicit@plt>
mov    %r14,%rdi
call   1030 <atomic_flag_clear@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <atomic_flag_clear_explicit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@memory_order_relaxed = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
store i32* %2, i32** %3
%5 = load i32, i32* @memory_order_relaxed
store i32 %5, i32* %4
%6 = load i32*, i32** %3
%7 = call i32 @atomic_flag_test_and_set(i32* %6)
%8 = load i32*, i32** %3
%9 = load i32, i32* %4
%10 = call i32 @atomic_flag_test_and_set_explicit(i32* %8, i32 %9)
%11 = load i32*, i32** %3
%12 = call i32 @atomic_flag_clear(i32* %11)
%13 = load i32*, i32** %3
%14 = load i32, i32* %4
%15 = call i32 @atomic_flag_clear_explicit(i32* %13, i32 %14)
ret i32 0
}

LLVM IR (-O2):
@memory_order_relaxed = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @memory_order_relaxed
%4 = call i32 @atomic_flag_test_and_set(i32* %1)
%5 = call i32 @atomic_flag_test_and_set_explicit(i32* %1, i32 %3)
%6 = call i32 @atomic_flag_clear(i32* %1)
%7 = call i32 @atomic_flag_clear_explicit(i32* %1, i32 %3)
ret i32 0
}