void with_custom_macro() {
  ({
    typeof(foo()) __z;
    do
      __z = (foo());
    while (__z == -1);
    __z;
  });
  ({
    typeof(foo() == 1) __z;
    do
      __z = (foo() == 1);
    while (__z == -1);
    __z;
  });
  ({
    typeof((foo())) __z;
    do
      __z = ((foo()));
    while (__z == -1);
    __z;
  });
  ({
    typeof((int)(foo() == 1)) __z;
    do
      __z = ((int)(foo() == 1));
    while (__z == -1);
    __z;
  });
  ({
    typeof((bar(foo() == 1))) __z;
    do
      __z = ((bar(foo() == 1)));
    while (__z == -1);
    __z;
  });
  ({
    typeof((int)((bar(foo() == 1)) == 1)) __z;
    do
      __z = ((int)((bar(foo() == 1)) == 1));
    while (__z == -1);
    __z;
  });
}


x86 assembly (clang, -O0):
<with_custom_macro>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1040 <foo@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
je     1128 <with_custom_macro+0x8>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <foo@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     1142 <with_custom_macro+0x22>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <foo@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     1167 <with_custom_macro+0x47>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <foo@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     1181 <with_custom_macro+0x61>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <foo@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <bar@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
je     11a6 <with_custom_macro+0x86>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <foo@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <bar@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
je     11d2 <with_custom_macro+0xb2>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<with_custom_macro>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <foo@plt>
cmp    $0xffffffff,%eax
je     1130 <with_custom_macro+0x10>
xor    %eax,%eax
call   1040 <foo@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <foo@plt>
cmp    $0xffffffff,%eax
je     1150 <with_custom_macro+0x30>
xor    %eax,%eax
call   1040 <foo@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <foo@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
xor    %eax,%eax
call   1030 <bar@plt>
cmp    $0xffffffff,%eax
je     1170 <with_custom_macro+0x50>
xor    %eax,%eax
call   1040 <foo@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
xor    %eax,%eax
pop    %rcx
jmp    1030 <bar@plt>

LLVM IR (-O0):
define void @with_custom_macro() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
br label %13
13: ; preds = %15, %0
%14 = call i32 (...) @foo()
store i32 %14, i32* %1
br label %15
15: ; preds = %13
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, -1
br i1 %17, label %13, label %18
18: ; preds = %15
%19 = load i32, i32* %1
store i32 %19, i32* %2
%20 = load i32, i32* %2
br label %21
21: ; preds = %25, %18
%22 = call i32 (...) @foo()
%23 = icmp eq i32 %22, 1
%24 = zext i1 %23 to i32
store i32 %24, i32* %3
br label %25
25: ; preds = %21
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, -1
br i1 %27, label %21, label %28
28: ; preds = %25
%29 = load i32, i32* %3
store i32 %29, i32* %4
%30 = load i32, i32* %4
br label %31
31: ; preds = %33, %28
%32 = call i32 (...) @foo()
store i32 %32, i32* %5
br label %33
33: ; preds = %31
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, -1
br i1 %35, label %31, label %36
36: ; preds = %33
%37 = load i32, i32* %5
store i32 %37, i32* %6
%38 = load i32, i32* %6
br label %39
39: ; preds = %43, %36
%40 = call i32 (...) @foo()
%41 = icmp eq i32 %40, 1
%42 = zext i1 %41 to i32
store i32 %42, i32* %7
br label %43
43: ; preds = %39
%44 = load i32, i32* %7
%45 = icmp eq i32 %44, -1
br i1 %45, label %39, label %46
46: ; preds = %43
%47 = load i32, i32* %7
store i32 %47, i32* %8
%48 = load i32, i32* %8
br label %49
49: ; preds = %54, %46
%50 = call i32 (...) @foo()
%51 = icmp eq i32 %50, 1
%52 = zext i1 %51 to i32
%53 = call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 %52)
store i32 %53, i32* %9
br label %54
54: ; preds = %49
%55 = load i32, i32* %9
%56 = icmp eq i32 %55, -1
br i1 %56, label %49, label %57
57: ; preds = %54
%58 = load i32, i32* %9
store i32 %58, i32* %10
%59 = load i32, i32* %10
br label %60
60: ; preds = %67, %57
%61 = call i32 (...) @foo()
%62 = icmp eq i32 %61, 1
%63 = zext i1 %62 to i32
%64 = call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 %63)
%65 = icmp eq i32 %64, 1
%66 = zext i1 %65 to i32
store i32 %66, i32* %11
br label %67
67: ; preds = %60
%68 = load i32, i32* %11
%69 = icmp eq i32 %68, -1
br i1 %69, label %60, label %70
70: ; preds = %67
%71 = load i32, i32* %11
store i32 %71, i32* %12
%72 = load i32, i32* %12
ret void
}

LLVM IR (-O2):
define void @with_custom_macro() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (...) @foo()
%3 = icmp eq i32 %2, -1
br i1 %3, label %1, label %4
4: ; preds = %1
%5 = tail call i32 (...) @foo()
br label %6
6: ; preds = %6, %4
%7 = tail call i32 (...) @foo()
%8 = icmp eq i32 %7, -1
br i1 %8, label %6, label %9
9: ; preds = %6
%10 = tail call i32 (...) @foo()
br label %11
11: ; preds = %11, %9
%12 = tail call i32 (...) @foo()
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i32
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %11, label %17
17: ; preds = %11
%18 = tail call i32 (...) @foo()
%19 = icmp eq i32 %18, 1
%20 = zext i1 %19 to i32
%21 = tail call i32 (i32, ...) bitcast (i32 (...)* @bar to i32 (i32, ...)*)(i32 %20)
ret void
}