#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 */
int /*<<< orphan*/ test(char *, char *);
void TEST_cpp_recursive_macro(void) {
  test("\"ok\"", "#define FOO() \"ok\"\n"
                 "#define BAR FOO()\n"
                 "BAR");
  test("\"ok\"", "#define FOO() \"ok\"\n"
                 "#define BAR() FOO()\n"
                 "BAR()");
  test("\"vers2\"", "#define str(s) # s\n"
                    "#define xstr(s) str(s)\n"
                    "#define INCFILE(n) vers ## n\n"
                    "xstr(INCFILE(2))");
  test("int foo=1; foo, 3", "int foo = 1;\n"
                            "#define foo foo, 3\n"
                            "foo");
  test("\"hello\", \"hello\" \", world\"", "#define glue(a, b) a ## b\n"
                                           "#define xglue(a, b) glue(a, b)\n"
                                           "#define HIGHLOW \"hello\"\n"
                                           "#define LOW LOW \", world\"\n"
                                           "glue(HIGH, LOW), xglue(HIGH, LOW)");
  test("123 45 67 89 10 11 12",
       "#define t(x,y,z) x ## y ## z\n"
       "t(1,2,3) t(,4,5) t(6,,7) t(8,9,) t(10,,) t(,11,) t(,,12) t(,,)");
  test("(1-1)", "#define OBJ_LIKE (1-1)\n"
                "OBJ_LIKE");
  test("(1-1)", "#define OBJ_LIKE /* white space */ (1-1) /* other */\n"
                "OBJ_LIKE");
  test("(7)", "#define FUNC_LIKE(a) ( a )\n"
              "FUNC_LIKE(7)");
  test("(7)", "#define FUNC_LIKE( a )( /* note the white space */ \\\n"
              "a /* other stuff on this line\n"
              "*/ )\n"
              "FUNC_LIKE(7)");
  test("int A=1; 1+A", "int A=1;\n"
                       "#define A 1+A\n"
                       "#define B(x) x\n"
                       "B(A)");
}


