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

/* Variables and functions */
int chaz_CC_test_compile(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ sprintf(char *, char const *, char const *, char const *);
int strlen(char const *);
int chaz_CC_test_macro(const char *expression, const char *predicate) {
  static const char template[] = "#if (%s) %s"
                                 "\n"
                                 "int i;"
                                 "\n"
                                 "#else"
                                 "\n"
                                 "#error \"nope\""
                                 "\n"
                                 "#endif"
                                 "\n";
  size_t size = sizeof(template) + strlen(expression) + strlen(predicate) + 20;
  char *code = (char *)malloc(size);
  int retval = 0;
  sprintf(code, template, expression, predicate);
  retval = chaz_CC_test_compile(code);
  free(code);
  return retval;
}


x86 assembly (clang, -O0):
<chaz_CC_test_macro>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cltq
add    $0x2f,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x14,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe49(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <chaz_CC_test_compile@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaz_CC_test_macro>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
movslq %eax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0x43,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe7a(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <chaz_CC_test_compile@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@chaz_CC_test_macro.template = internal constant [47 x i8] c"#if (%s) %s\0Aint i;\0A#else\0A#error \22nope\22\0A#endif\0A\00"
define i32 @chaz_CC_test_macro(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = sext i32 %9 to i64
%11 = add i64 47, %10
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = sext i32 %13 to i64
%15 = add i64 %11, %14
%16 = add i64 %15, 20
store i64 %16, i64* %5
%17 = load i64, i64* %5
%18 = call i64 @malloc(i64 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %6
store i32 0, i32* %7
%20 = load i8*, i8** %6
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @chaz_CC_test_macro.template, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i8*, i8** %6
%25 = call i32 @chaz_CC_test_compile(i8* %24)
store i32 %25, i32* %7
%26 = load i8*, i8** %6
%27 = call i32 @free(i8* %26)
%28 = load i32, i32* %7
ret i32 %28
}

LLVM IR (-O2):
@chaz_CC_test_macro.template = internal constant [47 x i8] c"#if (%s) %s\0Aint i;\0A#else\0A#error \22nope\22\0A#endif\0A\00"
define i32 @chaz_CC_test_macro(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = sext i32 %3 to i64
%5 = tail call i32 @strlen(i8* %1)
%6 = sext i32 %5 to i64
%7 = add nsw i64 %4, 67
%8 = add nsw i64 %7, %6
%9 = tail call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @chaz_CC_test_macro.template, i64 0, i64 0), i8* %0, i8* %1)
%12 = tail call i32 @chaz_CC_test_compile(i8* %10)
%13 = tail call i32 @free(i8* %10)
ret i32 %12
}