void Wremove_trailing_blanks(char *p) {
  char *st = p;
  if (!(*p))
    return;
  do
    p++;
  while (*p);
  p--;
  while ((((((*p) > 8) && ((*p) < 14)) || ((*p) == 32))) && (p != st))
    p--;
  if (((((*p) > 8) && ((*p) < 14)) || ((*p) == 32))) {
    *p = '\n';
    p[1] = '\0';
  } else {
    p[1] = '\n';
    p[2] = '\0';
  }
}


x86 assembly (clang, -O0):
<Wremove_trailing_blanks>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1122 <Wremove_trailing_blanks+0x22>
jmp    1204 <Wremove_trailing_blanks+0x104>
jmp    1127 <Wremove_trailing_blanks+0x27>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1127 <Wremove_trailing_blanks+0x27>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x8,%eax
jle    116c <Wremove_trailing_blanks+0x6c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xe,%eax
jl     1181 <Wremove_trailing_blanks+0x81>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x11(%rbp)
jne    118f <Wremove_trailing_blanks+0x8f>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    119f <Wremove_trailing_blanks+0x9f>
jmp    11b0 <Wremove_trailing_blanks+0xb0>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
jmp    114c <Wremove_trailing_blanks+0x4c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x8,%eax
jle    11d0 <Wremove_trailing_blanks+0xd0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xe,%eax
jl     11e0 <Wremove_trailing_blanks+0xe0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11f4 <Wremove_trailing_blanks+0xf4>
mov    -0x8(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x1(%rax)
jmp    1204 <Wremove_trailing_blanks+0x104>
mov    -0x8(%rbp),%rax
movb   $0xa,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x0,0x2(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<Wremove_trailing_blanks>:
cmpb   $0x0,(%rdi)
je     116f <Wremove_trailing_blanks+0x6f>
mov    $0x1,%eax
mov    $0x1,%ecx
nop
add    $0xffffffffffffffff,%rcx
cmpb   $0x0,(%rdi,%rax,1)
lea    0x1(%rax),%rax
jne    1110 <Wremove_trailing_blanks+0x10>
mov    %rdi,%rax
sub    %rcx,%rax
jmp    113d <Wremove_trailing_blanks+0x3d>
cs nopw 0x0(%rax,%rax,1)
test   %rcx,%rcx
je     1162 <Wremove_trailing_blanks+0x62>
add    $0xffffffffffffffff,%rax
add    $0x1,%rcx
movzbl (%rax),%edx
lea    -0x9(%rdx),%esi
cmp    $0x5,%sil
jb     1130 <Wremove_trailing_blanks+0x30>
test   %rcx,%rcx
je     1153 <Wremove_trailing_blanks+0x53>
cmp    $0x20,%dl
je     1135 <Wremove_trailing_blanks+0x35>
cmp    $0x20,%dl
je     1165 <Wremove_trailing_blanks+0x65>
movb   $0xa,0x1(%rax)
add    $0x2,%rax
jmp    116c <Wremove_trailing_blanks+0x6c>
mov    %rdi,%rax
movb   $0xa,(%rax)
add    $0x1,%rax
movb   $0x0,(%rax)
ret

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

LLVM IR (-O2):
define void @Wremove_trailing_blanks(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %32, label %4
4: ; preds = %1, %4
%5 = phi i8* [ %6, %4 ], [ %0, %1 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %4
9: ; preds = %4, %20
%10 = phi i8* [ %21, %20 ], [ %5, %4 ]
%11 = load i8, i8* %10
%12 = add i8 %11, -9
%13 = icmp ult i8 %12, 5
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = icmp ne i8 %11, 32
%16 = icmp eq i8* %10, %0
%17 = or i1 %16, %15
br i1 %17, label %22, label %20
18: ; preds = %9
%19 = icmp eq i8* %10, %0
br i1 %19, label %24, label %20
20: ; preds = %14, %18
%21 = getelementptr inbounds i8, i8* %10, i64 -1
br label %9
22: ; preds = %14
%23 = icmp eq i8 %11, 32
br i1 %23, label %24, label %27
24: ; preds = %18, %22
%25 = phi i8* [ %10, %22 ], [ %0, %18 ]
store i8 10, i8* %25
%26 = getelementptr inbounds i8, i8* %25, i64 1
br label %30
27: ; preds = %22
%28 = getelementptr inbounds i8, i8* %10, i64 1
store i8 10, i8* %28
%29 = getelementptr inbounds i8, i8* %10, i64 2
br label %30
30: ; preds = %27, %24
%31 = phi i8* [ %26, %24 ], [ %29, %27 ]
store i8 0, i8* %31
br label %32
32: ; preds = %30, %1
ret void
}