#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*/ isspace(char);
int /*<<< orphan*/ wFree(char *);
char *wPopString();
int /*<<< orphan*/ wPushStringCopy(char *);
void wBasLTrim() {
  char *string, *trimmed;
  string = wPopString();
  trimmed = string;
  while (trimmed[0] != '\0') {
    if (!isspace(trimmed[0])) {
      break;
    }
    trimmed++;
  }
  wPushStringCopy(trimmed);
  wFree(string);
}


x86 assembly (clang, -O0):
<wBasLTrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <wPopString@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1196 <wBasLTrim+0x56>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
jne    1185 <wBasLTrim+0x45>
jmp    1196 <wBasLTrim+0x56>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    115b <wBasLTrim+0x1b>
mov    -0x10(%rbp),%rdi
call   1050 <wPushStringCopy@plt>
mov    -0x8(%rbp),%rdi
call   1060 <wFree@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wBasLTrim>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <wPopString@plt>
mov    %rax,%r14
mov    (%rax),%al
mov    %r14,%rbx
test   %al,%al
je     1178 <wBasLTrim+0x38>
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <isspace@plt>
test   %eax,%eax
je     1178 <wBasLTrim+0x38>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <wBasLTrim+0x20>
mov    %rbx,%rdi
call   1050 <wPushStringCopy@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <wFree@plt>

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

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