#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);
int /*<<< orphan*/ tolower(char);
void stringRemoveNonAlphaNum(char *str) {
  unsigned long i = 0;
  unsigned long j = 0;
  char c;
  while ((c = str[i++]) != '\0') {
    if (isalnum(c)) {
      str[j++] = c;
    }
    tolower(c);
  }
  str[j] = '\0';
}


x86 assembly (clang, -O0):
<stringRemoveNonAlphaNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     119b <stringRemoveNonAlphaNum+0x7b>
movsbl -0x19(%rbp),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     118d <stringRemoveNonAlphaNum+0x6d>
mov    -0x19(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x18(%rbp)
mov    %dl,(%rax,%rcx,1)
movsbl -0x19(%rbp),%edi
call   1040 <tolower@plt>
jmp    113c <stringRemoveNonAlphaNum+0x1c>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringRemoveNonAlphaNum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%r12b
test   %r12b,%r12b
je     116e <stringRemoveNonAlphaNum+0x4e>
lea    0x1(%r14),%rbx
xor    %r15d,%r15d
jmp    1154 <stringRemoveNonAlphaNum+0x34>
nopl   0x0(%rax)
mov    %ebp,%edi
call   1040 <tolower@plt>
movzbl (%rbx),%r12d
add    $0x1,%rbx
test   %r12b,%r12b
je     1171 <stringRemoveNonAlphaNum+0x51>
movsbl %r12b,%ebp
mov    %ebp,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1140 <stringRemoveNonAlphaNum+0x20>
mov    %r12b,(%r14,%r15,1)
add    $0x1,%r15
jmp    1140 <stringRemoveNonAlphaNum+0x20>
xor    %r15d,%r15d
movb   $0x0,(%r14,%r15,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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