#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__ MatchClass(char, char);
char *PolySubst(char *string, char clazz, char n) {
  register char *ptr;
  static char area[1024];
  ptr = area;
  while (*string) {
    *(ptr++) = (MatchClass(clazz, *string) ? n : *string);
    string++;
  }
  *ptr = '\0';
  return (area);
}


x86 assembly (clang, -O0):
<PolySubst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
lea    0x2f12(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1198 <PolySubst+0x88>
mov    -0x9(%rbp),%cl
mov    -0x8(%rbp),%rax
movsbl %cl,%edi
movsbl (%rax),%esi
call   1030 <MatchClass@plt>
cmp    $0x0,%rax
je     1167 <PolySubst+0x57>
movsbl -0xa(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1171 <PolySubst+0x61>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1132 <PolySubst+0x22>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e9a(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PolySubst>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     116b <PolySubst+0x5b>
mov    %edx,%r14d
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0x2f12(%rip),%rbp
movsbl %sil,%r15d
jmp    1152 <PolySubst+0x42>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %cl,0x0(%rbp)
add    $0x1,%rbp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1172 <PolySubst+0x62>
movsbl %al,%esi
mov    %r15d,%edi
call   1030 <MatchClass@plt>
mov    %r14d,%ecx
test   %rax,%rax
jne    1140 <PolySubst+0x30>
movzbl -0x1(%rbx),%ecx
jmp    1140 <PolySubst+0x30>
lea    0x2ece(%rip),%rbp
movb   $0x0,0x0(%rbp)
lea    0x2ec3(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PolySubst.area = internal global [1024 x i8] zeroinitializer
define i8* @PolySubst(i8* %0, i8 signext %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 %2, i8* %6
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @PolySubst.area, i64 0, i64 0), i8** %7
br label %8
8: ; preds = %25, %3
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = load i8, i8* %5
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = call i64 @MatchClass(i8 signext %13, i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
br label %25
21: ; preds = %12
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
br label %25
25: ; preds = %21, %18
%26 = phi i32 [ %20, %18 ], [ %24, %21 ]
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %7
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %7
store i8 %27, i8* %28
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
br label %8
32: ; preds = %8
%33 = load i8*, i8** %7
store i8 0, i8* %33
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @PolySubst.area, i64 0, i64 0)
}

LLVM IR (-O2):
@PolySubst.area = internal global [1024 x i8] zeroinitializer
define i8* @PolySubst(i8* nocapture %0, i8 signext %1, i8 signext %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %3, %14
%7 = phi i8 [ %18, %14 ], [ %4, %3 ]
%8 = phi i8* [ %16, %14 ], [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @PolySubst.area, i64 0, i64 0), %3 ]
%9 = phi i8* [ %17, %14 ], [ %0, %3 ]
%10 = tail call i64 @MatchClass(i8 signext %1, i8 signext %7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = load i8, i8* %9
br label %14
14: ; preds = %6, %12
%15 = phi i8 [ %13, %12 ], [ %2, %6 ]
%16 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %15, i8* %8
%17 = getelementptr inbounds i8, i8* %9, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %6
20: ; preds = %14, %3
%21 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @PolySubst.area, i64 0, i64 0), %3 ], [ %16, %14 ]
store i8 0, i8* %21
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @PolySubst.area, i64 0, i64 0)
}