#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*/ fail_test(int);
scalar_t__ str_cmp(char *, char *);
int /*<<< orphan*/ str_cpy(char *, char *);
int str_len(char *);
char *str_trim(char *);
void test_trim() {
  char s[64];
  str_cpy(s, " \r  \n \t  abc\t\t\t\r\r");
  char *res = str_trim(s);
  if (str_len(res) != 3)
    fail_test(207);
  ;
  if (str_cmp("abc", res) != 0)
    fail_test(210);
  ;
}


x86 assembly (clang, -O0):
<test_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x40(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <str_cpy@plt>
lea    -0x40(%rbp),%rdi
call   1070 <str_trim@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <str_len@plt>
cmp    $0x3,%eax
je     1191 <test_trim+0x41>
mov    $0xcf,%edi
call   1030 <fail_test@plt>
mov    -0x48(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1040 <str_cmp@plt>
cmp    $0x0,%rax
je     11b5 <test_trim+0x65>
mov    $0xd2,%edi
call   1030 <fail_test@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_trim>:
push   %rbx
sub    $0x40,%rsp
lea    0xea4(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <str_cpy@plt>
mov    %rbx,%rdi
call   1070 <str_trim@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <str_len@plt>
cmp    $0x3,%eax
je     1189 <test_trim+0x39>
mov    $0xcf,%edi
call   1030 <fail_test@plt>
lea    0xe82(%rip),%rdi
mov    %rbx,%rsi
call   1040 <str_cmp@plt>
test   %rax,%rax
je     11a7 <test_trim+0x57>
mov    $0xd2,%edi
call   1030 <fail_test@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c" \0D \0A \09 abc\09\09\09\0D\0D\00"
@.str.1 = [4 x i8] c"abc\00"
define void @test_trim() {
%1 = alloca [64 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = call i32 @str_cpy(i8* %3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%6 = call i8* @str_trim(i8* %5)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @str_len(i8* %7)
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @fail_test(i32 207)
br label %12
12: ; preds = %10, %0
%13 = load i8*, i8** %2
%14 = call i64 @str_cmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @fail_test(i32 210)
br label %18
18: ; preds = %16, %12
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c" \0D \0A \09 abc\09\09\09\0D\0D\00"
@.str.1 = [4 x i8] c"abc\00"
define void @test_trim() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = call i32 @str_cpy(i8* %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i8* @str_trim(i8* %2)
%5 = call i32 @str_len(i8* %4)
%6 = icmp eq i32 %5, 3
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @fail_test(i32 207)
br label %9
9: ; preds = %7, %0
%10 = call i64 @str_cmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @fail_test(i32 210)
br label %14
14: ; preds = %12, %9
ret void
}