#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__ isalnum(char);
void eraseNonAlphaNum(char *s) {
  char *in, *out;
  char c;
  in = out = s;
  for (;;) {
    c = *in++;
    if (c == 0)
      break;
    if (isalnum(c))
      *out++ = c;
  }
  *out = 0;
}


x86 assembly (clang, -O0):
<eraseNonAlphaNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    114e <eraseNonAlphaNum+0x3e>
jmp    117a <eraseNonAlphaNum+0x6a>
movsbl -0x19(%rbp),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     1175 <eraseNonAlphaNum+0x65>
mov    -0x19(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1128 <eraseNonAlphaNum+0x18>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eraseNonAlphaNum>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%bpl
test   %bpl,%bpl
je     1153 <eraseNonAlphaNum+0x43>
lea    0x1(%r14),%rbx
jmp    113c <eraseNonAlphaNum+0x2c>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx),%ebp
add    $0x1,%rbx
test   %bpl,%bpl
je     1153 <eraseNonAlphaNum+0x43>
movsbl %bpl,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1130 <eraseNonAlphaNum+0x20>
mov    %bpl,(%r14)
add    $0x1,%r14
jmp    1130 <eraseNonAlphaNum+0x20>
movb   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @eraseNonAlphaNum(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %13
%5 = phi i8 [ %15, %13 ], [ %2, %1 ]
%6 = phi i8* [ %8, %13 ], [ %0, %1 ]
%7 = phi i8* [ %14, %13 ], [ %0, %1 ]
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = tail call i64 @isalnum(i8 signext %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %5, i8* %7
br label %13
13: ; preds = %11, %4
%14 = phi i8* [ %12, %11 ], [ %7, %4 ]
%15 = load i8, i8* %8
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %13, %1
%18 = phi i8* [ %0, %1 ], [ %14, %13 ]
store i8 0, i8* %18
ret void
}