#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*/ mmp_str_trim(char *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int /*<<< orphan*/ xfree(char *);
char *xstrdup(char *);
int test_str_trim(void) {
  char *p;
  if ((p = xstrdup(" test \n  \t\n")) == NULL)
    return -1;
  if (strcmp(mmp_str_trim(p), "test") != 0) {
    xfree(p);
    return -1;
  }
  xfree(p);
  return 0;
}


x86 assembly (clang, -O0):
<test_str_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <xstrdup@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    116e <test_str_trim+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <test_str_trim+0x74>
mov    -0x10(%rbp),%rdi
call   1060 <mmp_str_trim@plt>
mov    %eax,%edi
lea    0xe8c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11a4 <test_str_trim+0x64>
mov    -0x10(%rbp),%rdi
call   1030 <xfree@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <test_str_trim+0x74>
mov    -0x10(%rbp),%rdi
call   1030 <xfree@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_str_trim>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
call   1040 <xstrdup@plt>
test   %rax,%rax
je     1180 <test_str_trim+0x40>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <mmp_str_trim@plt>
lea    0xea5(%rip),%rsi
mov    %eax,%edi
call   1050 <strcmp@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <xfree@plt>
neg    %r14
sbb    %eax,%eax
jmp    1185 <test_str_trim+0x45>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c" test \0A \09\0A\00"
@.str.1 = [5 x i8] c"test\00"
define i32 @test_str_trim() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @xstrdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 -1, i32* %1
br label %17
6: ; preds = %0
%7 = load i8*, i8** %2
%8 = call i32 @mmp_str_trim(i8* %7)
%9 = call i64 @strcmp(i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = call i32 @xfree(i8* %12)
store i32 -1, i32* %1
br label %17
14: ; preds = %6
%15 = load i8*, i8** %2
%16 = call i32 @xfree(i8* %15)
store i32 0, i32* %1
br label %17
17: ; preds = %14, %11, %5
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [12 x i8] c" test \0A \09\0A\00"
@.str.1 = [5 x i8] c"test\00"
define i32 @test_str_trim() {
%1 = tail call i8* @xstrdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i32 @mmp_str_trim(i8* %1)
%5 = tail call i64 @strcmp(i32 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
%7 = tail call i32 @xfree(i8* %1)
%8 = sext i1 %6 to i32
br label %9
9: ; preds = %3, %0
%10 = phi i32 [ -1, %0 ], [ %8, %3 ]
ret i32 %10
}