#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*/ memcpy(char *, char *, int);
int strmlen(char *);
void strmdelsp(char *s) {
  if (s != NULL) {
    char test[strmlen(s) + 1];
    register unsigned int counter = 1;
    memcpy(test, s, strmlen(s) + 1);
    for (; counter < (strmlen(test)); ++counter) {
      test[counter - 1] = test[counter];
      if (test[counter] < 32)
        test[--counter] = 0;
    }
    memcpy(s, test, strmlen(test) + 1);
  }
}


x86 assembly (clang, -O0):
<strmdelsp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1221 <strmdelsp+0x101>
mov    -0x8(%rbp),%rdi
call   1030 <strmlen@plt>
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strmlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1040 <memcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    %eax,-0x34(%rbp)
call   1030 <strmlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jae    11f7 <strmdelsp+0xd7>
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jge    11e4 <strmdelsp+0xc4>
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    11e9 <strmdelsp+0xc9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1190 <strmdelsp+0x70>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
call   1030 <strmlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1040 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strmdelsp>:
test   %rdi,%rdi
je     11dd <strmdelsp+0xbd>
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strmlen@plt>
mov    %rsp,%r15
add    $0x1,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r14,%rdi
call   1030 <strmlen@plt>
lea    0x1(%rax),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <memcpy@plt>
mov    %r12,%rdi
call   1030 <strmlen@plt>
cmp    $0x2,%eax
jb     11b6 <strmdelsp+0x96>
mov    $0x1,%ebx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
movzbl (%r12,%rax,1),%eax
lea    -0x1(%rbx),%ecx
cmp    $0x20,%al
cmovl  %r13d,%eax
mov    %al,(%r12,%rcx,1)
cmovl  %ecx,%ebx
add    $0x1,%ebx
mov    %r12,%rdi
call   1030 <strmlen@plt>
cmp    %eax,%ebx
jb     1190 <strmdelsp+0x70>
mov    %r12,%rdi
call   1030 <strmlen@plt>
lea    0x1(%rax),%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <memcpy@plt>
mov    %r15,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @strmdelsp(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %54
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @strmlen(i8* %9)
%11 = add nsw i32 %10, 1
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %3
%14 = alloca i8, i64 %12
store i64 %12, i64* %4
store i32 1, i32* %5
%15 = load i8*, i8** %2
%16 = load i8*, i8** %2
%17 = call i32 @strmlen(i8* %16)
%18 = add nsw i32 %17, 1
%19 = call i32 @memcpy(i8* %14, i8* %15, i32 %18)
br label %20
20: ; preds = %45, %8
%21 = load i32, i32* %5
%22 = call i32 @strmlen(i8* %14)
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %48
24: ; preds = %20
%25 = load i32, i32* %5
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %14, i64 %26
%28 = load i8, i8* %27
%29 = load i32, i32* %5
%30 = sub i32 %29, 1
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %14, i64 %31
store i8 %28, i8* %32
%33 = load i32, i32* %5
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %14, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp slt i32 %37, 32
br i1 %38, label %39, label %44
39: ; preds = %24
%40 = load i32, i32* %5
%41 = add i32 %40, -1
store i32 %41, i32* %5
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %14, i64 %42
store i8 0, i8* %43
br label %44
44: ; preds = %39, %24
br label %45
45: ; preds = %44
%46 = load i32, i32* %5
%47 = add i32 %46, 1
store i32 %47, i32* %5
br label %20
48: ; preds = %20
%49 = load i8*, i8** %2
%50 = call i32 @strmlen(i8* %14)
%51 = add nsw i32 %50, 1
%52 = call i32 @memcpy(i8* %49, i8* %14, i32 %51)
%53 = load i8*, i8** %3
br label %54
54: ; preds = %48, %1
ret void
}

LLVM IR (-O2):
define void @strmdelsp(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %32, label %3
3: ; preds = %1
%4 = tail call i32 @strmlen(i8* %0)
%5 = add nsw i32 %4, 1
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = tail call i32 @strmlen(i8* %0)
%10 = add nsw i32 %9, 1
%11 = call i32 @memcpy(i8* %8, i8* %0, i32 %10)
%12 = call i32 @strmlen(i8* %8)
%13 = icmp ugt i32 %12, 1
br i1 %13, label %14, label %28
14: ; preds = %3, %14
%15 = phi i32 [ %25, %14 ], [ 1, %3 ]
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %8, i64 %16
%18 = load i8, i8* %17
%19 = add i32 %15, -1
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %8, i64 %20
%22 = icmp slt i8 %18, 32
%23 = select i1 %22, i8 0, i8 %18
store i8 %23, i8* %21
%24 = select i1 %22, i32 %19, i32 %15
%25 = add i32 %24, 1
%26 = call i32 @strmlen(i8* %8)
%27 = icmp ult i32 %25, %26
br i1 %27, label %14, label %28
28: ; preds = %14, %3
%29 = call i32 @strmlen(i8* %8)
%30 = add nsw i32 %29, 1
%31 = call i32 @memcpy(i8* %0, i8* %8, i32 %30)
br label %32
32: ; preds = %28, %1
ret void
}