#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*/ assert(char *);
int /*<<< orphan*/ isspace(char);
int strlen(char *);
void str_right_adjust(char *str) {
  register int len;
  assert(str);
  len = strlen(str);
  while (len--) {
    if (!isspace(str[len])) {
      str[len + 1] = '\0';
      return;
    }
  }
}


x86 assembly (clang, -O0):
<str_right_adjust>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     119a <str_right_adjust+0x6a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    1195 <str_right_adjust+0x65>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    119a <str_right_adjust+0x6a>
jmp    1151 <str_right_adjust+0x21>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_right_adjust>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
mov    %rcx,%rax
shl    $0x20,%rax
movabs $0x100000000,%r12
add    %rax,%r12
movabs $0xffffffff00000000,%r15
ff ff ff
mov    %rcx,%rbx
nopl   0x0(%rax)
sub    $0x1,%rbx
jb     1194 <str_right_adjust+0x64>
movsbl -0x1(%r14,%rcx,1),%edi
call   1040 <isspace@plt>
add    %r15,%r12
mov    %rbx,%rcx
test   %eax,%eax
jne    1170 <str_right_adjust+0x40>
sar    $0x20,%r12
movb   $0x0,(%r14,%r12,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @str_right_adjust(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @assert(i8* %4)
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %3
br label %8
8: ; preds = %26, %1
%9 = load i32, i32* %3
%10 = add nsw i32 %9, -1
store i32 %10, i32* %3
%11 = icmp ne i32 %9, 0
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @isspace(i8 signext %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %12
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
store i8 0, i8* %25
br label %27
26: ; preds = %12
br label %8
27: ; preds = %20, %8
ret void
}

LLVM IR (-O2):
define void @str_right_adjust(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i32 @strlen(i8* %0)
%4 = sext i32 %3 to i64
br label %5
5: ; preds = %9, %1
%6 = phi i64 [ %7, %9 ], [ %4, %1 ]
%7 = add nsw i64 %6, -1
%8 = icmp eq i64 %6, 0
br i1 %8, label %18, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 %7
%11 = load i8, i8* %10
%12 = tail call i32 @isspace(i8 signext %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %9
%15 = shl i64 %6, 32
%16 = ashr exact i64 %15, 32
%17 = getelementptr inbounds i8, i8* %0, i64 %16
store i8 0, i8* %17
br label %18
18: ; preds = %5, %14
ret void
}