#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 */
int /*<<< orphan*/ isdigit(char);
int strlen(char *);
int valid_id(char *id) {
  if (!id || !*id)
    return 0;
  if (strlen(id) > 10)
    return 0;
  while (*id) {
    if (!isdigit(*id))
      return 0;
    id++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1144 <valid_id+0x24>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1150 <valid_id+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <valid_id+0x99>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jle    116e <valid_id+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <valid_id+0x99>
jmp    1173 <valid_id+0x53>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b2 <valid_id+0x92>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11a1 <valid_id+0x81>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <valid_id+0x99>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1173 <valid_id+0x53>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_id>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     116c <valid_id+0x4c>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     116c <valid_id+0x4c>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jg     116c <valid_id+0x4c>
mov    (%rbx),%al
test   %al,%al
je     1167 <valid_id+0x47>
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     116c <valid_id+0x4c>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <valid_id+0x30>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @valid_id(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %6, %1
store i32 0, i32* %2
br label %31
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp sgt i32 %13, 10
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 0, i32* %2
br label %31
16: ; preds = %11
br label %17
17: ; preds = %27, %16
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = call i32 @isdigit(i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
store i32 0, i32* %2
br label %31
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %3
br label %17
30: ; preds = %17
store i32 1, i32* %2
br label %31
31: ; preds = %30, %26, %15, %10
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @valid_id(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 10
br i1 %8, label %21, label %9
9: ; preds = %6
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 0
br i1 %11, label %21, label %15
12: ; preds = %15
%13 = load i8, i8* %20
%14 = icmp eq i8 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %9, %12
%16 = phi i8 [ %13, %12 ], [ %10, %9 ]
%17 = phi i8* [ %20, %12 ], [ %0, %9 ]
%18 = tail call i32 @isdigit(i8 signext %16)
%19 = icmp eq i32 %18, 0
%20 = getelementptr inbounds i8, i8* %17, i64 1
br i1 %19, label %21, label %12
21: ; preds = %15, %12, %9, %6, %1, %3
%22 = phi i32 [ 0, %3 ], [ 0, %1 ], [ 0, %6 ], [ 1, %9 ], [ 0, %15 ], [ 1, %12 ]
ret i32 %22
}