#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 */
scalar_t__ isspace(char);
int /*<<< orphan*/ memmove(char *, char *, int);
int strlen(char *);
int front_chomp(char *s) {
  int len, i;
  len = strlen(s) + 1;
  for (i = 0; isspace(*(s + i)); ++i)
    ;
  memmove(s, s + i, strlen(s + i) + 1);
  return 0;
}


x86 assembly (clang, -O0):
<front_chomp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1180 <front_chomp+0x50>
jmp    1172 <front_chomp+0x42>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <front_chomp+0x22>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1050 <memmove@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<front_chomp>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x1(%r15,%rbx,1),%edi
call   1040 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <front_chomp+0x20>
mov    %ebx,%r14d
add    %r15,%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <memmove@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @front_chomp(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
br label %3
3: ; preds = %3, %1
%4 = phi i64 [ %9, %3 ], [ 0, %1 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = tail call i64 @isspace(i8 signext %6)
%8 = icmp eq i64 %7, 0
%9 = add nuw i64 %4, 1
br i1 %8, label %10, label %3
10: ; preds = %3
%11 = and i64 %4, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @strlen(i8* %12)
%14 = add nsw i32 %13, 1
%15 = tail call i32 @memmove(i8* %0, i8* %12, i32 %14)
ret i32 0
}