#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 expand_macsym(char *, int, char **, int);
char *findc(char *, char);
unsigned expand(char *text, int curr_macro, char **macparm, int n_macparms) {
  while ((text = findc(text, '`')) != NULL)
    if (expand_macsym(text, curr_macro, macparm, n_macparms) == 0xFFFD)
      return 0xFFFD;
  return 0;
}


x86 assembly (clang, -O0):
<expand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x60,%esi
call   1030 <findc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1181 <expand+0x61>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <expand_macsym@plt>
cmp    $0xfffd,%eax
jne    117c <expand+0x5c>
movl   $0xfffd,-0x4(%rbp)
jmp    1188 <expand+0x68>
jmp    1136 <expand+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x60,%esi
call   1030 <findc@plt>
test   %rax,%rax
je     1173 <expand+0x53>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1040 <expand_macsym@plt>
cmp    $0xfffd,%eax
jne    1140 <expand+0x20>
mov    $0xfffd,%eax
jmp    1175 <expand+0x55>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @expand(i8* %0, i32 %1, i8** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
br label %10
10: ; preds = %22, %4
%11 = load i8*, i8** %6
%12 = call i8* @findc(i8* %11, i8 signext 96)
store i8* %12, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = load i32, i32* %7
%17 = load i8**, i8*** %8
%18 = load i32, i32* %9
%19 = call i32 @expand_macsym(i8* %15, i32 %16, i8** %17, i32 %18)
%20 = icmp eq i32 %19, 65533
br i1 %20, label %21, label %22
21: ; preds = %14
store i32 65533, i32* %5
br label %24
22: ; preds = %14
br label %10
23: ; preds = %10
store i32 0, i32* %5
br label %24
24: ; preds = %23, %21
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
define i32 @expand(i8* %0, i32 %1, i8** %2, i32 %3) {
br label %5
5: ; preds = %9, %4
%6 = phi i8* [ %0, %4 ], [ %7, %9 ]
%7 = tail call i8* @findc(i8* %6, i8 signext 96)
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i32 @expand_macsym(i8* %7, i32 %1, i8** %2, i32 %3)
%11 = icmp eq i32 %10, 65533
br i1 %11, label %12, label %5
12: ; preds = %5, %9
%13 = phi i32 [ 65533, %9 ], [ 0, %5 ]
ret i32 %13
}