#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 */
scalar_t__ isdigit(char const);
int check_for_digit_name(const struct dirent *dent) {
  const char *p = dent->d_name;
  while (*p && isdigit(*p))
    p++;
  return *p ? 0 : 1;
}


x86 assembly (clang, -O0):
<check_for_digit_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1152 <check_for_digit_name+0x42>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1162 <check_for_digit_name+0x52>
jmp    1173 <check_for_digit_name+0x63>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1127 <check_for_digit_name+0x17>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_digit_name>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%rbx
mov    (%rbx),%al
mov    $0x1,%ebp
test   %al,%al
je     1154 <check_for_digit_name+0x44>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     114a <check_for_digit_name+0x3a>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <check_for_digit_name+0x20>
jmp    1154 <check_for_digit_name+0x44>
xor    %ebp,%ebp
cmpb   $0x0,-0x1(%rbx)
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
define i32 @check_for_digit_name(%struct.dirent* %0) {
%2 = alloca %struct.dirent*
%3 = alloca i8*
store %struct.dirent* %0, %struct.dirent** %2
%4 = load %struct.dirent*, %struct.dirent** %2
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i32 0, i32 0
%6 = load i8*, i8** %5
store i8* %6, i8** %3
br label %7
7: ; preds = %19, %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = call i64 @isdigit(i8 signext %14)
%16 = icmp ne i64 %15, 0
br label %17
17: ; preds = %12, %7
%18 = phi i1 [ false, %7 ], [ %16, %12 ]
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %7
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 0, i32 1
ret i32 %28
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
define i32 @check_for_digit_name(%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
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %1, %15
%7 = phi i8 [ %17, %15 ], [ %4, %1 ]
%8 = phi i8* [ %16, %15 ], [ %3, %1 ]
%9 = tail call i64 @isdigit(i8 signext %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = load i8, i8* %8
%13 = icmp eq i8 %12, 0
%14 = zext i1 %13 to i32
br label %19
15: ; preds = %6
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %6
19: ; preds = %15, %11, %1
%20 = phi i32 [ 1, %1 ], [ %14, %11 ], [ 1, %15 ]
ret i32 %20
}