#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 *);
int strlen(char *);
char *stripleadingspaces(char *s) {
  char s2[256];
  int c = 0, x, l = strlen(s);
  while (s[c] == ' ')
    c++;
  for (x = c; x <= (l + 1); x++)
    s2[x - c] = s[x];
  strcpy(s, s2);
  return &s[0];
}


x86 assembly (clang, -O0):
<stripleadingspaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x11c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x114(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1174 <stripleadingspaces+0x54>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1148 <stripleadingspaces+0x28>
mov    -0x114(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    -0x118(%rbp),%eax
mov    -0x11c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     11ce <stripleadingspaces+0xae>
mov    -0x8(%rbp),%rax
movslq -0x118(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x118(%rbp),%eax
sub    -0x114(%rbp),%eax
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    1180 <stripleadingspaces+0x60>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stripleadingspaces>:
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x2(%rax),%ecx
mov    $0xffffffffffffffff,%rdx
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ecx
cmpb   $0x20,0x1(%rbx,%rdx,1)
lea    0x1(%rdx),%rdx
je     1150 <stripleadingspaces+0x20>
add    $0x1,%eax
cmp    %edx,%eax
jl     1178 <stripleadingspaces+0x48>
mov    %edx,%esi
add    %rbx,%rsi
mov    %ecx,%edx
add    $0x1,%rdx
mov    %rsp,%rdi
call   1050 <memcpy@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x100,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @stripleadingspaces(i8* returned %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
br label %6
6: ; preds = %6, %1
%7 = phi i64 [ %11, %6 ], [ 0, %1 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 32
%11 = add nuw i64 %7, 1
br i1 %10, label %6, label %12
12: ; preds = %6
%13 = trunc i64 %7 to i32
%14 = add i32 %5, 1
%15 = icmp slt i32 %14, %13
br i1 %15, label %22, label %16
16: ; preds = %12
%17 = and i64 %7, 4294967295
%18 = getelementptr i8, i8* %0, i64 %17
%19 = sub i32 %14, %13
%20 = zext i32 %19 to i64
%21 = add nuw nsw i64 %20, 1
br label %22
22: ; preds = %16, %12
%23 = call i32 @strcpy(i8* %0, i8* %4)
ret i8* %0
}