#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*/ assert(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ trim(char *);
void test_trim() {
  char str[512];
  printf("test_trim...");
  sprintf(str, "%s", "This is a test");
  trim(str);
  assert(strcmp(str, "This is a test") == 0);
  sprintf(str, "%s", "   This is a test");
  trim(str);
  assert(strcmp(str, "This is a test") == 0);
  sprintf(str, "%s", "This is a test   ");
  trim(str);
  assert(strcmp(str, "This is a test") == 0);
  sprintf(str, "%s", "   This is a test   ");
  trim(str);
  assert(strcmp(str, "This is a test") == 0);
  sprintf(str, "%s", "\tThis is a test\t\t");
  trim(str);
  assert(strcmp(str, "This is a test") == 0);
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x200(%rbp),%rdi
lea    0xe98(%rip),%rsi
lea    0xe97(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1040 <trim@plt>
lea    -0x200(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xe4e(%rip),%rsi
lea    0xe4a(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1040 <trim@plt>
lea    -0x200(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xe04(%rip),%rsi
lea    0xe15(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1040 <trim@plt>
lea    -0x200(%rbp),%rdi
lea    0xde4(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xdba(%rip),%rsi
lea    0xdc8(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1040 <trim@plt>
lea    -0x200(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xd70(%rip),%rsi
lea    0xd93(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1040 <trim@plt>
lea    -0x200(%rbp),%rdi
lea    0xd50(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xd69(%rip),%rdi
call   1030 <printf@plt>
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_trim>:
push   %r14
push   %rbx
sub    $0x208,%rsp
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
movabs $0x2073692073696854,%rax
69 73 20
mov    %rax,(%rsp)
movabs $0x74736574206120,%rax
mov    %rax,0x7(%rsp)
lea    0xe86(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <trim@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movups 0xe58(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x74,0x10(%rsp)
mov    %rbx,%rdi
call   1050 <trim@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movups 0xe3a(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x20,0x10(%rsp)
mov    %rbx,%rdi
call   1050 <trim@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movabs $0x20202074736574,%rax
mov    %rax,0xd(%rsp)
movups 0xdf5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rbx,%rdi
call   1050 <trim@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
movups 0xdde(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x9,0x10(%rsp)
mov    %rbx,%rdi
call   1050 <trim@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xdbd(%rip),%rdi
call   1030 <puts@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"test_trim...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [15 x i8] c"This is a test\00"
@.str.3 = [18 x i8] c" This is a test\00"
@.str.4 = [18 x i8] c"This is a test \00"
@.str.5 = [21 x i8] c" This is a test \00"
@.str.6 = [18 x i8] c"\09This is a test\09\09\00"
@.str.7 = [4 x i8] c"Ok\0A\00"
define void @test_trim() {
%1 = alloca [512 x i8]
%2 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%6 = call i32 @trim(i8* %5)
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%13 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%15 = call i32 @trim(i8* %14)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%22 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%24 = call i32 @trim(i8* %23)
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%31 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%33 = call i32 @trim(i8* %32)
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%40 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%42 = call i32 @trim(i8* %41)
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"test_trim...\00"
@.str.2 = [15 x i8] c"This is a test\00"
@.str.3 = [18 x i8] c" This is a test\00"
@.str.4 = [18 x i8] c"This is a test \00"
@.str.5 = [21 x i8] c" This is a test \00"
@.str.6 = [18 x i8] c"\09This is a test\09\09\00"
@str = [3 x i8] c"Ok\00"
define void @test_trim() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @trim(i8* %2)
%5 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @trim(i8* %2)
%10 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @trim(i8* %2)
%15 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @trim(i8* %2)
%20 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 @trim(i8* %2)
%25 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}