#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 {
  int /*<<< orphan*/ *d_name;
};

/* Variables and functions */
int /*<<< orphan*/ isdigit(int /*<<< orphan*/);
int strlen(int /*<<< orphan*/ *);
int is_pid(const struct dirent *directory) {
  int name_length = strlen(directory->d_name);
  for (int i = 0; i < name_length; i++)
    if (!isdigit(directory->d_name[i]))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<is_pid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1189 <is_pid+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1176 <is_pid+0x56>
movl   $0x0,-0x4(%rbp)
jmp    1190 <is_pid+0x70>
jmp    117b <is_pid+0x5b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1142 <is_pid+0x22>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_pid>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1161 <is_pid+0x51>
mov    %eax,%ecx
mov    (%rbx),%rdx
mov    (%rdx),%esi
add    $0xffffffd0,%esi
xor    %eax,%eax
cmp    $0x9,%esi
ja     115f <is_pid+0x4f>
mov    %ecx,%ecx
mov    $0x1,%eax
nopl   0x0(%rax,%rax,1)
mov    %rax,%rsi
cmp    %rax,%rcx
je     1157 <is_pid+0x47>
mov    (%rdx,%rsi,4),%edi
add    $0xffffffd0,%edi
lea    0x1(%rsi),%rax
cmp    $0xa,%edi
jb     1140 <is_pid+0x30>
xor    %eax,%eax
cmp    %rcx,%rsi
setae  %al
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.dirent = type { i32* }
define i32 @is_pid(%struct.dirent* nocapture %0) {
%2 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%3 = load i32*, i32** %2
%4 = tail call i32 @strlen(i32* %3)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %25
6: ; preds = %1
%7 = load i32*, i32** %2
%8 = zext i32 %4 to i64
%9 = zext i32 %4 to i64
%10 = load i32, i32* %7
%11 = add i32 %10, -48
%12 = icmp ult i32 %11, 10
br i1 %12, label %13, label %25
13: ; preds = %6, %16
%14 = phi i64 [ %21, %16 ], [ 1, %6 ]
%15 = icmp eq i64 %14, %9
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = getelementptr inbounds i32, i32* %7, i64 %14
%18 = load i32, i32* %17
%19 = add i32 %18, -48
%20 = icmp ult i32 %19, 10
%21 = add nuw nsw i64 %14, 1
br i1 %20, label %13, label %22
22: ; preds = %13, %16
%23 = icmp uge i64 %14, %8
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %22, %6, %1
%26 = phi i32 [ 1, %1 ], [ 0, %6 ], [ %24, %22 ]
ret i32 %26
}