#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 *flu_strrtrim(char const *);
int /*<<< orphan*/ free(char *);
char *strdup(char *);
char *flu_strtrim(const char *s) {
  char *s1 = flu_strrtrim(s);
  char *s2 = s1;
  while (1) {
    if (*s2 == ' ' || *s2 == '\t' || *s2 == '\n' || *s2 == '\r')
      ++s2;
    else
      break;
  }
  char *r = strdup(s2);
  free(s1);
  return r;
}


x86 assembly (clang, -O0):
<flu_strtrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <flu_strrtrim@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1191 <flu_strtrim+0x61>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     1191 <flu_strtrim+0x61>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1191 <flu_strtrim+0x61>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    11a2 <flu_strtrim+0x72>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a7 <flu_strtrim+0x77>
jmp    11ac <flu_strtrim+0x7c>
jmp    1151 <flu_strtrim+0x21>
mov    -0x18(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flu_strtrim>:
push   %r14
push   %rbx
push   %rax
call   1050 <flu_strrtrim@plt>
mov    %rax,%r14
movabs $0x100002600,%rax
mov    %r14,%rdi
nopl   0x0(%rax)
movzbl (%rdi),%ecx
cmp    $0x20,%rcx
ja     1165 <flu_strtrim+0x35>
bt     %rcx,%rax
jae    1165 <flu_strtrim+0x35>
add    $0x1,%rdi
jmp    1150 <flu_strtrim+0x20>
call   1040 <strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @flu_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 = call i8* @flu_strrtrim(i8* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
store i8* %8, i8** %4
br label %9
9: ; preds = %1, %33
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 32
br i1 %13, label %29, label %14
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 9
br i1 %18, label %29, label %19
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 10
br i1 %23, label %29, label %24
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 13
br i1 %28, label %29, label %32
29: ; preds = %24, %19, %14, %9
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
br label %33
32: ; preds = %24
br label %34
33: ; preds = %29
br label %9
34: ; preds = %32
%35 = load i8*, i8** %4
%36 = call i8* @strdup(i8* %35)
store i8* %36, i8** %5
%37 = load i8*, i8** %3
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %5
ret i8* %39
}

LLVM IR (-O2):
define noalias i8* @flu_strtrim(i8* %0) {
%2 = tail call i8* @flu_strrtrim(i8* %0)
br label %3
3: ; preds = %6, %1
%4 = phi i8* [ %2, %1 ], [ %7, %6 ]
%5 = load i8, i8* %4
switch i8 %5, label %8 [
i8 32, label %6
i8 9, label %6
i8 10, label %6
i8 13, label %6
]
6: ; preds = %3, %3, %3, %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3
%9 = tail call i8* @strdup(i8* %4)
%10 = tail call i32 @free(i8* %2)
ret i8* %9
}