#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 */
scalar_t__ isspace(char);
int /*<<< orphan*/ memmove(char *, char *, scalar_t__);
scalar_t__ strlen(char *);
void ltrim(char *str) {
  char *newstart = str;
  while (isspace(*newstart))
    newstart++;
  if (str != newstart)
    memmove(str, newstart, strlen(newstart) + 1);
}


x86 assembly (clang, -O0):
<ltrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     116b <ltrim+0x3b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <ltrim+0x14>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     11a6 <ltrim+0x76>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1050 <memmove@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltrim>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1040 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1140 <ltrim+0x10>
cmp    $0x1,%rbx
je     117d <ltrim+0x4d>
lea    (%r15,%rbx,1),%r14
add    $0xffffffffffffffff,%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <memmove@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @ltrim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %10, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = call i64 @isspace(i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %3
br label %5
13: ; preds = %5
%14 = load i8*, i8** %2
%15 = load i8*, i8** %3
%16 = icmp ne i8* %14, %15
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i8*, i8** %2
%19 = load i8*, i8** %3
%20 = load i8*, i8** %3
%21 = call i64 @strlen(i8* %20)
%22 = add nsw i64 %21, 1
%23 = call i32 @memmove(i8* %18, i8* %19, i64 %22)
br label %24
24: ; preds = %17, %13
ret void
}

LLVM IR (-O2):
define void @ltrim(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %7, %2 ]
%4 = load i8, i8* %3
%5 = tail call i64 @isspace(i8 signext %4)
%6 = icmp eq i64 %5, 0
%7 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = icmp eq i8* %3, %0
br i1 %9, label %14, label %10
10: ; preds = %8
%11 = tail call i64 @strlen(i8* %3)
%12 = add nsw i64 %11, 1
%13 = tail call i32 @memmove(i8* %0, i8* %3, i64 %12)
br label %14
14: ; preds = %10, %8
ret void
}