#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 */
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
size_t strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
void pi_clean(char **clean, char *dirty) {
  int count = 0, i = 0, l = 0;
  size_t length = 0;
  length = strlen(dirty);
  *clean = malloc(sizeof(char) * length + 1);
  for (i = 0, l = (int)length; i < l; i++) {
    if (dirty[i] >= '0' && dirty[i] <= '9') {
      strncat(*clean, dirty + i, 1);
      count++;
    }
  }
  printf("%s\n", *clean);
}


x86 assembly (clang, -O0):
<pi_clean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1213 <pi_clean+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     1200 <pi_clean+0xc0>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jg     1200 <pi_clean+0xc0>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   1050 <strncat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1205 <pi_clean+0xc5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a5 <pi_clean+0x65>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xddf(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pi_clean>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
mov    %rax,(%r14)
test   %r15d,%r15d
jle    119a <pi_clean+0x5a>
mov    %r15d,%ebx
jmp    117a <pi_clean+0x3a>
xchg   %ax,%ax
add    $0x1,%r12
add    $0xffffffffffffffff,%rbx
je     1197 <pi_clean+0x57>
movzbl (%r12),%eax
add    $0xd0,%al
cmp    $0x9,%al
ja     1170 <pi_clean+0x30>
mov    (%r14),%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1050 <strncat@plt>
jmp    1170 <pi_clean+0x30>
mov    (%r14),%rax
lea    0xe5f(%rip),%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @pi_clean(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i64 0, i64* %8
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
store i64 %10, i64* %8
%11 = load i64, i64* %8
%12 = mul i64 1, %11
%13 = add i64 %12, 1
%14 = trunc i64 %13 to i32
%15 = call i8* @malloc(i32 %14)
%16 = load i8**, i8*** %3
store i8* %15, i8** %16
store i32 0, i32* %6
%17 = load i64, i64* %8
%18 = trunc i64 %17 to i32
store i32 %18, i32* %7
br label %19
19: ; preds = %50, %2
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %53
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp sge i32 %29, 48
br i1 %30, label %31, label %49
31: ; preds = %23
%32 = load i8*, i8** %4
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp sle i32 %37, 57
br i1 %38, label %39, label %49
39: ; preds = %31
%40 = load i8**, i8*** %3
%41 = load i8*, i8** %40
%42 = load i8*, i8** %4
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = call i32 @strncat(i8* %41, i8* %45, i32 1)
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
br label %49
49: ; preds = %39, %31, %23
br label %50
50: ; preds = %49
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %19
53: ; preds = %19
%54 = load i8**, i8*** %3
%55 = load i8*, i8** %54
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %55)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @pi_clean(i8** nocapture %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = trunc i64 %3 to i32
%5 = add i32 %4, 1
%6 = tail call i8* @malloc(i32 %5)
store i8* %6, i8** %0
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = and i64 %3, 4294967295
br label %10
10: ; preds = %8, %19
%11 = phi i64 [ 0, %8 ], [ %20, %19 ]
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = load i8, i8* %12
%14 = add i8 %13, -48
%15 = icmp ult i8 %14, 10
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i8*, i8** %0
%18 = tail call i32 @strncat(i8* %17, i8* %12, i32 1)
br label %19
19: ; preds = %10, %16
%20 = add nuw nsw i64 %11, 1
%21 = icmp eq i64 %20, %9
br i1 %21, label %22, label %10
22: ; preds = %19
%23 = load i8*, i8** %0
br label %24
24: ; preds = %22, %2
%25 = phi i8* [ %23, %22 ], [ %6, %2 ]
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %25)
ret void
}