#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*/ *strchr(char const *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void strtrim(char cadena[]) {
  if (cadena != NULL) {
    static const char *Espacios = " \t\n\r";
    char *fin = cadena + strlen(cadena);
    char *inicioReal;
    char *finReal;
    for (inicioReal = cadena; strchr(Espacios, *inicioReal) != NULL;
         ++inicioReal)
      ;
    for (finReal = fin - 1; strchr(Espacios, *finReal) != NULL; --finReal)
      ;
    *(finReal + 1) = 0;
    strcpy(cadena, inicioReal);
  }
}


x86 assembly (clang, -O0):
<strtrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11f7 <strtrim+0xc7>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2ec1(%rip),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     11a3 <strtrim+0x73>
jmp    1192 <strtrim+0x62>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1170 <strtrim+0x40>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    0x2e82(%rip),%rdi
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     11e2 <strtrim+0xb2>
jmp    11d1 <strtrim+0xa1>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    11af <strtrim+0x7f>
mov    -0x20(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtrim>:
test   %rdi,%rdi
je     11bc <strtrim+0x8c>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
movslq %eax,%r12
lea    -0x1(%r14),%r13
lea    0xea8(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%r13),%esi
add    $0x1,%r13
mov    %r15,%rdi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1160 <strtrim+0x30>
lea    (%r12,%r14,1),%rbx
add    $0x1,%rbx
lea    0xe7b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsbl -0x2(%rbx),%esi
mov    %r15,%rdi
call   1050 <strchr@plt>
add    $0xffffffffffffffff,%rbx
test   %rax,%rax
jne    1190 <strtrim+0x60>
movb   $0x0,(%rbx)
mov    %r14,%rdi
mov    %r13,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>
ret

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

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