#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 *const, char *, scalar_t__);
scalar_t__ strlen(char *);
void str_ltrim(char *const start) {
  char *s;
  for (s = start; isspace(*s); s++)
    ;
  if (s > start)
    memmove(start, s, strlen(s) + 1);
}


x86 assembly (clang, -O0):
<str_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     1170 <str_ltrim+0x40>
jmp    115f <str_ltrim+0x2f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <str_ltrim+0x14>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    11ab <str_ltrim+0x7b>
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):
<str_ltrim>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    -0x1(%rdi),%rbx
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1140 <str_ltrim+0x10>
cmp    %r14,%rbx
jbe    1175 <str_ltrim+0x45>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <memmove@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @str_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 = %11, %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 %14
10: ; preds = %5
br label %11
11: ; preds = %10
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %3
br label %5
14: ; preds = %5
%15 = load i8*, i8** %3
%16 = load i8*, i8** %2
%17 = icmp ugt i8* %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = load i8*, i8** %3
%21 = load i8*, i8** %3
%22 = call i64 @strlen(i8* %21)
%23 = add nsw i64 %22, 1
%24 = call i32 @memmove(i8* %19, i8* %20, i64 %23)
br label %25
25: ; preds = %18, %14
ret void
}

LLVM IR (-O2):
define void @str_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 ugt i8* %3, %0
br i1 %9, label %10, label %14
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
}