#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 */
scalar_t__ isspace(unsigned char);
unsigned char *adjust_s(unsigned char *stop, unsigned char *s) {
  unsigned char *t = s;
  while (t > stop && isspace(t[-1]))
    --t;
  if (isspace(*t))
    *t = '\0';
  while (isspace(s[1]))
    ++s;
  return s;
}


x86 assembly (clang, -O0):
<adjust_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jbe    1152 <adjust_s+0x42>
mov    -0x18(%rbp),%rax
movzbl -0x1(%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1162 <adjust_s+0x52>
jmp    1173 <adjust_s+0x63>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <adjust_s+0x18>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1190 <adjust_s+0x80>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    1195 <adjust_s+0x85>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     11bd <adjust_s+0xad>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1195 <adjust_s+0x85>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_s>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%r15
cmp    %r14,%r12
jbe    114b <adjust_s+0x3b>
lea    -0x1(%r15),%r12
movzbl -0x1(%r15),%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1130 <adjust_s+0x20>
movzbl (%r15),%edi
call   1030 <isspace@plt>
test   %rax,%rax
je     115d <adjust_s+0x4d>
movb   $0x0,(%r15)
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x2(%rbx),%edi
call   1030 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1170 <adjust_s+0x60>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @adjust_s(i8* readnone %0, i8* %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i8* [ %1, %2 ], [ %7, %6 ]
%5 = icmp ugt i8* %4, %0
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 -1
%8 = load i8, i8* %7
%9 = tail call i64 @isspace(i8 zeroext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %3
11: ; preds = %3, %6
%12 = load i8, i8* %4
%13 = tail call i64 @isspace(i8 zeroext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11
store i8 0, i8* %4
br label %16
16: ; preds = %15, %11
br label %17
17: ; preds = %16, %17
%18 = phi i8* [ %19, %17 ], [ %1, %16 ]
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = tail call i64 @isspace(i8 zeroext %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %17
23: ; preds = %17
ret i8* %18
}