#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*/ ft_strncpy(char *, char *, int /*<<< orphan*/);
char *ft_strnew(int /*<<< orphan*/);
int /*<<< orphan*/ ft_strtrim_len(char *);
char *ft_strtrim(char const *s) {
  char *str;
  char *src;
  src = (char *)s;
  while (*src != 0 && (*src == ' ' || *src == '\t' || *src == '\n'))
    src++;
  str = ft_strnew(ft_strtrim_len(src));
  if (str != 0) {
    ft_strncpy(str, src, ft_strtrim_len(src));
  }
  return (str);
}


x86 assembly (clang, -O0):
<ft_strtrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1199 <ft_strtrim+0x69>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x1a(%rbp)
je     1193 <ft_strtrim+0x63>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x1a(%rbp)
je     1193 <ft_strtrim+0x63>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a9 <ft_strtrim+0x79>
jmp    11ba <ft_strtrim+0x8a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1144 <ft_strtrim+0x14>
mov    -0x18(%rbp),%rdi
call   1050 <ft_strtrim_len@plt>
mov    %eax,%edi
call   1030 <ft_strnew@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1201 <ft_strtrim+0xd1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <ft_strtrim_len@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <ft_strncpy@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_strtrim>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movabs $0x100000600,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%ecx
cmp    $0x20,%rcx
ja     1165 <ft_strtrim+0x35>
bt     %rcx,%rax
jae    1165 <ft_strtrim+0x35>
add    $0x1,%rbx
jmp    1150 <ft_strtrim+0x20>
mov    %rbx,%rdi
call   1050 <ft_strtrim_len@plt>
mov    %eax,%edi
call   1030 <ft_strnew@plt>
mov    %rax,%r14
test   %rax,%rax
je     1191 <ft_strtrim+0x61>
mov    %rbx,%rdi
call   1050 <ft_strtrim_len@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <ft_strncpy@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @ft_strtrim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %4
br label %6
6: ; preds = %30, %1
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %28
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 32
br i1 %15, label %26, label %16
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 9
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br label %26
26: ; preds = %21, %16, %11
%27 = phi i1 [ true, %16 ], [ true, %11 ], [ %25, %21 ]
br label %28
28: ; preds = %26, %6
%29 = phi i1 [ false, %6 ], [ %27, %26 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %6
33: ; preds = %28
%34 = load i8*, i8** %4
%35 = call i32 @ft_strtrim_len(i8* %34)
%36 = call i8* @ft_strnew(i32 %35)
store i8* %36, i8** %3
%37 = load i8*, i8** %3
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %45
39: ; preds = %33
%40 = load i8*, i8** %3
%41 = load i8*, i8** %4
%42 = load i8*, i8** %4
%43 = call i32 @ft_strtrim_len(i8* %42)
%44 = call i32 @ft_strncpy(i8* %40, i8* %41, i32 %43)
br label %45
45: ; preds = %39, %33
%46 = load i8*, i8** %3
ret i8* %46
}

LLVM IR (-O2):
define i8* @ft_strtrim(i8* %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %6, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %7 [
i8 10, label %5
i8 32, label %5
i8 9, label %5
]
5: ; preds = %2, %2, %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
7: ; preds = %2
%8 = tail call i32 @ft_strtrim_len(i8* %3)
%9 = tail call i8* @ft_strnew(i32 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = tail call i32 @ft_strtrim_len(i8* %3)
%13 = tail call i32 @ft_strncpy(i8* %9, i8* %3, i32 %12)
br label %14
14: ; preds = %11, %7
ret i8* %9
}