#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__ isdigit(char);
char *mask_trim(char *destination, char *source) {
  char *holder = destination;
  while (*source) {
    if (isdigit(*source))
      *destination++ = *source++;
    else
      source++;
  }
  *destination = '\0';
  return holder;
}


x86 assembly (clang, -O0):
<mask_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1183 <mask_trim+0x73>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1172 <mask_trim+0x62>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    117e <mask_trim+0x6e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1128 <mask_trim+0x18>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mask_trim>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rsi),%al
mov    %rdi,%r15
test   %al,%al
je     1155 <mask_trim+0x45>
mov    %rsi,%rbx
add    $0x1,%rbx
mov    %r14,%r15
jmp    113b <mask_trim+0x2b>
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1155 <mask_trim+0x45>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1130 <mask_trim+0x20>
movzbl -0x1(%rbx),%eax
mov    %al,(%r15)
add    $0x1,%r15
jmp    1130 <mask_trim+0x20>
movb   $0x0,(%r15)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @mask_trim(i8* returned writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %19, label %5
5: ; preds = %2, %14
%6 = phi i8 [ %17, %14 ], [ %3, %2 ]
%7 = phi i8* [ %15, %14 ], [ %0, %2 ]
%8 = phi i8* [ %16, %14 ], [ %1, %2 ]
%9 = tail call i64 @isdigit(i8 signext %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %5
%12 = load i8, i8* %8
%13 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %12, i8* %7
br label %14
14: ; preds = %5, %11
%15 = phi i8* [ %13, %11 ], [ %7, %5 ]
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %5
19: ; preds = %14, %2
%20 = phi i8* [ %0, %2 ], [ %15, %14 ]
store i8 0, i8* %20
ret i8* %0
}