#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);
void strip(char *buf) {
  int i, j;
  for (i = 0, j = 0; (buf[j] = buf[i]); j += !isspace(buf[i++]))
    ;
}


x86 assembly (clang, -O0):
<strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
cmp    $0x0,%al
je     1180 <strip+0x70>
jmp    114d <strip+0x3d>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    112a <strip+0x1a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1173 <strip+0x63>
mov    %rdi,%r14
movsbl %al,%edi
call   1030 <isspace@plt>
mov    0x1(%r14),%cl
cmp    $0x1,%eax
mov    %r14,%rdx
adc    $0x0,%rdx
mov    %cl,(%rdx)
test   %cl,%cl
je     1173 <strip+0x63>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
lea    0x2(%r14),%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsbl -0x1(%r15),%edi
call   1030 <isspace@plt>
mov    %ebx,%ebx
cmp    $0x1,%eax
adc    $0x0,%rbx
movzbl (%r15),%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%r15
test   %al,%al
jne    1150 <strip+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @strip(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = tail call i32 @isspace(i8 signext %2)
%6 = icmp eq i32 %5, 0
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = zext i1 %6 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 %8, i8* %10
%11 = icmp eq i8 %8, 0
br i1 %11, label %29, label %12
12: ; preds = %4
%13 = zext i1 %6 to i32
br label %14
14: ; preds = %12, %14
%15 = phi i8* [ %7, %12 ], [ %24, %14 ]
%16 = phi i32 [ %13, %12 ], [ %23, %14 ]
%17 = phi i64 [ 1, %12 ], [ %19, %14 ]
%18 = load i8, i8* %15
%19 = add nuw i64 %17, 1
%20 = tail call i32 @isspace(i8 signext %18)
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = add nuw nsw i32 %16, %22
%24 = getelementptr inbounds i8, i8* %0, i64 %19
%25 = load i8, i8* %24
%26 = zext i32 %23 to i64
%27 = getelementptr inbounds i8, i8* %0, i64 %26
store i8 %25, i8* %27
%28 = icmp eq i8 %25, 0
br i1 %28, label %29, label %14
29: ; preds = %14, %4, %1
ret void
}