void trim_trailing_whitespace(int *prv_spaces, char **dst, char *out_line) {
  while (*dst > out_line && (*((*dst) - 1) == ' ' || *((*dst) - 1) == '\t'))
    (*dst)--;
  *prv_spaces = 0;
}


x86 assembly (clang, -O0):
<trim_trailing_whitespace>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x19(%rbp)
jbe    1159 <trim_trailing_whitespace+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl -0x1(%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x1a(%rbp)
je     1153 <trim_trailing_whitespace+0x53>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl -0x1(%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1169 <trim_trailing_whitespace+0x69>
jmp    117c <trim_trailing_whitespace+0x7c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%rax)
jmp    1110 <trim_trailing_whitespace+0x10>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim_trailing_whitespace>:
mov    (%rsi),%rax
cmp    %rdx,%rax
jbe    112c <trim_trailing_whitespace+0x2c>
add    $0xffffffffffffffff,%rax
jmp    111f <trim_trailing_whitespace+0x1f>
xchg   %ax,%ax
mov    %rax,(%rsi)
lea    -0x1(%rax),%rcx
cmp    %rdx,%rax
mov    %rcx,%rax
jbe    112c <trim_trailing_whitespace+0x2c>
movzbl (%rax),%ecx
cmp    $0x20,%cl
je     1110 <trim_trailing_whitespace+0x10>
cmp    $0x9,%cl
je     1110 <trim_trailing_whitespace+0x10>
movl   $0x0,(%rdi)
ret

LLVM IR (-O0):
define void @trim_trailing_whitespace(i32* %0, i8** %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i8*
store i32* %0, i32** %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
br label %7
7: ; preds = %30, %3
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
%10 = load i8*, i8** %6
%11 = icmp ugt i8* %9, %10
br i1 %11, label %12, label %28
12: ; preds = %7
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i64 -1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 32
br i1 %18, label %26, label %19
19: ; preds = %12
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 -1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 9
br label %26
26: ; preds = %19, %12
%27 = phi i1 [ true, %12 ], [ %25, %19 ]
br label %28
28: ; preds = %26, %7
%29 = phi i1 [ false, %7 ], [ %27, %26 ]
br i1 %29, label %30, label %34
30: ; preds = %28
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i32 -1
store i8* %33, i8** %31
br label %7
34: ; preds = %28
%35 = load i32*, i32** %4
store i32 0, i32* %35
ret void
}

LLVM IR (-O2):
define void @trim_trailing_whitespace(i32* nocapture writeonly %0, i8** nocapture %1, i8* readnone %2) {
%4 = load i8*, i8** %1
%5 = icmp ugt i8* %4, %2
br i1 %5, label %6, label %12
6: ; preds = %3, %10
%7 = phi i8* [ %8, %10 ], [ %4, %3 ]
%8 = getelementptr inbounds i8, i8* %7, i64 -1
%9 = load i8, i8* %8
switch i8 %9, label %12 [
i8 32, label %10
i8 9, label %10
]
10: ; preds = %6, %6
store i8* %8, i8** %1
%11 = icmp ugt i8* %8, %2
br i1 %11, label %6, label %12
12: ; preds = %10, %6, %3
store i32 0, i32* %0
ret void
}