#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 delete_spaces(const char *src, char *dst, int dstlen) {
  char c;
  int i = 0;
  if ((NULL == src) || (NULL == dst) || (dstlen < 0)) {
    return -1;
  }
  while ((c = *src++) != '\0') {
    if (c != ' ') {
      *dst++ = c;
      ++i;
      if (i >= dstlen) {
        return -1;
      }
    }
  }
  *dst = '\0';
  return 0;
}


x86 assembly (clang, -O0):
<delete_spaces>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1138 <delete_spaces+0x38>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     1138 <delete_spaces+0x38>
cmpl   $0x0,-0x1c(%rbp)
jge    1144 <delete_spaces+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <delete_spaces+0xc3>
jmp    1149 <delete_spaces+0x49>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11b5 <delete_spaces+0xb5>
movsbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
je     11b0 <delete_spaces+0xb0>
mov    -0x1d(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11ab <delete_spaces+0xab>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <delete_spaces+0xc3>
jmp    11b0 <delete_spaces+0xb0>
jmp    1149 <delete_spaces+0x49>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_spaces>:
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1146 <delete_spaces+0x46>
test   %rsi,%rsi
je     1146 <delete_spaces+0x46>
test   %edx,%edx
js     1146 <delete_spaces+0x46>
xor    %r8d,%r8d
cs nopw 0x0(%rax,%rax,1)
movzbl (%rdi),%ecx
add    $0x1,%rdi
cmp    $0x20,%cl
je     1120 <delete_spaces+0x20>
test   %cl,%cl
je     1141 <delete_spaces+0x41>
mov    %cl,(%rsi)
add    $0x1,%rsi
add    $0x1,%r8d
cmp    %edx,%r8d
jl     1120 <delete_spaces+0x20>
jmp    1146 <delete_spaces+0x46>
movb   $0x0,(%rsi)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @delete_spaces(i8* %0, i8* writeonly %1, i32 %2) {
%4 = icmp eq i8* %0, null
%5 = icmp eq i8* %1, null
%6 = or i1 %4, %5
%7 = icmp slt i32 %2, 0
%8 = or i1 %6, %7
br i1 %8, label %22, label %9
9: ; preds = %3, %17
%10 = phi i8* [ %18, %17 ], [ %1, %3 ]
%11 = phi i8* [ %15, %17 ], [ %0, %3 ]
%12 = phi i32 [ %19, %17 ], [ 0, %3 ]
br label %13
13: ; preds = %9, %13
%14 = phi i8* [ %15, %13 ], [ %11, %9 ]
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8, i8* %14
switch i8 %16, label %17 [
i8 0, label %21
i8 32, label %13
]
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %16, i8* %10
%19 = add nuw nsw i32 %12, 1
%20 = icmp slt i32 %19, %2
br i1 %20, label %9, label %22
21: ; preds = %13
store i8 0, i8* %10
br label %22
22: ; preds = %17, %3, %21
%23 = phi i32 [ 0, %21 ], [ -1, %3 ], [ -1, %17 ]
ret i32 %23
}