x86 assembly (clang, -O0):
<TEST_cpp_recursive_macro>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
lea    0xee3(%rip),%rsi
call   1030 <test@plt>
lea    0xed2(%rip),%rdi
lea    0xef9(%rip),%rsi
call   1030 <test@plt>
lea    0xf1a(%rip),%rdi
lea    0xf1b(%rip),%rsi
call   1030 <test@plt>
lea    0xf67(%rip),%rdi
lea    0xf72(%rip),%rsi
call   1030 <test@plt>
lea    0xf8a(%rip),%rdi
lea    0xf9e(%rip),%rsi
call   1030 <test@plt>
lea    0x101f(%rip),%rdi
lea    0x102e(%rip),%rsi
call   1030 <test@plt>
lea    0x107e(%rip),%rdi
lea    0x107d(%rip),%rsi
call   1030 <test@plt>
lea    0x106b(%rip),%rdi
lea    0x108a(%rip),%rsi
call   1030 <test@plt>
lea    0x1145(%rip),%rdi
lea    0x10b5(%rip),%rsi
call   1030 <test@plt>
lea    0x1132(%rip),%rdi
lea    0x10ca(%rip),%rsi
call   1030 <test@plt>
lea    0x1123(%rip),%rdi
lea    0x1129(%rip),%rsi
call   1030 <test@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<TEST_cpp_recursive_macro>:
push   %rbx
lea    0xee8(%rip),%rbx
lea    0xee6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <test@plt>
lea    0xf00(%rip),%rsi
mov    %rbx,%rdi
call   1030 <test@plt>
lea    0xf1e(%rip),%rdi
lea    0xf1f(%rip),%rsi
call   1030 <test@plt>
lea    0xf6b(%rip),%rdi
lea    0xf76(%rip),%rsi
call   1030 <test@plt>
lea    0xf8e(%rip),%rdi
lea    0xfa2(%rip),%rsi
call   1030 <test@plt>
lea    0x1023(%rip),%rdi
lea    0x1032(%rip),%rsi
call   1030 <test@plt>
lea    0x1082(%rip),%rbx
lea    0x1081(%rip),%rsi
mov    %rbx,%rdi
call   1030 <test@plt>
lea    0x1092(%rip),%rsi
mov    %rbx,%rdi
call   1030 <test@plt>
lea    0x114a(%rip),%rbx
lea    0x10ba(%rip),%rsi
mov    %rbx,%rdi
call   1030 <test@plt>
lea    0x10d3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <test@plt>
lea    0x1129(%rip),%rdi
lea    0x112f(%rip),%rsi
pop    %rbx
jmp    1030 <test@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"\22ok\22\00"
@.str.1 = [41 x i8] c"#define FOO() \22ok\22\0A#define BAR FOO()\0ABAR\00"
@.str.2 = [45 x i8] c"#define FOO() \22ok\22\0A#define BAR() FOO()\0ABAR()\00"
@.str.3 = [8 x i8] c"\22vers2\22\00"
@.str.4 = [88 x i8] c"#define str(s) # s\0A#define xstr(s) str(s)\0A#define INCFILE(n) vers ## n\0Axstr(INCFILE(2))\00"
@.str.5 = [18 x i8] c"int foo=1; foo, 3\00"
@.str.6 = [36 x i8] c"int foo = 1;\0A#define foo foo, 3\0Afoo\00"
@.str.7 = [27 x i8] c"\22hello\22, \22hello\22 \22, world\22\00"
@.str.8 = [141 x i8] c"#define glue(a, b) a ## b\0A#define xglue(a, b) glue(a, b)\0A#define HIGHLOW \22hello\22\0A#define LOW LOW \22, world\22\0Aglue(HIGH, LOW), xglue(HIGH, LOW)\00"
@.str.9 = [22 x i8] c"123 45 67 89 10 11 12\00"
@.str.10 = [92 x i8] c"#define t(x,y,z) x ## y ## z\0At(1,2,3) t(,4,5) t(6,,7) t(8,9,) t(10,,) t(,11,) t(,,12) t(,,)\00"
@.str.11 = [6 x i8] c"(1-1)\00"
@.str.12 = [32 x i8] c"#define OBJ_LIKE (1-1)\0AOBJ_LIKE\00"
@.str.13 = [62 x i8] c"#define OBJ_LIKE /* white space */ (1-1) /* other */\0AOBJ_LIKE\00"
@.str.14 = [4 x i8] c"(7)\00"
@.str.15 = [40 x i8] c"#define FUNC_LIKE(a) ( a )\0AFUNC_LIKE(7)\00"
@.str.16 = [101 x i8] c"#define FUNC_LIKE( a )( /* note the white space */ \\\0Aa /* other stuff on this line\0A*/ )\0AFUNC_LIKE(7)\00"
@.str.17 = [13 x i8] c"int A=1; 1+A\00"
@.str.18 = [43 x i8] c"int A=1;\0A#define A 1+A\0A#define B(x) x\0AB(A)\00"
define void @TEST_cpp_recursive_macro() {
%1 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%3 = call i32 @test(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.4, i64 0, i64 0))
%4 = call i32 @test(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%5 = call i32 @test(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.8, i64 0, i64 0))
%6 = call i32 @test(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.10, i64 0, i64 0))
%7 = call i32 @test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%8 = call i32 @test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.13, i64 0, i64 0))
%9 = call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.15, i64 0, i64 0))
%10 = call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.16, i64 0, i64 0))
%11 = call i32 @test(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.18, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\22ok\22\00"
@.str.1 = [41 x i8] c"#define FOO() \22ok\22\0A#define BAR FOO()\0ABAR\00"
@.str.2 = [45 x i8] c"#define FOO() \22ok\22\0A#define BAR() FOO()\0ABAR()\00"
@.str.3 = [8 x i8] c"\22vers2\22\00"
@.str.4 = [88 x i8] c"#define str(s) # s\0A#define xstr(s) str(s)\0A#define INCFILE(n) vers ## n\0Axstr(INCFILE(2))\00"
@.str.5 = [18 x i8] c"int foo=1; foo, 3\00"
@.str.6 = [36 x i8] c"int foo = 1;\0A#define foo foo, 3\0Afoo\00"
@.str.7 = [27 x i8] c"\22hello\22, \22hello\22 \22, world\22\00"
@.str.8 = [141 x i8] c"#define glue(a, b) a ## b\0A#define xglue(a, b) glue(a, b)\0A#define HIGHLOW \22hello\22\0A#define LOW LOW \22, world\22\0Aglue(HIGH, LOW), xglue(HIGH, LOW)\00"
@.str.9 = [22 x i8] c"123 45 67 89 10 11 12\00"
@.str.10 = [92 x i8] c"#define t(x,y,z) x ## y ## z\0At(1,2,3) t(,4,5) t(6,,7) t(8,9,) t(10,,) t(,11,) t(,,12) t(,,)\00"
@.str.11 = [6 x i8] c"(1-1)\00"
@.str.12 = [32 x i8] c"#define OBJ_LIKE (1-1)\0AOBJ_LIKE\00"
@.str.13 = [62 x i8] c"#define OBJ_LIKE /* white space */ (1-1) /* other */\0AOBJ_LIKE\00"
@.str.14 = [4 x i8] c"(7)\00"
@.str.15 = [40 x i8] c"#define FUNC_LIKE(a) ( a )\0AFUNC_LIKE(7)\00"
@.str.16 = [101 x i8] c"#define FUNC_LIKE( a )( /* note the white space */ \\\0Aa /* other stuff on this line\0A*/ )\0AFUNC_LIKE(7)\00"
@.str.17 = [13 x i8] c"int A=1; 1+A\00"
@.str.18 = [43 x i8] c"int A=1;\0A#define A 1+A\0A#define B(x) x\0AB(A)\00"
define void @TEST_cpp_recursive_macro() {
%1 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @test(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.4, i64 0, i64 0))
%4 = tail call i32 @test(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%5 = tail call i32 @test(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str.8, i64 0, i64 0))
%6 = tail call i32 @test(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.10, i64 0, i64 0))
%7 = tail call i32 @test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%8 = tail call i32 @test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.13, i64 0, i64 0))
%9 = tail call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.15, i64 0, i64 0))
%10 = tail call i32 @test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.16, i64 0, i64 0))
%11 = tail call i32 @test(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.18, i64 0, i64 0))
ret void
}