#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*/ free(char *);
int /*<<< orphan*/ getchar();
char *mlibc_str_trim(char *);
char *mlibc_str_triml(char *);
char *mlibc_str_trimr(char *);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  int code = 0;
  char *test = "  hello world!	     ";
  char *test_triml = mlibc_str_triml(test);
  char *test_trimr = mlibc_str_trimr(test);
  char *test_trim = mlibc_str_trim(test);
  char *test_trim2 = mlibc_str_trim(test);
  char *test_trimr2 = mlibc_str_trimr(test);
  char *test_trim3 = mlibc_str_trim(test);
  char *test_triml2 = mlibc_str_triml(test);
  printf("test: %s, len: %zu\n", test, strlen(test));
  printf("test_triml: %s, len: %zu\n", test_triml, strlen(test_triml));
  printf("test_trimr: %s, len: %zu\n", test_trimr, strlen(test_trimr));
  printf("test_trim: %s, len: %zu\n", test_trim, strlen(test_trim));
  printf("test_trim2: %s, len: %zu\n", test_trim2, strlen(test_trim2));
  printf("test_trimr2: %s, len: %zu\n", test_trimr2, strlen(test_trimr2));
  printf("test_trim3: %s, len: %zu\n", test_trim3, strlen(test_trim3));
  printf("test_triml2: %s, len: %zu\n", test_triml2, strlen(test_triml2));
  free(test_triml);
  free(test_trimr);
  free(test_trim);
  free(test_trim2);
  free(test_trimr2);
  free(test_trim3);
  free(test_triml2);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe69(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <mlibc_str_triml@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <mlibc_str_trimr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <mlibc_str_trim@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <mlibc_str_trim@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <mlibc_str_trimr@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <mlibc_str_trim@plt>
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <mlibc_str_triml@plt>
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x98(%rbp),%rsi
mov    %eax,%edx
lea    0xdfb(%rip),%rdi
call   1070 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
lea    0xde6(%rip),%rdi
call   1070 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x88(%rbp),%rsi
mov    %eax,%edx
lea    0xdd7(%rip),%rdi
call   1070 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
lea    0xdce(%rip),%rdi
call   1070 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
lea    0xdc4(%rip),%rdi
call   1070 <printf@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
lea    0xdbb(%rip),%rdi
call   1070 <printf@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x50(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
lea    0xdb3(%rip),%rdi
call   1070 <printf@plt>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
lea    0xdaa(%rip),%rdi
call   1070 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe7b(%rip),%r15
mov    %r15,%rdi
call   1040 <mlibc_str_triml@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1050 <mlibc_str_trimr@plt>
mov    %rax,(%rsp)
mov    %r15,%rdi
call   1090 <mlibc_str_trim@plt>
mov    %rax,0x8(%rsp)
mov    %r15,%rdi
call   1090 <mlibc_str_trim@plt>
mov    %rax,%r13
mov    %r15,%rdi
call   1050 <mlibc_str_trimr@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1090 <mlibc_str_trim@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1040 <mlibc_str_triml@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0xe31(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
mov    %r12,0x10(%rsp)
mov    %r12,%rdi
call   1060 <strlen@plt>
lea    0xe27(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
mov    (%rsp),%r12
mov    %r12,%rdi
call   1060 <strlen@plt>
lea    0xe24(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
mov    0x8(%rsp),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0xe20(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
mov    %r13,%rdi
call   1060 <strlen@plt>
lea    0xe20(%rip),%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0xe21(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    0xe23(%rip),%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0xe24(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1070 <printf@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c" hello world!\09 \00"
@.str.1 = [20 x i8] c"test: %s, len: %zu\0A\00"
@.str.2 = [26 x i8] c"test_triml: %s, len: %zu\0A\00"
@.str.3 = [26 x i8] c"test_trimr: %s, len: %zu\0A\00"
@.str.4 = [25 x i8] c"test_trim: %s, len: %zu\0A\00"
@.str.5 = [26 x i8] c"test_trim2: %s, len: %zu\0A\00"
@.str.6 = [27 x i8] c"test_trimr2: %s, len: %zu\0A\00"
@.str.7 = [26 x i8] c"test_trim3: %s, len: %zu\0A\00"
@.str.8 = [27 x i8] c"test_triml2: %s, len: %zu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %7
%15 = load i8*, i8** %7
%16 = call i8* @mlibc_str_triml(i8* %15)
store i8* %16, i8** %8
%17 = load i8*, i8** %7
%18 = call i8* @mlibc_str_trimr(i8* %17)
store i8* %18, i8** %9
%19 = load i8*, i8** %7
%20 = call i8* @mlibc_str_trim(i8* %19)
store i8* %20, i8** %10
%21 = load i8*, i8** %7
%22 = call i8* @mlibc_str_trim(i8* %21)
store i8* %22, i8** %11
%23 = load i8*, i8** %7
%24 = call i8* @mlibc_str_trimr(i8* %23)
store i8* %24, i8** %12
%25 = load i8*, i8** %7
%26 = call i8* @mlibc_str_trim(i8* %25)
store i8* %26, i8** %13
%27 = load i8*, i8** %7
%28 = call i8* @mlibc_str_triml(i8* %27)
store i8* %28, i8** %14
%29 = load i8*, i8** %7
%30 = load i8*, i8** %7
%31 = call i32 @strlen(i8* %30)
%32 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %29, i32 %31)
%33 = load i8*, i8** %8
%34 = load i8*, i8** %8
%35 = call i32 @strlen(i8* %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %33, i32 %35)
%37 = load i8*, i8** %9
%38 = load i8*, i8** %9
%39 = call i32 @strlen(i8* %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %37, i32 %39)
%41 = load i8*, i8** %10
%42 = load i8*, i8** %10
%43 = call i32 @strlen(i8* %42)
%44 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %41, i32 %43)
%45 = load i8*, i8** %11
%46 = load i8*, i8** %11
%47 = call i32 @strlen(i8* %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %45, i32 %47)
%49 = load i8*, i8** %12
%50 = load i8*, i8** %12
%51 = call i32 @strlen(i8* %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %49, i32 %51)
%53 = load i8*, i8** %13
%54 = load i8*, i8** %13
%55 = call i32 @strlen(i8* %54)
%56 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %53, i32 %55)
%57 = load i8*, i8** %14
%58 = load i8*, i8** %14
%59 = call i32 @strlen(i8* %58)
%60 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %57, i32 %59)
%61 = load i8*, i8** %8
%62 = call i32 @free(i8* %61)
%63 = load i8*, i8** %9
%64 = call i32 @free(i8* %63)
%65 = load i8*, i8** %10
%66 = call i32 @free(i8* %65)
%67 = load i8*, i8** %11
%68 = call i32 @free(i8* %67)
%69 = load i8*, i8** %12
%70 = call i32 @free(i8* %69)
%71 = load i8*, i8** %13
%72 = call i32 @free(i8* %71)
%73 = load i8*, i8** %14
%74 = call i32 @free(i8* %73)
%75 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c" hello world!\09 \00"
@.str.1 = [20 x i8] c"test: %s, len: %zu\0A\00"
@.str.2 = [26 x i8] c"test_triml: %s, len: %zu\0A\00"
@.str.3 = [26 x i8] c"test_trimr: %s, len: %zu\0A\00"
@.str.4 = [25 x i8] c"test_trim: %s, len: %zu\0A\00"
@.str.5 = [26 x i8] c"test_trim2: %s, len: %zu\0A\00"
@.str.6 = [27 x i8] c"test_trimr2: %s, len: %zu\0A\00"
@.str.7 = [26 x i8] c"test_trim3: %s, len: %zu\0A\00"
@.str.8 = [27 x i8] c"test_triml2: %s, len: %zu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8* @mlibc_str_triml(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = tail call i8* @mlibc_str_trimr(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = tail call i8* @mlibc_str_trim(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* @mlibc_str_trim(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @mlibc_str_trimr(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = tail call i8* @mlibc_str_trim(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = tail call i8* @mlibc_str_triml(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = tail call i32 @strlen(i8* %3)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 %12)
%14 = tail call i32 @strlen(i8* %4)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32 %14)
%16 = tail call i32 @strlen(i8* %5)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %5, i32 %16)
%18 = tail call i32 @strlen(i8* %6)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %6, i32 %18)
%20 = tail call i32 @strlen(i8* %7)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %7, i32 %20)
%22 = tail call i32 @strlen(i8* %8)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %8, i32 %22)
%24 = tail call i32 @strlen(i8* %9)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %9, i32 %24)
%26 = tail call i32 @free(i8* %3)
%27 = tail call i32 @free(i8* %4)
%28 = tail call i32 @free(i8* %5)
%29 = tail call i32 @free(i8* %6)
%30 = tail call i32 @free(i8* %7)
%31 = tail call i32 @free(i8* %8)
%32 = tail call i32 @free(i8* %9)
%33 = tail call i32 (...) @getchar()
ret i32 0
}