#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*/ free(char *);
char *gmx_strdup(char *);
int /*<<< orphan*/ strcpy(char *, char *);
void ltrim(char *str) {
  char *tr;
  int c;
  if (!str)
    return;
  tr = gmx_strdup(str);
  c = 0;
  while ((tr[c] == ' ') || (tr[c] == '\t'))
    c++;
  strcpy(str, tr + c);
  free(tr);
}


x86 assembly (clang, -O0):
<ltrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    114c <ltrim+0x1c>
jmp    11ca <ltrim+0x9a>
mov    -0x8(%rbp),%rdi
call   1050 <gmx_strdup@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x15(%rbp)
je     118f <ltrim+0x5f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    119f <ltrim+0x6f>
jmp    11ad <ltrim+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <ltrim+0x30>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltrim>:
test   %rdi,%rdi
je     1181 <ltrim+0x51>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <gmx_strdup@plt>
mov    %rax,%rbx
xor    %eax,%eax
jmp    1154 <ltrim+0x24>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
movzbl (%rbx,%rax,1),%ecx
cmp    $0x20,%cl
je     1150 <ltrim+0x20>
cmp    $0x9,%cl
je     1150 <ltrim+0x20>
mov    %eax,%eax
mov    %rbx,%rsi
add    %rax,%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
ret

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

LLVM IR (-O2):
define void @ltrim(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i8* @gmx_strdup(i8* %0)
br label %5
5: ; preds = %9, %3
%6 = phi i64 [ %10, %9 ], [ 0, %3 ]
%7 = getelementptr inbounds i8, i8* %4, i64 %6
%8 = load i8, i8* %7
switch i8 %8, label %11 [
i8 32, label %9
i8 9, label %9
]
9: ; preds = %5, %5
%10 = add nuw i64 %6, 1
br label %5
11: ; preds = %5
%12 = and i64 %6, 4294967295
%13 = getelementptr inbounds i8, i8* %4, i64 %12
%14 = tail call i32 @strcpy(i8* %0, i8* %13)
%15 = tail call i32 @free(i8* %4)
br label %16
16: ; preds = %1, %11
ret void
}