#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__ fcitx_utils_isspace(char const);
int strlen(char const *);
int /*<<< orphan*/ strspn(char const *, char *);
__attribute__((always_)) void
fcitx_utils_trim_helper(const char *s, char **pStart, char **pEnd) {
  register const char *end;
  s += strspn(s, "\f\n\r\t\v ");
  end = s + (strlen(s) - 1);
  while (end >= s && fcitx_utils_isspace(*end))
    --end;
  end++;
  *pStart = (char *)s;
  *pEnd = (char *)end;
}


x86 assembly (clang, -O0):
<fcitx_utils_trim_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <strspn@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x29(%rbp)
jb     11b1 <fcitx_utils_trim_helper+0x81>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <fcitx_utils_isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11c1 <fcitx_utils_trim_helper+0x91>
jmp    11d2 <fcitx_utils_trim_helper+0xa2>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1188 <fcitx_utils_trim_helper+0x58>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcitx_utils_trim_helper>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xeb7(%rip),%rsi
call   1050 <strspn@plt>
movslq %eax,%r13
add    %r12,%r13
mov    %r13,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rax,%r13,1),%rbx
add    $0xffffffffffffffff,%rbx
test   %eax,%eax
jle    1186 <fcitx_utils_trim_helper+0x56>
nopw   0x0(%rax,%rax,1)
movsbl (%rbx),%edi
call   1040 <fcitx_utils_isspace@plt>
test   %rax,%rax
je     1186 <fcitx_utils_trim_helper+0x56>
add    $0xffffffffffffffff,%rbx
cmp    %r13,%rbx
jae    1170 <fcitx_utils_trim_helper+0x40>
add    $0x1,%rbx
mov    %r13,(%r15)
mov    %rbx,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\0C\0A\0D\09\0B \00"
define void @fcitx_utils_trim_helper(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%8 = load i8*, i8** %4
%9 = call i32 @strspn(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %4
%11 = sext i32 %9 to i64
%12 = getelementptr inbounds i8, i8* %10, i64 %11
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
store i8* %18, i8** %7
br label %19
19: ; preds = %30, %3
%20 = load i8*, i8** %7
%21 = load i8*, i8** %4
%22 = icmp uge i8* %20, %21
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = call i64 @fcitx_utils_isspace(i8 signext %25)
%27 = icmp ne i64 %26, 0
br label %28
28: ; preds = %23, %19
%29 = phi i1 [ false, %19 ], [ %27, %23 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %7
br label %19
33: ; preds = %28
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %7
%36 = load i8*, i8** %4
%37 = load i8**, i8*** %5
store i8* %36, i8** %37
%38 = load i8*, i8** %7
%39 = load i8**, i8*** %6
store i8* %38, i8** %39
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"\0C\0A\0D\09\0B \00"
define void @fcitx_utils_trim_helper(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i32 @strspn(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i32 @strlen(i8* %6)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
%11 = icmp slt i32 %7, 1
br i1 %11, label %20, label %12
12: ; preds = %3, %17
%13 = phi i8* [ %18, %17 ], [ %10, %3 ]
%14 = load i8, i8* %13
%15 = tail call i64 @fcitx_utils_isspace(i8 signext %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %13, i64 -1
%19 = icmp ult i8* %18, %6
br i1 %19, label %20, label %12
20: ; preds = %12, %17, %3
%21 = phi i8* [ %10, %3 ], [ %18, %17 ], [ %13, %12 ]
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %6, i8** %1
store i8* %22, i8** %2
ret void
}