#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*/ isblank(char);
int /*<<< orphan*/ iscntrl(char);
int /*<<< orphan*/ isspace(char);
int strlen(char *);
void tidyStringUp(char *string) {
  int i;
  i = strlen(string);
  for (; i > -1; i--) {
    if (!isspace(string[i]) && !isblank(string[i]) && !iscntrl(string[i]))
      break;
    string[i] = '\0';
  }
}


x86 assembly (clang, -O0):
<tidyStringUp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jle    11cf <tidyStringUp+0x8f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    11b5 <tidyStringUp+0x75>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isblank@plt>
cmp    $0x0,%eax
jne    11b5 <tidyStringUp+0x75>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%eax
jne    11b5 <tidyStringUp+0x75>
jmp    11cf <tidyStringUp+0x8f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <tidyStringUp+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tidyStringUp>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
js     1199 <tidyStringUp+0x59>
mov    %eax,%ebx
add    $0x1,%rbx
jmp    116c <tidyStringUp+0x2c>
nopl   0x0(%rax,%rax,1)
movb   $0x0,-0x1(%r14,%rbx,1)
add    $0xffffffffffffffff,%rbx
jle    1199 <tidyStringUp+0x59>
movsbl -0x1(%r14,%rbx,1),%edi
call   1060 <isspace@plt>
test   %eax,%eax
jne    1160 <tidyStringUp+0x20>
movsbl -0x1(%r14,%rbx,1),%edi
call   1050 <isblank@plt>
test   %eax,%eax
jne    1160 <tidyStringUp+0x20>
movsbl -0x1(%r14,%rbx,1),%edi
call   1030 <iscntrl@plt>
test   %eax,%eax
jne    1160 <tidyStringUp+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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