#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__ isalnum(char);
int consume_number(char *p) {
  int len = 1;
  char c = p[1];
  for (;;) {
    if (!(isalnum(c) || c == '.' || c == '_')) {
      break;
    }
    c = p[++len];
  }
  return len;
}


x86 assembly (clang, -O0):
<consume_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    115f <consume_number+0x4f>
movsbl -0xd(%rbp),%eax
cmp    $0x2e,%eax
je     115f <consume_number+0x4f>
movsbl -0xd(%rbp),%eax
cmp    $0x5f,%eax
je     115f <consume_number+0x4f>
jmp    117a <consume_number+0x6a>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
jmp    112d <consume_number+0x1d>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consume_number>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x1,%r15d
jmp    1124 <consume_number+0x14>
add    $0x1,%r15
movzbl (%r14,%r15,1),%ebx
movsbl %bl,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1120 <consume_number+0x10>
cmp    $0x5f,%bl
je     1120 <consume_number+0x10>
cmp    $0x2e,%bl
je     1120 <consume_number+0x10>
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @consume_number(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
store i32 1, i32* %3
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %6
store i8 %7, i8* %4
br label %8
8: ; preds = %21, %1
%9 = load i8, i8* %4
%10 = call i64 @isalnum(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %8
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 46
br i1 %15, label %21, label %16
16: ; preds = %12
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 95
br i1 %19, label %21, label %20
20: ; preds = %16
br label %28
21: ; preds = %16, %12, %8
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %4
br label %8
28: ; preds = %20
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @consume_number(i8* nocapture %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i64 [ %11, %10 ], [ 1, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = tail call i64 @isalnum(i8 signext %5)
%7 = freeze i64 %6
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
switch i8 %5, label %12 [
i8 95, label %10
i8 46, label %10
]
10: ; preds = %9, %9, %2
%11 = add nuw i64 %3, 1
br label %2
12: ; preds = %9
%13 = trunc i64 %3 to i32
ret i32 %13
}