#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 */

/* Variables and functions */
scalar_t__ chaz_AtomicOps_osatomic_cas_ptr();
int /*<<< orphan*/ chaz_ConfWriter_add_def(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ chaz_ConfWriter_end_module();
int /*<<< orphan*/ chaz_ConfWriter_start_module(char *);
scalar_t__ chaz_HeadCheck_check_header(char *);
void chaz_AtomicOps_run(void) {
  chaz_ConfWriter_start_module("AtomicOps");
  if (chaz_HeadCheck_check_header("libkern/OSAtomic.h")) {
    chaz_ConfWriter_add_def("HAS_LIBKERN_OSATOMIC_H", NULL);
    if (chaz_AtomicOps_osatomic_cas_ptr()) {
      chaz_ConfWriter_add_def("HAS_OSATOMIC_CAS_PTR", NULL);
    }
  }
  if (chaz_HeadCheck_check_header("sys/atomic.h")) {
    chaz_ConfWriter_add_def("HAS_SYS_ATOMIC_H", NULL);
  }
  if (chaz_HeadCheck_check_header("windows.h") &&
      chaz_HeadCheck_check_header("intrin.h")) {
    chaz_ConfWriter_add_def("HAS_INTRIN_H", NULL);
  }
  chaz_ConfWriter_end_module();
}


x86 assembly (clang, -O0):
<chaz_AtomicOps_run>:
push   %rbp
mov    %rsp,%rbp
lea    0xea5(%rip),%rdi
call   1030 <chaz_ConfWriter_start_module@plt>
lea    0xea3(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
cmp    $0x0,%rax
je     11ac <chaz_AtomicOps_run+0x5c>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
mov    $0x0,%al
call   1050 <chaz_AtomicOps_osatomic_cas_ptr@plt>
cmp    $0x0,%rax
je     11a7 <chaz_AtomicOps_run+0x57>
lea    0xe96(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
jmp    11ac <chaz_AtomicOps_run+0x5c>
lea    0xe96(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
cmp    $0x0,%rax
je     11d2 <chaz_AtomicOps_run+0x82>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
lea    0xe8e(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
cmp    $0x0,%rax
je     120e <chaz_AtomicOps_run+0xbe>
lea    0xe82(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
cmp    $0x0,%rax
je     120e <chaz_AtomicOps_run+0xbe>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
mov    $0x0,%al
call   1070 <chaz_ConfWriter_end_module@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaz_AtomicOps_run>:
push   %rax
lea    0xea8(%rip),%rdi
call   1030 <chaz_ConfWriter_start_module@plt>
lea    0xea6(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
test   %rax,%rax
je     1196 <chaz_AtomicOps_run+0x46>
lea    0xea8(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
xor    %eax,%eax
call   1050 <chaz_AtomicOps_osatomic_cas_ptr@plt>
test   %rax,%rax
je     1196 <chaz_AtomicOps_run+0x46>
lea    0xea5(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
lea    0xeac(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
test   %rax,%rax
je     11b5 <chaz_AtomicOps_run+0x65>
lea    0xea8(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
lea    0xeab(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
test   %rax,%rax
je     11e5 <chaz_AtomicOps_run+0x95>
lea    0xea4(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
test   %rax,%rax
je     11e5 <chaz_AtomicOps_run+0x95>
lea    0xe9c(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <chaz_ConfWriter_end_module@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"AtomicOps\00"
@.str.1 = [19 x i8] c"libkern/OSAtomic.h\00"
@.str.2 = [23 x i8] c"HAS_LIBKERN_OSATOMIC_H\00"
@.str.3 = [21 x i8] c"HAS_OSATOMIC_CAS_PTR\00"
@.str.4 = [13 x i8] c"sys/atomic.h\00"
@.str.5 = [17 x i8] c"HAS_SYS_ATOMIC_H\00"
@.str.6 = [10 x i8] c"windows.h\00"
@.str.7 = [9 x i8] c"intrin.h\00"
@.str.8 = [13 x i8] c"HAS_INTRIN_H\00"
define void @chaz_AtomicOps_run() {
%1 = call i32 @chaz_ConfWriter_start_module(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = call i64 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %0
%5 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32* null)
%6 = call i64 (...) @chaz_AtomicOps_osatomic_cas_ptr()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %10
10: ; preds = %8, %4
br label %11
11: ; preds = %10, %0
%12 = call i64 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32* null)
br label %16
16: ; preds = %14, %11
%17 = call i64 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = call i64 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32* null)
br label %24
24: ; preds = %22, %19, %16
%25 = call i32 (...) @chaz_ConfWriter_end_module()
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"AtomicOps\00"
@.str.1 = [19 x i8] c"libkern/OSAtomic.h\00"
@.str.2 = [23 x i8] c"HAS_LIBKERN_OSATOMIC_H\00"
@.str.3 = [21 x i8] c"HAS_OSATOMIC_CAS_PTR\00"
@.str.4 = [13 x i8] c"sys/atomic.h\00"
@.str.5 = [17 x i8] c"HAS_SYS_ATOMIC_H\00"
@.str.6 = [10 x i8] c"windows.h\00"
@.str.7 = [9 x i8] c"intrin.h\00"
@.str.8 = [13 x i8] c"HAS_INTRIN_H\00"
define void @chaz_AtomicOps_run() {
%1 = tail call i32 @chaz_ConfWriter_start_module(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32* null)
%6 = tail call i64 (...) @chaz_AtomicOps_osatomic_cas_ptr()
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %10
10: ; preds = %4, %8, %0
%11 = tail call i64 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32* null)
br label %15
15: ; preds = %13, %10
%16 = tail call i64 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = tail call i64 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32* null)
br label %23
23: ; preds = %21, %18, %15
%24 = tail call i32 (...) @chaz_ConfWriter_end_module()
ret void
}