#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 */
struct dirent {
  char *d_name;
};

/* Variables and functions */
int /*<<< orphan*/ isdigit(char);
size_t strlen(char *);
int filter_pids(const struct dirent *dir) {
  size_t char_idx;
  if (dir->d_name[0] == '.')
    return 0;
  for (char_idx = 0; char_idx < strlen(dir->d_name); ++char_idx) {
    if (!isdigit(dir->d_name[char_idx]))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<filter_pids>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    114b <filter_pids+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11bd <filter_pids+0x9d>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jae    11b6 <filter_pids+0x96>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11a0 <filter_pids+0x80>
movl   $0x0,-0x4(%rbp)
jmp    11bd <filter_pids+0x9d>
jmp    11a5 <filter_pids+0x85>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1153 <filter_pids+0x33>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_pids>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rax
mov    (%rax),%al
test   %al,%al
je     1174 <filter_pids+0x54>
xor    %r14d,%r14d
cmp    $0x2e,%al
je     117a <filter_pids+0x5a>
mov    %rdi,%r15
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     117a <filter_pids+0x5a>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
cmp    %rax,%rbx
jae    1174 <filter_pids+0x54>
movsbl 0x0(%rbp,%rbx,1),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %eax,%eax
jne    1150 <filter_pids+0x30>
jmp    117a <filter_pids+0x5a>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.dirent = type { i8* }
define i32 @filter_pids(%struct.dirent* nocapture %0) {
%2 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 46, label %20
i8 0, label %19
]
5: ; preds = %1
%6 = tail call i32 @isdigit(i8 signext %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %5, %13
%9 = phi i64 [ %18, %13 ], [ 1, %5 ]
%10 = load i8*, i8** %2
%11 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%12 = icmp ult i64 %9, %11
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %10, i64 %9
%15 = load i8, i8* %14
%16 = tail call i32 @isdigit(i8 signext %15)
%17 = icmp eq i32 %16, 0
%18 = add nuw i64 %9, 1
br i1 %17, label %20, label %8
19: ; preds = %1
br label %20
20: ; preds = %8, %13, %5, %1, %19
%21 = phi i32 [ 0, %1 ], [ 1, %19 ], [ 0, %5 ], [ 0, %13 ], [ 1, %8 ]
ret i32 %21
}