#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);
int remove_space(char line[], int size) {
  while (size > 0) {
    if (!isspace(line[size - 1]))
      break;
    else
      size--;
  }
  line[size] = '\0';
  return size;
}


x86 assembly (clang, -O0):
<remove_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    115b <remove_space+0x4b>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    114d <remove_space+0x3d>
jmp    115b <remove_space+0x4b>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    111f <remove_space+0xf>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_space>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %esi,%ebx
xor    %ebp,%ebp
test   %esi,%esi
cmovs  %esi,%ebp
test   %ebx,%ebx
jle    113c <remove_space+0x2c>
movsbl -0x1(%r14,%rbx,1),%edi
add    $0xffffffffffffffff,%rbx
call   1030 <isspace@plt>
test   %eax,%eax
jne    1120 <remove_space+0x10>
add    $0x1,%ebx
mov    %ebx,%ebp
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @remove_space(i8* nocapture %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = call i32 @llvm.smin.i32(i32 %1, i32 0)
br label %5
5: ; preds = %9, %2
%6 = phi i64 [ %10, %9 ], [ %3, %2 ]
%7 = trunc i64 %6 to i32
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = add nsw i64 %6, -1
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = tail call i32 @isspace(i8 signext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %5
15: ; preds = %9
%16 = trunc i64 %6 to i32
br label %17
17: ; preds = %5, %15
%18 = phi i32 [ %16, %15 ], [ %4, %5 ]
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 0, i8* %20
ret i32 %18
}