#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_CC_test_compile(char *);
int /*<<< orphan*/ chaz_ConfWriter_add_def(char *, char const *);
int /*<<< orphan*/ chaz_ConfWriter_end_module();
int /*<<< orphan*/ chaz_ConfWriter_start_module(char *);
int /*<<< orphan*/ chaz_FuncMacro_probe_inline();
void chaz_FuncMacro_run(void) {
  int has_funcmac = 0;
  int has_iso_funcmac = 0;
  int has_gnuc_funcmac = 0;
  chaz_ConfWriter_start_module("FuncMacro");
  if (chaz_CC_test_compile("const char *f() { return __func__; }")) {
    has_funcmac = 1;
    has_iso_funcmac = 1;
  }
  if (chaz_CC_test_compile("const char *f() { return __FUNCTION__; }")) {
    has_funcmac = 1;
    has_gnuc_funcmac = 1;
  }
  if (has_funcmac) {
    const char *macro_text = has_iso_funcmac ? "__func__" : "__FUNCTION__";
    chaz_ConfWriter_add_def("HAS_FUNC_MACRO", NULL);
    chaz_ConfWriter_add_def("FUNC_MACRO", macro_text);
  }
  if (has_iso_funcmac) {
    chaz_ConfWriter_add_def("HAS_ISO_FUNC_MACRO", NULL);
  }
  if (has_gnuc_funcmac) {
    chaz_ConfWriter_add_def("HAS_GNUC_FUNC_MACRO", NULL);
  }
  chaz_FuncMacro_probe_inline();
  chaz_ConfWriter_end_module();
}


x86 assembly (clang, -O0):
<chaz_FuncMacro_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe8c(%rip),%rdi
call   1030 <chaz_ConfWriter_start_module@plt>
lea    0xe8a(%rip),%rdi
call   1060 <chaz_CC_test_compile@plt>
cmp    $0x0,%rax
je     119d <chaz_FuncMacro_run+0x4d>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xe8b(%rip),%rdi
call   1060 <chaz_CC_test_compile@plt>
cmp    $0x0,%rax
je     11c1 <chaz_FuncMacro_run+0x71>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1207 <chaz_FuncMacro_run+0xb7>
mov    -0x8(%rbp),%edx
lea    0xe8c(%rip),%rax
lea    0xe7c(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x18(%rbp)
lea    0xe80(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <chaz_ConfWriter_add_def@plt>
mov    -0x18(%rbp),%rsi
lea    0xe97(%rip),%rdi
call   1050 <chaz_ConfWriter_add_def@plt>
cmpl   $0x0,-0x8(%rbp)
je     1221 <chaz_FuncMacro_run+0xd1>
lea    0xe65(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <chaz_ConfWriter_add_def@plt>
cmpl   $0x0,-0xc(%rbp)
je     123b <chaz_FuncMacro_run+0xeb>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <chaz_ConfWriter_add_def@plt>
mov    $0x0,%al
call   1040 <chaz_FuncMacro_probe_inline@plt>
mov    $0x0,%al
call   1070 <chaz_ConfWriter_end_module@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaz_FuncMacro_run>:
push   %r15
push   %r14
push   %rbx
lea    0xea4(%rip),%rdi
call   1030 <chaz_ConfWriter_start_module@plt>
lea    0xea2(%rip),%rdi
call   1060 <chaz_CC_test_compile@plt>
mov    %rax,%rbx
lea    0xeb8(%rip),%rdi
call   1060 <chaz_CC_test_compile@plt>
mov    %rax,%r14
or     %rbx,%rax
je     11b6 <chaz_FuncMacro_run+0x66>
test   %rbx,%rbx
lea    0xed3(%rip),%rax
lea    0xec3(%rip),%r15
cmove  %rax,%r15
lea    0xece(%rip),%rdi
xor    %esi,%esi
call   1050 <chaz_ConfWriter_add_def@plt>
lea    0xeeb(%rip),%rdi
mov    %r15,%rsi
call   1050 <chaz_ConfWriter_add_def@plt>
test   %rbx,%rbx
je     11c9 <chaz_FuncMacro_run+0x79>
lea    0xebb(%rip),%rdi
xor    %esi,%esi
call   1050 <chaz_ConfWriter_add_def@plt>
test   %r14,%r14
je     11dc <chaz_FuncMacro_run+0x8c>
lea    0xebb(%rip),%rdi
xor    %esi,%esi
call   1050 <chaz_ConfWriter_add_def@plt>
xor    %eax,%eax
call   1040 <chaz_FuncMacro_probe_inline@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <chaz_ConfWriter_end_module@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"FuncMacro\00"
@.str.1 = [37 x i8] c"const char *f() { return __func__; }\00"
@.str.2 = [41 x i8] c"const char *f() { return __FUNCTION__; }\00"
@.str.3 = [9 x i8] c"__func__\00"
@.str.4 = [13 x i8] c"__FUNCTION__\00"
@.str.5 = [15 x i8] c"HAS_FUNC_MACRO\00"
@.str.6 = [11 x i8] c"FUNC_MACRO\00"
@.str.7 = [19 x i8] c"HAS_ISO_FUNC_MACRO\00"
@.str.8 = [20 x i8] c"HAS_GNUC_FUNC_MACRO\00"
define void @chaz_FuncMacro_run() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = call i32 @chaz_ConfWriter_start_module(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @chaz_CC_test_compile(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %1
store i32 1, i32* %2
br label %9
9: ; preds = %8, %0
%10 = call i64 @chaz_CC_test_compile(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 1, i32* %1
store i32 1, i32* %3
br label %13
13: ; preds = %12, %9
%14 = load i32, i32* %1
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i64
%20 = select i1 %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0)
store i8* %20, i8** %4
%21 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* null)
%22 = load i8*, i8** %4
%23 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %16, %13
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* null)
br label %29
29: ; preds = %27, %24
%30 = load i32, i32* %3
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* null)
br label %34
34: ; preds = %32, %29
%35 = call i32 (...) @chaz_FuncMacro_probe_inline()
%36 = call i32 (...) @chaz_ConfWriter_end_module()
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"FuncMacro\00"
@.str.1 = [37 x i8] c"const char *f() { return __func__; }\00"
@.str.2 = [41 x i8] c"const char *f() { return __FUNCTION__; }\00"
@.str.3 = [9 x i8] c"__func__\00"
@.str.4 = [13 x i8] c"__FUNCTION__\00"
@.str.5 = [15 x i8] c"HAS_FUNC_MACRO\00"
@.str.6 = [11 x i8] c"FUNC_MACRO\00"
@.str.7 = [19 x i8] c"HAS_ISO_FUNC_MACRO\00"
@.str.8 = [20 x i8] c"HAS_GNUC_FUNC_MACRO\00"
define void @chaz_FuncMacro_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_CC_test_compile(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
%4 = tail call i64 @chaz_CC_test_compile(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i1 %3, i1 false
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = select i1 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
%9 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* null)
%10 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %8)
br label %11
11: ; preds = %7, %0
br i1 %3, label %14, label %12
12: ; preds = %11
%13 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* null)
br label %14
14: ; preds = %12, %11
br i1 %5, label %17, label %15
15: ; preds = %14
%16 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* null)
br label %17
17: ; preds = %15, %14
%18 = tail call i32 (...) @chaz_FuncMacro_probe_inline()
%19 = tail call i32 (...) @chaz_ConfWriter_end_module()
ret void
}