#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 /*<<< orphan*/ isalnum(char);
void clean_buffer(char *buffer, int len) {
  int i;
  for (i = 0; i < len; ++i) {
    if (!isalnum(buffer[i]) && buffer[i] != '-' && buffer[i] != '+') {
      buffer[i] = '.';
    }
  }
}


x86 assembly (clang, -O0):
<clean_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1195 <clean_buffer+0x85>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    1182 <clean_buffer+0x72>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     1182 <clean_buffer+0x72>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2b,%eax
je     1182 <clean_buffer+0x72>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x2e,(%rax,%rcx,1)
jmp    1187 <clean_buffer+0x77>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <clean_buffer+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clean_buffer>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    115b <clean_buffer+0x4b>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
jmp    1139 <clean_buffer+0x29>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r14
je     115b <clean_buffer+0x4b>
movsbl (%r15,%rbx,1),%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1130 <clean_buffer+0x20>
movzbl (%r15,%rbx,1),%eax
cmp    $0x2b,%al
je     1130 <clean_buffer+0x20>
cmp    $0x2d,%al
je     1130 <clean_buffer+0x20>
movb   $0x2e,(%r15,%rbx,1)
jmp    1130 <clean_buffer+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @clean_buffer(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %40, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %43
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = call i32 @isalnum(i8 signext %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %39, label %18
18: ; preds = %10
%19 = load i8*, i8** %3
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 45
br i1 %25, label %26, label %39
26: ; preds = %18
%27 = load i8*, i8** %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 43
br i1 %33, label %34, label %39
34: ; preds = %26
%35 = load i8*, i8** %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 46, i8* %38
br label %39
39: ; preds = %34, %26, %18, %10
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %6
43: ; preds = %6
ret void
}

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