#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 */
typedef int wchar_t;

/* Variables and functions */
int *StringUtilities_copy_string_part(int const *, int);
int wcslen(int const *);
wchar_t *copy_trimmed_text(const wchar_t *text, int prefix_length) {
  const wchar_t *text_start = text + prefix_length;
  while (*text_start != L'\0' && *text_start == L' ') {
    ++text_start;
  }
  const wchar_t *text_end = text_start + wcslen(text_start);
  while (text_end > text_start && *(text_end - 1) == L' ') {
    --text_end;
  }
  return StringUtilities_copy_string_part(text_start, text_end - text_start);
}


x86 assembly (clang, -O0):
<copy_trimmed_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x21(%rbp)
je     1161 <copy_trimmed_text+0x41>
mov    -0x18(%rbp),%rax
cmpl   $0x20,(%rax)
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1171 <copy_trimmed_text+0x51>
jmp    1182 <copy_trimmed_text+0x62>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    1142 <copy_trimmed_text+0x22>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <wcslen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x31(%rbp)
jbe    11c8 <copy_trimmed_text+0xa8>
mov    -0x20(%rbp),%rax
cmpl   $0x20,-0x4(%rax)
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11d8 <copy_trimmed_text+0xb8>
jmp    11e9 <copy_trimmed_text+0xc9>
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rbp)
jmp    11a7 <copy_trimmed_text+0x87>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,%esi
call   1040 <StringUtilities_copy_string_part@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_trimmed_text>:
push   %r14
push   %rbx
push   %rax
movslq %esi,%rax
lea    (%rdi,%rax,4),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rbx
add    $0x4,%r14
cmpl   $0x20,(%rbx)
je     1130 <copy_trimmed_text+0x10>
mov    %rbx,%rdi
call   1030 <wcslen@plt>
cltq
lea    -0x4(,%rax,4),%rax
ff
xchg   %ax,%ax
mov    %rax,%rsi
add    %r14,%rax
cmp    %rbx,%rax
jbe    1167 <copy_trimmed_text+0x47>
lea    -0x4(%rsi),%rax
cmpl   $0x20,-0x4(%r14,%rsi,1)
je     1150 <copy_trimmed_text+0x30>
add    $0x4,%rsi
shr    $0x2,%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <StringUtilities_copy_string_part@plt>

LLVM IR (-O0):
define i32* @copy_trimmed_text(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %7, i64 %9
store i32* %10, i32** %5
br label %11
11: ; preds = %21, %2
%12 = load i32*, i32** %5
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 32
br label %19
19: ; preds = %15, %11
%20 = phi i1 [ false, %11 ], [ %18, %15 ]
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i32 1
store i32* %23, i32** %5
br label %11
24: ; preds = %19
%25 = load i32*, i32** %5
%26 = load i32*, i32** %5
%27 = call i32 @wcslen(i32* %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %25, i64 %28
store i32* %29, i32** %6
br label %30
30: ; preds = %41, %24
%31 = load i32*, i32** %6
%32 = load i32*, i32** %5
%33 = icmp ugt i32* %31, %32
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i64 -1
%37 = load i32, i32* %36
%38 = icmp eq i32 %37, 32
br label %39
39: ; preds = %34, %30
%40 = phi i1 [ false, %30 ], [ %38, %34 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i32*, i32** %6
%43 = getelementptr inbounds i32, i32* %42, i32 -1
store i32* %43, i32** %6
br label %30
44: ; preds = %39
%45 = load i32*, i32** %5
%46 = load i32*, i32** %6
%47 = load i32*, i32** %5
%48 = ptrtoint i32* %46 to i64
%49 = ptrtoint i32* %47 to i64
%50 = sub i64 %48, %49
%51 = sdiv exact i64 %50, 4
%52 = trunc i64 %51 to i32
%53 = call i32* @StringUtilities_copy_string_part(i32* %45, i32 %52)
ret i32* %53
}

LLVM IR (-O2):
define i32* @copy_trimmed_text(i32* %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i32, i32* %0, i64 %3
br label %5
5: ; preds = %5, %2
%6 = phi i32* [ %4, %2 ], [ %9, %5 ]
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 32
%9 = getelementptr inbounds i32, i32* %6, i64 1
br i1 %8, label %5, label %10
10: ; preds = %5
%11 = tail call i32 @wcslen(i32* %6)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %6, i64 %12
br label %14
14: ; preds = %17, %10
%15 = phi i32* [ %13, %10 ], [ %18, %17 ]
%16 = icmp ugt i32* %15, %6
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = getelementptr inbounds i32, i32* %15, i64 -1
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 32
br i1 %20, label %14, label %21
21: ; preds = %14, %17
%22 = ptrtoint i32* %15 to i64
%23 = ptrtoint i32* %6 to i64
%24 = sub i64 %22, %23
%25 = lshr exact i64 %24, 2
%26 = trunc i64 %25 to i32
%27 = tail call i32* @StringUtilities_copy_string_part(i32* %6, i32 %26)
ret i32* %27
}