#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 */
unsigned int strlen(char *);
void StringClean(char *s) {
  unsigned int i;
  int c;
  while (strlen(s) > 0 && ((c = s[strlen(s) - 1]) <= ' ' || c > '~'))
    s[strlen(s) - 1] = '\0';
  while (strlen(s) > 0 && (s[0] <= ' ' || s[0] > '~')) {
    for (i = 1; i <= strlen(s); i++)
      s[i - 1] = s[i];
  }
}


x86 assembly (clang, -O0):
<StringClean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jbe    1176 <StringClean+0x66>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%ecx
mov    %ecx,-0x10(%rbp)
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x12(%rbp)
jle    1170 <StringClean+0x60>
cmpl   $0x7e,-0x10(%rbp)
setg   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1186 <StringClean+0x76>
jmp    11ab <StringClean+0x9b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
jmp    111c <StringClean+0xc>
jmp    11b0 <StringClean+0xa0>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jbe    11f4 <StringClean+0xe4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x2a(%rbp)
jle    11ee <StringClean+0xde>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
setg   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1204 <StringClean+0xf4>
jmp    1253 <StringClean+0x143>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
ja     124e <StringClean+0x13e>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    120b <StringClean+0xfb>
jmp    11b0 <StringClean+0xa0>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StringClean>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
call   1030 <strlen@plt>
test   %eax,%eax
je     119d <StringClean+0x8d>
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
movzbl (%r14,%rax,1),%eax
add    $0x81,%al
cmp    $0xa1,%al
ja     119d <StringClean+0x8d>
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
jmp    1120 <StringClean+0x10>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%al
add    $0x81,%al
cmp    $0xa1,%al
ja     11a9 <StringClean+0x99>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     119d <StringClean+0x8d>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
movzbl (%r14,%rax,1),%eax
lea    -0x1(%rbx),%ecx
mov    %al,(%r14,%rcx,1)
add    $0x1,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebx
jbe    1180 <StringClean+0x70>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jne    1160 <StringClean+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @StringClean(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
br label %5
5: ; preds = %26, %1
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = icmp ugt i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8*, i8** %2
%12 = call i32 @strlen(i8* %11)
%13 = sub i32 %12, 1
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %10, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
store i32 %17, i32* %4
%18 = icmp sle i32 %17, 32
br i1 %18, label %22, label %19
19: ; preds = %9
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 126
br label %22
22: ; preds = %19, %9
%23 = phi i1 [ true, %9 ], [ %21, %19 ]
br label %24
24: ; preds = %22, %5
%25 = phi i1 [ false, %5 ], [ %23, %22 ]
br i1 %25, label %26, label %33
26: ; preds = %24
%27 = load i8*, i8** %2
%28 = load i8*, i8** %2
%29 = call i32 @strlen(i8* %28)
%30 = sub i32 %29, 1
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %27, i64 %31
store i8 0, i8* %32
br label %5
33: ; preds = %24
br label %34
34: ; preds = %74, %33
%35 = load i8*, i8** %2
%36 = call i32 @strlen(i8* %35)
%37 = icmp ugt i32 %36, 0
br i1 %37, label %38, label %52
38: ; preds = %34
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp sle i32 %42, 32
br i1 %43, label %50, label %44
44: ; preds = %38
%45 = load i8*, i8** %2
%46 = getelementptr inbounds i8, i8* %45, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp sgt i32 %48, 126
br label %50
50: ; preds = %44, %38
%51 = phi i1 [ true, %38 ], [ %49, %44 ]
br label %52
52: ; preds = %50, %34
%53 = phi i1 [ false, %34 ], [ %51, %50 ]
br i1 %53, label %54, label %75
54: ; preds = %52
store i32 1, i32* %3
br label %55
55: ; preds = %71, %54
%56 = load i32, i32* %3
%57 = load i8*, i8** %2
%58 = call i32 @strlen(i8* %57)
%59 = icmp ule i32 %56, %58
br i1 %59, label %60, label %74
60: ; preds = %55
%61 = load i8*, i8** %2
%62 = load i32, i32* %3
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = load i8, i8* %64
%66 = load i8*, i8** %2
%67 = load i32, i32* %3
%68 = sub i32 %67, 1
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %66, i64 %69
store i8 %65, i8* %70
br label %71
71: ; preds = %60
%72 = load i32, i32* %3
%73 = add i32 %72, 1
store i32 %73, i32* %3
br label %55
74: ; preds = %55
br label %34
75: ; preds = %52
ret void
}

LLVM IR (-O2):
define void @StringClean(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1, %12
%5 = tail call i32 @strlen(i8* %0)
%6 = add i32 %5, -1
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = add i8 %9, -127
%11 = icmp ult i8 %10, -94
br i1 %11, label %12, label %19
12: ; preds = %4
%13 = tail call i32 @strlen(i8* %0)
%14 = add i32 %13, -1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
store i8 0, i8* %16
%17 = tail call i32 @strlen(i8* %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %4
19: ; preds = %4, %12, %1
%20 = tail call i32 @strlen(i8* %0)
%21 = icmp eq i32 %20, 0
br i1 %21, label %43, label %25
22: ; preds = %32, %29
%23 = tail call i32 @strlen(i8* %0)
%24 = icmp eq i32 %23, 0
br i1 %24, label %43, label %25
25: ; preds = %19, %22
%26 = load i8, i8* %0
%27 = add i8 %26, -127
%28 = icmp ult i8 %27, -94
br i1 %28, label %29, label %43
29: ; preds = %25
%30 = tail call i32 @strlen(i8* %0)
%31 = icmp eq i32 %30, 0
br i1 %31, label %22, label %32
32: ; preds = %29, %32
%33 = phi i32 [ %40, %32 ], [ 1, %29 ]
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %0, i64 %34
%36 = load i8, i8* %35
%37 = add i32 %33, -1
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %0, i64 %38
store i8 %36, i8* %39
%40 = add i32 %33, 1
%41 = tail call i32 @strlen(i8* %0)
%42 = icmp ugt i32 %40, %41
br i1 %42, label %22, label %32
43: ; preds = %22, %25, %19
ret void
}