#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 */
char *gs_reject(char *, char const *);
int /*<<< orphan*/ memmove(char *, char *, scalar_t__);
scalar_t__ strlen(char *);
char *gs_c_ltrim(char *str, const char *reject) {
  char *s = gs_reject(str, reject);
  if (!s) {
    *str = 0;
    return str;
  }
  if (s == str)
    return str;
  memmove(str, s, strlen(s) + 1);
  return str;
}


x86 assembly (clang, -O0):
<gs_c_ltrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <gs_reject@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1170 <gs_c_ltrim+0x40>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <gs_c_ltrim+0x90>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    118b <gs_c_ltrim+0x5b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <gs_c_ltrim+0x90>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1050 <memmove@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gs_c_ltrim>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <gs_reject@plt>
test   %rax,%rax
je     1162 <gs_c_ltrim+0x32>
mov    %rax,%rbx
cmp    %r14,%rax
je     1166 <gs_c_ltrim+0x36>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <memmove@plt>
jmp    1166 <gs_c_ltrim+0x36>
movb   $0x0,(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @gs_c_ltrim(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i8* @gs_reject(i8* %7, i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i8*, i8** %4
store i8 0, i8* %13
%14 = load i8*, i8** %4
store i8* %14, i8** %3
br label %29
15: ; preds = %2
%16 = load i8*, i8** %6
%17 = load i8*, i8** %4
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = load i8*, i8** %4
store i8* %20, i8** %3
br label %29
21: ; preds = %15
%22 = load i8*, i8** %4
%23 = load i8*, i8** %6
%24 = load i8*, i8** %6
%25 = call i64 @strlen(i8* %24)
%26 = add nsw i64 %25, 1
%27 = call i32 @memmove(i8* %22, i8* %23, i64 %26)
%28 = load i8*, i8** %4
store i8* %28, i8** %3
br label %29
29: ; preds = %21, %19, %12
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
define i8* @gs_c_ltrim(i8* returned %0, i8* %1) {
%3 = tail call i8* @gs_reject(i8* %0, i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %6
5: ; preds = %2
store i8 0, i8* %0
br label %12
6: ; preds = %2
%7 = icmp eq i8* %3, %0
br i1 %7, label %12, label %8
8: ; preds = %6
%9 = tail call i64 @strlen(i8* %3)
%10 = add nsw i64 %9, 1
%11 = tail call i32 @memmove(i8* %0, i8* %3, i64 %10)
br label %12
12: ; preds = %6, %8, %5
ret i8* %0
}