#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*/ strcpy(char *, char *);
char *ltrim(char *str) {
  char *s;
  if (str[0] == '\0')
    return str;
  s = str;
  while (*s && *s == ' ') {
    strcpy(str, &str[1]);
    s = str;
  }
  return str;
}


x86 assembly (clang, -O0):
<ltrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1139 <ltrim+0x29>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <ltrim+0x8c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1166 <ltrim+0x56>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1176 <ltrim+0x66>
jmp    1194 <ltrim+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1141 <ltrim+0x31>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltrim>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmpb   $0x20,(%rdi)
jne    1130 <ltrim+0x20>
lea    0x1(%rbx),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
cmpb   $0x20,(%rbx)
je     1120 <ltrim+0x10>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @ltrim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i8*, i8** %3
store i8* %11, i8** %2
br label %34
12: ; preds = %1
%13 = load i8*, i8** %3
store i8* %13, i8** %4
br label %14
14: ; preds = %26, %12
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 32
br label %24
24: ; preds = %19, %14
%25 = phi i1 [ false, %14 ], [ %23, %19 ]
br i1 %25, label %26, label %32
26: ; preds = %24
%27 = load i8*, i8** %3
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = call i32 @strcpy(i8* %27, i8* %29)
%31 = load i8*, i8** %3
store i8* %31, i8** %4
br label %14
32: ; preds = %24
%33 = load i8*, i8** %3
store i8* %33, i8** %2
br label %34
34: ; preds = %32, %10
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
define i8* @ltrim(i8* returned %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 32
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
br label %6
6: ; preds = %4, %6
%7 = tail call i32 @strcpy(i8* %0, i8* %5)
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 32
br i1 %9, label %6, label %10
10: ; preds = %6, %1
ret i8* %0
}