#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);
int strlen(char *);
char *stringify(char data[20]) {
  int i, j = 0;
  int length = strlen(data);
  static char string[13];
  for (i = 0; i < length; i++)
    if (isdigit(data[i])) {
      string[j++] = data[i];
    }
  string[j] = '\0';
  return string;
}


x86 assembly (clang, -O0):
<stringify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a3 <stringify+0x83>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1190 <stringify+0x70>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
movslq %eax,%rcx
lea    0x2ea4(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1195 <stringify+0x75>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <stringify+0x26>
movslq -0x10(%rbp),%rcx
lea    0x2e83(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e78(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringify>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
test   %eax,%eax
jle    1179 <stringify+0x59>
mov    %eax,%r14d
xor    %ebx,%ebx
lea    0x2ef1(%rip),%r12
xor    %ebp,%ebp
jmp    1159 <stringify+0x39>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r14
je     117b <stringify+0x5b>
movsbl (%r15,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1150 <stringify+0x30>
movzbl (%r15,%rbx,1),%eax
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %al,(%rcx,%r12,1)
jmp    1150 <stringify+0x30>
xor    %ebp,%ebp
movslq %ebp,%rcx
lea    0x2eac(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stringify.string = internal global [13 x i8] zeroinitializer
define i8* @stringify(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %5
store i32 0, i32* %3
br label %8
8: ; preds = %31, %1
%9 = load i32, i32* %3
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %34
12: ; preds = %8
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = call i64 @isdigit(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %12
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [13 x i8], [13 x i8]* @stringify.string, i64 0, i64 %28
store i8 %25, i8* %29
br label %30
30: ; preds = %20, %12
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %8
34: ; preds = %8
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [13 x i8], [13 x i8]* @stringify.string, i64 0, i64 %36
store i8 0, i8* %37
ret i8* getelementptr inbounds ([13 x i8], [13 x i8]* @stringify.string, i64 0, i64 0)
}

LLVM IR (-O2):
@stringify.string = internal global [13 x i8] zeroinitializer
define i8* @stringify(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %22
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %18
%7 = phi i64 [ 0, %4 ], [ %20, %18 ]
%8 = phi i32 [ 0, %4 ], [ %19, %18 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = tail call i64 @isdigit(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %6
%14 = load i8, i8* %9
%15 = add nsw i32 %8, 1
%16 = sext i32 %8 to i64
%17 = getelementptr inbounds [13 x i8], [13 x i8]* @stringify.string, i64 0, i64 %16
store i8 %14, i8* %17
br label %18
18: ; preds = %6, %13
%19 = phi i32 [ %15, %13 ], [ %8, %6 ]
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %22, label %6
22: ; preds = %18, %1
%23 = phi i32 [ 0, %1 ], [ %19, %18 ]
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [13 x i8], [13 x i8]* @stringify.string, i64 0, i64 %24
store i8 0, i8* %25
ret i8* getelementptr inbounds ([13 x i8], [13 x i8]* @stringify.string, i64 0, i64 0)
}