#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__ malloc(int);
scalar_t__ strlen(char const *);
char *dbToDBDate(const char *string) {
  char *date;
  int pos = 0;
  date = (char *)malloc(8 + 1);
  for (int i = 0; i < (int)strlen(string); i++) {
    if (string[i] > 47 && string[i] < 58) {
      date[pos] = string[i];
      pos++;
    }
  }
  date[pos] = '\0';
  return date;
}


x86 assembly (clang, -O0):
<dbToDBDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x9,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11c1 <dbToDBDate+0xa1>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jle    11ae <dbToDBDate+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jge    11ae <dbToDBDate+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b3 <dbToDBDate+0x93>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1148 <dbToDBDate+0x28>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbToDBDate>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    $0x9,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    117d <dbToDBDate+0x5d>
xor    %ebx,%ebx
xor    %r12d,%r12d
jmp    1163 <dbToDBDate+0x43>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1180 <dbToDBDate+0x60>
movzbl (%r15,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1150 <dbToDBDate+0x30>
movslq %r12d,%r12
mov    %al,(%r14,%r12,1)
add    $0x1,%r12d
jmp    1150 <dbToDBDate+0x30>
xor    %r12d,%r12d
movslq %r12d,%rax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @dbToDBDate(i8* nocapture %0) {
%2 = tail call i64 @malloc(i32 9)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = trunc i64 %4 to i32
%6 = icmp sgt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %22, %1
%8 = phi i32 [ 0, %1 ], [ %23, %22 ]
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %3, i64 %9
store i8 0, i8* %10
ret i8* %3
11: ; preds = %1, %22
%12 = phi i64 [ %24, %22 ], [ 0, %1 ]
%13 = phi i32 [ %23, %22 ], [ 0, %1 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %12
%15 = load i8, i8* %14
%16 = add i8 %15, -48
%17 = icmp ult i8 %16, 10
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = sext i32 %13 to i64
%20 = getelementptr inbounds i8, i8* %3, i64 %19
store i8 %15, i8* %20
%21 = add nsw i32 %13, 1
br label %22
22: ; preds = %11, %18
%23 = phi i32 [ %21, %18 ], [ %13, %11 ]
%24 = add nuw nsw i64 %12, 1
%25 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%26 = shl i64 %25, 32
%27 = ashr exact i64 %26, 32
%28 = icmp slt i64 %24, %27
br i1 %28, label %11, label %7
}