#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 */
char *fcitx_utils_malloc(size_t);
int /*<<< orphan*/ fcitx_utils_trim_helper(char const *, char **, char **);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
__attribute__((visibility("default"))) char *fcitx_utils_trim(const char *s) {
  char *start, *end;
  fcitx_utils_trim_helper(s, &start, &end);
  size_t len = end - s;
  char *result = fcitx_utils_malloc(len + 1);
  memcpy(result, s, len);
  result[len] = '\0';
  return result;
}


x86 assembly (clang, -O0):
<fcitx_utils_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <fcitx_utils_trim_helper@plt>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1050 <fcitx_utils_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcitx_utils_trim>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <fcitx_utils_trim_helper@plt>
mov    (%rsp),%rbx
sub    %r14,%rbx
lea    0x1(%rbx),%rdi
call   1050 <fcitx_utils_malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <memcpy@plt>
movb   $0x0,(%r15,%rbx,1)
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @fcitx_utils_trim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @fcitx_utils_trim_helper(i8* %7, i8** %3, i8** %4)
%9 = load i8*, i8** %4
%10 = load i8*, i8** %2
%11 = ptrtoint i8* %9 to i64
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %11, %12
store i64 %13, i64* %5
%14 = load i64, i64* %5
%15 = add i64 %14, 1
%16 = call i8* @fcitx_utils_malloc(i64 %15)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = load i8*, i8** %2
%19 = load i64, i64* %5
%20 = call i32 @memcpy(i8* %17, i8* %18, i64 %19)
%21 = load i8*, i8** %6
%22 = load i64, i64* %5
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8 0, i8* %23
%24 = load i8*, i8** %6
ret i8* %24
}

LLVM IR (-O2):
define i8* @fcitx_utils_trim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = bitcast i8** %2 to i8*
%5 = bitcast i8** %3 to i8*
%6 = call i32 @fcitx_utils_trim_helper(i8* %0, i8** %2, i8** %3)
%7 = load i8*, i8** %3
%8 = ptrtoint i8* %7 to i64
%9 = ptrtoint i8* %0 to i64
%10 = sub i64 %8, %9
%11 = add i64 %10, 1
%12 = call i8* @fcitx_utils_malloc(i64 %11)
%13 = call i32 @memcpy(i8* %12, i8* %0, i64 %10)
%14 = getelementptr inbounds i8, i8* %12, i64 %10
store i8 0, i8* %14
ret i8* %12
}