#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) {
    char c = *s2;
    if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
      ++s2;
    else
      break;
  }
  char *r = strdup(s2);
  free(s1);
  return r;
}


x86 assembly (clang, -O0):
<flu_strtrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x20,%eax
je     118e <flu_strtrim+0x5e>
movsbl -0x19(%rbp),%eax
cmp    $0x9,%eax
je     118e <flu_strtrim+0x5e>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     118e <flu_strtrim+0x5e>
movsbl -0x19(%rbp),%eax
cmp    $0xd,%eax
jne    119f <flu_strtrim+0x6f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a4 <flu_strtrim+0x74>
jmp    11a9 <flu_strtrim+0x79>
jmp    1151 <flu_strtrim+0x21>
mov    -0x18(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%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
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @flu_strrtrim(i8* %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
store i8* %9, i8** %4
br label %10
10: ; preds = %1, %32
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
store i8 %12, i8* %5
%13 = load i8, i8* %5
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 32
br i1 %15, label %28, label %16
16: ; preds = %10
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 9
br i1 %19, label %28, label %20
20: ; preds = %16
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 10
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 13
br i1 %27, label %28, label %31
28: ; preds = %24, %20, %16, %10
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
br label %32
31: ; preds = %24
br label %33
32: ; preds = %28
br label %10
33: ; preds = %31
%34 = load i8*, i8** %4
%35 = call i8* @strdup(i8* %34)
store i8* %35, i8** %6
%36 = load i8*, i8** %3
%37 = call i32 @free(i8* %36)
%38 = load i8*, i8** %6
ret i8* %38
}

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 13, label %6
i8 10, label %6
i8 9, 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
}